Jelajahi Sumber

子目增加费设置

zhangweicheng 5 tahun lalu
induk
melakukan
b2efacfad4

+ 3 - 2
web/building_saas/main/js/controllers/block_controller.js

@@ -333,9 +333,10 @@ let BlockController = {
              //主材设备工料机插入主树
              project.ration_glj.addToMainTree(result.ration_gljs);
              //更新计算程序模板,并进行重新计算
-             project.calcProgram.calcNodesAndSave(rationNodes,function () {
+             project.calcProgram.calcNodesAndSave(rationNodes,async function () {
                  installationFeeObj.calcInstallationFee();
-                 OVER_HEIGHT.reCalcOverHeightFee();
+                await OVER_HEIGHT.reCalcOverHeightFee();
+                 await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rationNodes);
              });
         })
 

+ 3 - 2
web/building_saas/main/js/controllers/material_controller.js

@@ -63,9 +63,10 @@ let MaterialController = {
         }
         if(nodes.length >0){
             projectObj.project.projectGLJ.loadData(function () {
-                projectObj.project.calcProgram.calcNodesAndSave(nodes,function(){
+                projectObj.project.calcProgram.calcNodesAndSave(nodes,async function(){
                     installationFeeObj.calcInstallationFee();
-                    OVER_HEIGHT.reCalcOverHeightFee();
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
                 });
                 gljOprObj.refreshView();
             })

+ 13 - 2
web/building_saas/main/js/models/bills.js

@@ -818,13 +818,14 @@ var Bills = {
             updateData.projectID = selected.data.projectID;
             updateData.user_id = userID;
             $.bootstrapLoading.start();
-            CommonAjax.post("/bills/multiDelete", updateData, function () {
+            CommonAjax.post("/bills/multiDelete", updateData, async function () {
                 // 回收删除节点
                 BlockController.recycleBlock(selection);
                 let quantity_detail_datas = project.quantity_detail.datas;
                 let ration_datas = project.Ration.datas;
                 let nodes = controller.tree.nodes;
                 let prefix = controller.tree.prefix;
+                let deleteParentBillIDs = [];
                 //更新缓存
                 if(updateData['bills']){//更新bills
                     for(let b_key in updateData['bills']){
@@ -842,6 +843,8 @@ var Bills = {
                     for(let r_key in updateData['ration']){//定额只有删除,没有更新
                         _.remove(ration_datas,{'ID':r_key});
                         project.Ration.deleteSubListOfRation({ID:r_key});
+                        let tnode = projectObj.project.mainTree.getNodeByID(r_key);
+                        if(tnode) deleteParentBillIDs.push(tnode.data.billsItemID);
                     }
                 }
                 for(let r of refNodes){
@@ -858,7 +861,15 @@ var Bills = {
                     }
                     gljOprObj.refreshView();
                 });
-                OVER_HEIGHT.reCalcOverHeightFee();
+               await OVER_HEIGHT.reCalcOverHeightFee();
+               //计算子目增加费
+                let tbns = [];
+                for(let bID of deleteParentBillIDs){
+                    let bnode = projectObj.project.mainTree.getNodeByID(bID);
+                    if(bnode) tbns.push(bnode);
+                }
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(tbns);
+
                 //添加内容为定额子目时,根据特征及内容添加规则刷新清单
                 if(updateData['ration']){
                     let addRuleSetting = getAddRuleSetting();

+ 2 - 2
web/building_saas/main/js/models/overHeight.js

@@ -1072,7 +1072,7 @@ const OVER_HEIGHT = (() => {
      * 为了降低复杂度和保证逻辑统一性,重新计取为重新走(删除新增逻辑)
      * 需要尽可能地降低操作的触发率
      */
-    function reCalcOverHeightFee() {
+    async function reCalcOverHeightFee() {
         const project = projectObj.project;
         // 如果项目没有超高降效数据,项目不可用超高降效,返回
         if (!project.isOverHeightProject()) {
@@ -1094,7 +1094,7 @@ const OVER_HEIGHT = (() => {
             return;
         }
         // 存在不同,重算
-        handleConfirmed();
+       await handleConfirmed();
     }
 
     // 事件监听

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

@@ -316,8 +316,9 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb
             me.refreshTreeNodePriceIfNeed(glj);//刷新造价书中主树上的定额工料机;
             gljs.push(glj);
             let nodes = me.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
-            projectObj.project.calcProgram.calcNodesAndSave(nodes, function () {
-                OVER_HEIGHT.reCalcOverHeightFee();
+            projectObj.project.calcProgram.calcNodesAndSave(nodes, async function () {
+                await OVER_HEIGHT.reCalcOverHeightFee();
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
             });//触发计算程序
             projectGljObject.onUnitFileChange(data);
             if(cb){

+ 6 - 4
web/building_saas/main/js/models/quantity_detail.js

@@ -771,9 +771,10 @@ var quantity_detail = {
                 /*project.calcProgram.calcNodesAndSave(needUpdateChildren, function () {
                     project.projectGLJ.loadData();
                 });*/
-                project.calcProgram.calcNodesAndSave(needUpdateChildren, function () {
+                project.calcProgram.calcNodesAndSave(needUpdateChildren,async function () {
                     project.projectGLJ.calcQuantity();
-                    OVER_HEIGHT.reCalcOverHeightFee();
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(needUpdateChildren);
                     if(project.Bills.isFBFX(node)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
                         project.installation_fee.calcInstallationFee(function (isChange,rations) {
                             if(isChange){
@@ -816,7 +817,7 @@ var quantity_detail = {
             node.changed = true;
             let rationNodes = mbzm_obj.updateReferenceRationNodeQuantity(node);
             rationNodes.push(node);
-            project.calcProgram.calcNodesAndSave(rationNodes, function () {
+            project.calcProgram.calcNodesAndSave(rationNodes, async function () {
                 project.projectGLJ.calcQuantity();
                 let calcInstall = false;
                 for(let t of rationNodes){
@@ -832,7 +833,8 @@ var quantity_detail = {
                         }
                     });
                 }
-                OVER_HEIGHT.reCalcOverHeightFee();
+                await OVER_HEIGHT.reCalcOverHeightFee();
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rationNodes);
             });
             let childrenNodes = [];
             for(let r of rationNodes){

+ 9 - 3
web/building_saas/main/js/models/ration.js

@@ -440,8 +440,9 @@ var Ration = {
                 project.projectGLJ.loadData(function () {
                     mbzm_obj.nodeChanged = true;//子目模板关联刷新
                     gljOprObj.showDataIfRationSelect(projectObj.project.mainTree.selected,"-111111111");//这里第二个参数是为了使改前和改后selectedID不一样,删除了的话下方的定额工料机不会刷新
-                    project.calcProgram.calcNodesAndSave(refershNodes, function () {
-                        OVER_HEIGHT.reCalcOverHeightFee();
+                    project.calcProgram.calcNodesAndSave(refershNodes, async function () {
+                        await OVER_HEIGHT.reCalcOverHeightFee();
+                        await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(refershNodes);
                     });
                     projectObj.mainController.refreshTreeNode(refershNodes, true);
                     $.bootstrapLoading.end();
@@ -542,14 +543,18 @@ var Ration = {
                                 if(isChange){
                                     rations = rations.concat(newNodes);
                                     project.calcProgram.calcNodesAndSave(rations);
+                                    itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rations);
                                 }else {
                                     project.calcProgram.calcNodesAndSave(newNodes);
+                                    itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
                                 }
                             });
                         }else {
                             project.calcProgram.calcNodesAndSave(newNodes);
+                            itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(newNodes);
                         }
                         updateBillsOprRation();
+
                         if(callback){
                             callback();
                         }
@@ -650,7 +655,8 @@ var Ration = {
                     }else {
                         if(data.projectGLJDatas) projectObj.project.projectGLJ.refreshByDatas(data.projectGLJDatas);
                         syncNodeOper(data);
-                        project.calcProgram.calcAndSave(newNode,function () {
+                        project.calcProgram.calcAndSave(newNode,async function () {
+                            await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([newNode]);
                             if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
                                 installationFeeObj.calcInstallationFee();
                             }

+ 6 - 4
web/building_saas/main/js/models/ration_glj.js

@@ -283,9 +283,10 @@ let ration_glj = {
                     projectObj.mainController.deleteNode(node, next);
                 }
             }
-            project.calcProgram.calcAndSave(rationNode,function () {
+            project.calcProgram.calcAndSave(rationNode,async function () {
                 installationFeeObj.calcInstallationFee();
-                OVER_HEIGHT.reCalcOverHeightFee();
+                await OVER_HEIGHT.reCalcOverHeightFee();
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([rationNode.parent]);
             });
         };
         // CSL,2017.05.09
@@ -1016,8 +1017,9 @@ let ration_glj = {
             let node = this.findRationNodeByID(ration_glj.rationID);
             if (node) {
                 node.changed = true;
-                project.calcProgram.calcAndSave(node, function () {
-                    OVER_HEIGHT.reCalcOverHeightFee();
+                project.calcProgram.calcAndSave(node, async function () {
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([node.parent]);
                 });
             }
         };

+ 6 - 4
web/building_saas/main/js/views/area_increase_fee_view.js

@@ -23,8 +23,9 @@ let areaIncreaseFeeObj = {
         datas.push(data);
         setChildren(node,newval,datas);//同步设置所有子项
         let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
-        projectObj.project.calcProgram.calcNodesAndSave(nodes,function () {
-            OVER_HEIGHT.reCalcOverHeightFee();
+        projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
+            await OVER_HEIGHT.reCalcOverHeightFee();
+            await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
         });
 
 
@@ -115,8 +116,9 @@ let areaIncreaseFeeObj = {
             d.data.areaIncreaseFee = false;
         }
         let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
-        projectObj.project.calcProgram.calcNodesAndSave(nodes,function () {
-            OVER_HEIGHT.reCalcOverHeightFee();
+        projectObj.project.calcProgram.calcNodesAndSave(nodes,async function () {
+            await OVER_HEIGHT.reCalcOverHeightFee();
+            await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(nodes);
         });
     }
     

+ 6 - 4
web/building_saas/main/js/views/glj_view.js

@@ -1319,8 +1319,9 @@ var gljOprObj = {
                     selected.data.adjustState = result.adjustState;
                     selected.data.name = result.name;
                     projectObj.mainController.refreshTreeNode(nodes);
-                    project.calcProgram.calcAndSave(selected, function () {
-                        OVER_HEIGHT.reCalcOverHeightFee();
+                    project.calcProgram.calcAndSave(selected, async function () {
+                       await OVER_HEIGHT.reCalcOverHeightFee();
+                        await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes([selected]);
                     });
                     $.bootstrapLoading.end();
                 });
@@ -1355,8 +1356,9 @@ var gljOprObj = {
             project.projectGLJ.loadData(function () {
                 me.showRationGLJSheetData();
                 var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
-                project.calcProgram.calcNodesAndSave(rationNodes, function () {
-                    OVER_HEIGHT.reCalcOverHeightFee();
+                project.calcProgram.calcNodesAndSave(rationNodes, async function () {
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await  await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(rationNodes);
                 });
                 $.bootstrapLoading.end();
             });

+ 24 - 0
web/building_saas/main/js/views/item_increase_fee_view.js

@@ -217,6 +217,30 @@ let itemIncreaseFeeObj = {
 
         }
     },
+
+
+    calcItemIncreaseFeeByNodes:async function (nodes) {
+        let itemIncreaseSetting = projectObj.project.property.itemIncreaseSetting;
+        let datas = [];
+        let refreshNodes=[];
+        let rationGLJMap ={};
+        let uniqMap={};
+        if(!itemIncreaseSetting) return;
+        for (n of nodes){
+            if(n.sourceType == ModuleNames.ration) n = n.parent;
+            if(uniqMap[n.data.ID]) continue;//去重复
+            let newRefreshNodes = this.calcItemIncreasePerNode(n,itemIncreaseSetting,rationGLJMap,datas);
+            if(newRefreshNodes.length > 0) refreshNodes = refreshNodes.concat(newRefreshNodes);
+            uniqMap[n.data.ID] = true;
+        }
+        if(datas || refreshNodes.length > 0){
+            let nodes = await projectObj.project.syncUpdateNodesAndRefresh(datas);
+            //重新计算
+            cbTools.refreshFormulaNodes();
+            projectObj.project.calcProgram.calcNodesAndSave(refreshNodes.concat(nodes));
+        }
+
+    },
     cancelItemIncreaseFee:async function () {
         let itemIncreaseSetting = projectObj.project.property.itemIncreaseSetting;
         let datas = [];

+ 3 - 2
web/building_saas/main/js/views/mbzm_view.js

@@ -208,9 +208,10 @@ let mbzm_obj={
                 cbTools.refreshFormulaNodes();
                 //更新计算程序模板,并进行重新计算
                 if(parentsNodes.length > 0) calRations = calRations.concat(parentsNodes);//计算被删除的子目关联定额的父节点
-                projectObj.project.calcProgram.calcNodesAndSave(calRations,function () {
+                projectObj.project.calcProgram.calcNodesAndSave(calRations,async function () {
                     installationFeeObj.calcInstallationFee();
-                    OVER_HEIGHT.reCalcOverHeightFee();
+                    await OVER_HEIGHT.reCalcOverHeightFee();
+                    await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(calRations);
                 });
                 mbzm_obj.showApplySuccess();
             });

+ 3 - 2
web/building_saas/main/js/views/project_glj_view.js

@@ -864,10 +864,11 @@ let projectGljObject={
             updateNodes = updateNodes.concat(subRations);
         }
         if(updateNodes.length>0){
-            projectObj.project.calcProgram.calcNodesAndSave(updateNodes,function () {
+            projectObj.project.calcProgram.calcNodesAndSave(updateNodes,async function () {
                 projectObj.mainController.refreshTreeNode(projectObj.project.mainTree.roots);
                 installationFeeObj.calcInstallationFee();//计算安装增加费
-                OVER_HEIGHT.reCalcOverHeightFee();
+               await OVER_HEIGHT.reCalcOverHeightFee();
+                await itemIncreaseFeeObj.calcItemIncreaseFeeByNodes(updateNodes);
             });
         }
         gljOprObj.refreshView();

+ 2 - 2
web/building_saas/main/js/views/zlfb_view.js

@@ -241,7 +241,7 @@ let zlfb_object={
         updateData.projectID = FBFX.data.projectID;
         updateData.user_id = userID;
         $.bootstrapLoading.start();
-        CommonAjax.post('/bills/reorganizeFBFX',updateData,function (data) {
+        CommonAjax.post('/bills/reorganizeFBFX',updateData,async function (data) {
             $.bootstrapLoading.end();
             //更新前端缓存
             let billDatas = projectObj.project.Bills.datas;
@@ -291,7 +291,7 @@ let zlfb_object={
                 projectObj.project.Bills.getEngineeringCostNode(controller).changed = true;
                 projectObj.project.calcProgram.calcAllNodesAndSave();
             });
-            OVER_HEIGHT.reCalcOverHeightFee();
+            await OVER_HEIGHT.reCalcOverHeightFee();
         },function () {
             //errorCallback
         });