Ver código fonte

批量粘贴排序问题。

Chenshilong 8 anos atrás
pai
commit
259ba48316

+ 2 - 2
modules/ration_repository/controllers/coe_controller.js

@@ -21,9 +21,9 @@ module.exports ={
     },
 
     getCoeItemsByIDs: function(req,res){
-        console.log('传入: '+JSON.stringify(JSON.parse(req.body.data)));
+        //console.log('传入: '+JSON.stringify(JSON.parse(req.body.data)));
         coeList.getCoeItemsByIDs(JSON.parse(req.body.data), function(err,data){
-            console.log('返回: '+JSON.stringify(data));
+            //console.log('返回: '+JSON.stringify(data));
             callback(req, res, err, 'Get coe', data);
         });
     }

+ 14 - 3
web/maintain/ration_repository/js/ration_coe.js

@@ -126,17 +126,28 @@ var rationCoeOprObj = {
                                 newAddArr.push(rstArr[i]);
                             };
                         };
+
+                        curCache = curCache.concat(newAddArr);
+
                         curCache.sort(function(a, b) {
                             var rst = 0;
-                            if (a > b) rst = 1
-                            else if (a < b) rst = -1;
+                            if (a.ID > b.ID) rst = 1
+                            else if (a.ID < b.ID) rst = -1;
                             return rst;
                         });
-                        me.cache["_Coe_" + me.curRation.ID] = curCache.concat(newAddArr);
+
+                        me.cache["_Coe_" + me.curRation.ID] = curCache;
                         if (newAddArr.length > 0) {
                             me.updateCurRation();
                         };
                     }else{
+                        rstArr.sort(function(a, b) {
+                            var rst = 0;
+                            if (a.ID > b.ID) rst = 1
+                            else if (a.ID < b.ID) rst = -1;
+                            return rst;
+                        });
+
                         me.cache["_Coe_" + me.curRation.ID] = rstArr;
                         me.updateCurRation();
                     };