Explorar o código

resolve conflict

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

+ 16 - 0
modules/ration_repository/models/ration_item.js

@@ -81,6 +81,22 @@ rationItemDAO.prototype.getRationItemsByCode = function(repId, code,callback){
     })
 };
 
+rationItemDAO.prototype.getRationItem = function (sectionId, code, callback) {
+    if (callback) {
+        rationItemModel.findOne({sectionId: sectionId, code: code}, '-_id').exec()
+            .then(function (result, err) {
+                if (err) {
+                    callback(1, '找不到定额“' + code +'”' , null);
+                } else {
+                    callback(0, '', result);
+                }
+            });
+        return null;
+    } else {
+        return rationItemModel.findOne({sectionId: sectionId, code: code}, '-_id').exec();
+    }
+};
+
 rationItemDAO.prototype.addRationItems = function(rationLibId, sectionId, items,callback){
     if (items && items.length > 0) {
         counter.counterDAO.getIDAfterCount(counter.moduleName.rations, items.length, function(err, result){

+ 2 - 7
web/building_saas/main/js/models/ration.js

@@ -118,29 +118,24 @@ var Ration = {
         };
 
         ration.prototype.insertStdRation = function (billsID, preRation, std) {
-            var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation);
+            var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation), newRation = null;
             updateData.forEach(function (data) {
                 if (data.updateType === 'ut_create') {
                     data.updateData.code = std.code;
                     data.updateData.name = std.name;
                     data.updateData.unit = std.unit;
+                    newRation = data.updateData;
                 }
             });
             this.project.pushNow('insertRation', [this.getSourceType()], [updateData]);
 
-            var newRation = null;
             if (preRation) {
                 var preIndex = br.indexOf(preRation), i;
-                newRation = this.getTempRationData(this.getNewRationID(), billsID, preIndex < br.length - 1 ? br[preIndex + 1].serialNo : br[preIndex].serialNo + 1);
-                newRation.code = std.code;
-                newRation.name = std.name;
-                newRation.unit = std.unit;
                 this.datas.push(newRation);
                 for (i = preIndex + 1; i < br.length; i++) {
                     br[i].serialNo = i < br.length - 1 ? br [i + 1].serialNo : br[i].serialNo + 1;
                 }
             } else {
-                newRation = this.getTempRationData(this.getNewRationID(), billsID, br.length > 0 ? br[br.length - 1].serialNo + 1 : 1);
                 this.datas.push(newRation);
             }
             return newRation;