zhangweicheng 6 лет назад
Родитель
Сommit
a16834d3c7

+ 9 - 1
modules/main/controllers/ration_controller.js

@@ -8,6 +8,7 @@ let ration_facade = require('../facade/ration_facade');
 let bill_facade = require('../facade/bill_facade');
 let project_facade = require("../facade/project_facade");
 let logger = require("../../../logs/log_helper").logger;
+import GLJController from "../../glj/controllers/glj_controller";
 let controller = {
     insertGLJAsRation:async function (req){
         let data = req.body.data;
@@ -78,7 +79,14 @@ let controller = {
     updateCoeAdjust:async function(req){
         let data = req.body.data;
         data = JSON.parse(data);
-        return await ration_facade.updateCoeAdjust(data,req.session.sessionCompilation);
+        let result = await ration_facade.updateCoeAdjust(data,req.session.sessionCompilation);
+        //合并取项目工料机数据的情求,用于刷新项目工料机数据,当有添加、替换项目工料机的情况,才需要刷新
+        if(result.add.length > 0 || result.replace.length > 0){
+            let gljController = new GLJController();
+            let responseData = await gljController.getProjectGLJsByProjectID(data.projectID)
+            result.projectGLJDatas = responseData.data;
+        }
+        return result
 
     }
 

+ 1 - 1
modules/ration_glj/facade/glj_calculate_facade.js

@@ -89,7 +89,7 @@ async function calculateQuantity(query,noNeedCal=null,refreshRationName = false)
             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,mixRatioMap,noNeedCal);
             if(quantityUpdateCheck(gljList[i],r) == true) result.glj_result.push(r);
         }
-         if(noNeedCal==null){
+         if(noNeedCal==null && result.glj_result.length > 0){
              await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
          }
          adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);

+ 8 - 2
web/building_saas/main/js/models/project_glj.js

@@ -44,8 +44,7 @@ ProjectGLJ.prototype.loadData = function (callback = null,error=null) {
                 if(error) error();
                 return false;
             }
-            self.datas = response.data;
-            self.calcQuantity();
+            self.refreshByDatas(response.data);
             // 回调函数
             if (callback !== null) {
                 callback(response.data);
@@ -56,6 +55,13 @@ ProjectGLJ.prototype.loadData = function (callback = null,error=null) {
     });
 };
 
+//更新项目工料机数据和缓存
+ProjectGLJ.prototype.refreshByDatas = function(datas){
+    this.datas = datas;
+    this.calcQuantity();
+};
+
+
 ProjectGLJ.prototype.synLoadData = function () {
     return new Promise(function (resolve, reject) {
         projectObj.project.projectGLJ.loadData(function (data) {

+ 1 - 1
web/building_saas/main/js/models/ration_coe.js

@@ -197,7 +197,7 @@ var ration_coe = {
                 CommonAjax.post("/ration/updateCoeAdjust",updateData,function (result) {
                     $.bootstrapLoading.end();
                     me.refreshAfterUpdate(result.coe);
-                    zmhs_obj.refreshAfterUpdate(result,true)
+                    zmhs_obj.refreshAfterUpdate(result)
                 })
             });
 

+ 7 - 10
web/building_saas/main/js/views/zmhs_view.js

@@ -203,9 +203,9 @@ let zmhs_obj = {
         this.assSheetData = assList;
         return assList;
     },
-    refreshAfterUpdate:function(result,reload){
+    refreshAfterUpdate:function(result){
         let ration_glj = projectObj.project.ration_glj;
-        let calcInstall = false;//是否记安装增加费
+        let calcInstall = false;//是否记安装增加费
         let nodes = projectObj.project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
         if(result.add && result.add.length > 0){//需添加定额工料机的情况
             ration_glj.datas = ration_glj.datas.concat(result.add);
@@ -223,14 +223,11 @@ let zmhs_obj = {
         projectObj.mainController.refreshTreeNode(nodes, false);
 
         let rationID= ration_glj.updateCacheAfterAdjust(result.ration_glj);
-        if(reload == true){//有添加、替换、工料机等需重新加载的情况
-            $.bootstrapLoading.start();
-            projectObj.project.projectGLJ.loadData(function () {
-                $.bootstrapLoading.end();
-                if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);//这个方法有再去项目工料机那里取价格,所以要在回调里调用,不像替换工料的情况
-                ration_glj.reCalcWhenGLJChange({rationID:rationID});
-                if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
-            });
+        if(result.projectGLJDatas){//有添加、替换、工料机等需重新加载的情况
+            projectObj.project.projectGLJ.refreshByDatas(result.projectGLJDatas);
+            if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);//这个方法有再去项目工料机那里取价格,所以要在回调里调用,不像替换工料的情况
+            ration_glj.reCalcWhenGLJChange({rationID:rationID});
+            if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
         }else {
             ration_glj.reCalcWhenGLJChange({rationID:rationID});
         }