瀏覽代碼

ration: delete

MaiXinRong 8 年之前
父節點
當前提交
1a16f59e04
共有 3 個文件被更改,包括 14 次插入6 次删除
  1. 1 1
      modules/main/models/ration.js
  2. 1 1
      web/building_saas/main/html/main.html
  3. 12 4
      web/building_saas/main/js/models/ration.js

+ 1 - 1
modules/main/models/ration.js

@@ -53,7 +53,7 @@ class rationModel extends baseModel {
         });
     };
 
-    save (projectId, datas, callback) {
+    save (user_id, datas, callback) {
         let functions = [];
         let data;
 

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

@@ -740,7 +740,7 @@
                 if (selected.sourceType === project.Bills.getSourceType()) {
                     project.Bills.deleteBills(selected.source);
                     controller.delete();
-                } else if (selected.sourceType === project.Rations.getSourceType()) {
+                } else if (selected.sourceType === project.Ration.getSourceType()) {
                     project.Ration.delete(selected.source);
                     controller.delete();
                 };

+ 12 - 4
web/building_saas/main/js/models/ration.js

@@ -89,7 +89,6 @@ var Ration = {
             }
             return updateData;
         };
-
         ration.prototype.getCounterData = function (count) {
             var updateData = {'projectID': this.project.ID()};
             if (count) {
@@ -99,7 +98,6 @@ var Ration = {
             }
             return updateData;
         };
-
         ration.prototype.insertRation = function (billsID, preRation) {
             var br = this.getBillsSortRation(billsID);
             this.project.pushNow('insertRation', [this.getSourceType(), this.project.projCounter()],
@@ -120,7 +118,6 @@ var Ration = {
             }
             return newRation;
         };
-
         ration.prototype.insertStdRation = function (billsID, preRation, std) {
             var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation), newRation = null;
             updateData.forEach(function (data) {
@@ -146,6 +143,17 @@ var Ration = {
             return newRation;
         };
 
+        ration.prototype.getDeleteData = function (rationData) {
+            var updateData = [];
+            updateData.push({'updateType': 'ut_delete', 'updateData': {'ID': rationData.ID, 'projectID': this.project.ID()}});
+            return updateData;
+        };
+        ration.prototype.delete = function (ration) {
+            this.project.pushNow('deleteRation', [this.getSourceType()], [this.getDeleteData(ration)]);
+
+            this.datas.splice(this.datas.indexOf(ration), 1);
+        };
+
         ration.prototype.getChangePosUpdateData = function (ration1, ration2) {
             var updateData = [];
             updateData.push({updateType: 'ut_update', updateData: this.getTempRationData(ration1.ID, ration1.billsItemID, ration2.serialNo)});
@@ -159,7 +167,7 @@ var Ration = {
             var preSerialNo = ration1.serialNo;
             ration1.serialNo = ration2.serialNo;
             ration2.serialNo = preSerialNo;
-        }
+        };
 
         return new ration(project);
     }