Explorar o código

ration: upMove & downMove

MaiXinRong %!s(int64=8) %!d(string=hai) anos
pai
achega
e6eaa74cc3

+ 1 - 0
modules/ration_repository/routes/ration_front_end_routes.js

@@ -27,6 +27,7 @@ apiRouter.post("/getGljItemsByCodes",repositoryGljController.getGljItemsByCodes)
 
 apiRouter.post("/getCoeList",coeListController.getCoeList);
 
+apiRouter.post('/getRationItem', searchController.getRationItem);
 apiRouter.post('/findRation', searchController.findRation);
 
 module.exports = apiRouter;

+ 6 - 6
web/building_saas/main/html/main.html

@@ -762,25 +762,25 @@
             }
         });
         $('#upMove').click(function () {
-            var selected = controller.tree.selected;
+            var selected = controller.tree.selected, pre, preSerialNo;
             if (selected) {
                 if (selected.sourceType === project.Bills.getSourceType()) {
                     selected.source.upLevel();
                     controller.upMove();
-                } else if (selected.sourceType === project.Rations.getSourceType()) {
-                    // to Do
+                } else if (selected.sourceType === project.Ration.getSourceType()) {
+                    project.Ration.changePos(selected.source, selected.preSibling.source);
                     controller.upMove();
                 }
             }
         });
         $('#downMove').click(function () {
-            var selected = controller.tree.selected;
+            var selected = controller.tree.selected, next, nextSerialNo;
             if (selected) {
                 if (selected.sourceType === project.Bills.getSourceType()) {
                     selected.source.downLevel();
                     controller.downMove();
-                } else if (selected.sourceType === project.Rations.getSourceType()) {
-                    // to Do
+                } else if (selected.sourceType === project.Ration.getSourceType()) {
+                    project.Ration.changePos(selected.source, selected.nextSibling.source);
                     controller.downMove();
                 }
             }

+ 16 - 0
web/building_saas/main/js/models/ration.js

@@ -133,6 +133,7 @@ var Ration = {
             });
             this.project.pushNow('insertRation', [this.getSourceType()], [updateData]);
 
+            newRation.ID = this.getNewRationID();
             if (preRation) {
                 var preIndex = br.indexOf(preRation), i;
                 this.datas.push(newRation);
@@ -145,6 +146,21 @@ var Ration = {
             return newRation;
         };
 
+        ration.prototype.getChangePosUpdateData = function (ration1, ration2) {
+            var updateData = [];
+            updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(ration1.ID, ration1.billsItemID, ration2.serialNo)});
+            updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(ration2.ID, ration2.billsItemID, ration1.serialNo)});
+            return updateData;
+        };
+        ration.prototype.changePos = function (ration1, ration2) {
+            var updateData = this.getChangePosUpdateData(ration1, ration2);
+            this.project.pushNow('insertRation', [this.getSourceType()], [updateData]);
+
+            var preSerialNo = ration1.serialNo;
+            ration1.serialNo = ration2.serialNo;
+            ration2.serialNo = preSerialNo;
+        }
+
         return new ration(project);
     }
 };