zhangweicheng 6 rokov pred
rodič
commit
94d4f9371d

+ 36 - 2
web/building_saas/main/js/models/calc_program.js

@@ -194,7 +194,7 @@ let calcTools = {
         delete treeNode.data.gljList;
         delete treeNode.data.gljList;
         if (this.isRationCategory(treeNode)) {
         if (this.isRationCategory(treeNode)) {
             if (treeNode.data.type != rationType.volumePrice) {
             if (treeNode.data.type != rationType.volumePrice) {
-                treeNode.data.gljList = projectObj.project.ration_glj.getGljArrByRation(treeNode.data);
+                treeNode.data.gljList = projectObj.project.calcProgram.getGljArrByRation(treeNode.data);
             }
             }
         }
         }
         else if (this.isBill(treeNode)){
         else if (this.isBill(treeNode)){
@@ -1438,6 +1438,8 @@ class CalcProgram {
         let me = this;
         let me = this;
         me.project = project;
         me.project = project;
         me.datas = [];
         me.datas = [];
+        me.rationMap = null;//定额 - 工料机映射临时变量
+        me.pgljMap = null;
         project.registerModule(ModuleNames.calc_program, me);
         project.registerModule(ModuleNames.calc_program, me);
     };
     };
 
 
@@ -1637,7 +1639,8 @@ class CalcProgram {
         let me = this;
         let me = this;
         // 仅用作树节点显示的工料机不能参与计算。
         // 仅用作树节点显示的工料机不能参与计算。
         if (treeNode.sourceType === ModuleNames.ration_glj) return;
         if (treeNode.sourceType === ModuleNames.ration_glj) return;
-
+        //设置定额工料机映射表
+        me.setRationMap();
         treeNode.calcType = calcTools.getCalcType(treeNode);
         treeNode.calcType = calcTools.getCalcType(treeNode);
         let nQ = calcTools.uiNodeQty(treeNode);
         let nQ = calcTools.uiNodeQty(treeNode);
         let nTQ = calcTools.uiNodeTenderQty(treeNode);
         let nTQ = calcTools.uiNodeTenderQty(treeNode);
@@ -1931,6 +1934,8 @@ class CalcProgram {
         me.project.updateNodes(dataArr, function (data) {
         me.project.updateNodes(dataArr, function (data) {
             let endShowTime = +new Date();
             let endShowTime = +new Date();
             console.log(`保存所需时间——${endShowTime - startTime}`);
             console.log(`保存所需时间——${endShowTime - startTime}`);
+            me.rationMap = null;
+            me.pgljMap = null;
             if(callback){
             if(callback){
                 callback(data);
                 callback(data);
             };
             };
@@ -2170,6 +2175,35 @@ class CalcProgram {
             projectObj.project.calcProgram.calculate(treeNode, false, false, tenderTypes.ttCalc);  // 再正向算
             projectObj.project.calcProgram.calculate(treeNode, false, false, tenderTypes.ttCalc);  // 再正向算
         };
         };
     };
     };
+    setRationMap(){
+        if(this.rationMap == null){
+            this.rationMap = {};
+            for(let glj of projectObj.project.ration_glj.datas){
+                if(this.rationMap[glj.rationID]){
+                    this.rationMap[glj.rationID].push(glj)
+                }else {
+                    this.rationMap[glj.rationID] = [glj];
+                }
+            }
+        }
+        if(this.pgljMap == null ){
+            this.pgljMap = _.indexBy(projectObj.project.projectGLJ.datas.gljList, 'id');
+        }
+    };
+    getGljArrByRation(ration){
+        if (ration.type == rationType.gljRation){
+            let glj = JSON.parse(JSON.stringify(ration));
+            glj.type = glj.subType;
+            glj.quantity = 1;
+            glj.totalQuantity = parseFloatPlus(ration.quantity);
+            return [glj];
+        } else{
+            if(!this.rationMap) return [];
+            let result = this.rationMap[ration.ID];
+            result = gljOprObj.combineWithProjectGlj(result,false,ration,this.pgljMap);
+            return result;
+        }
+    }
 };
 };
 
 
 // export default analyzer;
 // export default analyzer;

+ 1 - 22
web/building_saas/main/js/models/ration_glj.js

@@ -40,27 +40,6 @@ let ration_glj = {
             this.datas = datas;
             this.datas = datas;
         };
         };
 
 
-        ration_glj.prototype.getGljArrByRation = function (ration) {
-            if (ration.type == rationType.gljRation){
-                let glj = JSON.parse(JSON.stringify(ration));
-                glj.type = glj.subType;
-                glj.quantity = 1;
-                glj.totalQuantity = parseFloatPlus(ration.quantity);
-                return [glj];
-            }
-            else{
-                let result = this.datas.filter(function (data) {
-                    if(data.rationID === ration.ID){
-                        gljOprObj.getTotalQuantity(data, ration);
-                        return true;
-                    }
-                    return false;
-                })
-                result = gljOprObj.combineWithProjectGlj(result);
-                return result;
-            }
-        };
-
         ration_glj.prototype.getGLJListByRationID = function (rationID) {
         ration_glj.prototype.getGLJListByRationID = function (rationID) {
            return  _.filter(this.datas, {'rationID': rationID})
            return  _.filter(this.datas, {'rationID': rationID})
         };
         };
@@ -95,7 +74,7 @@ let ration_glj = {
                     result.push(glj);
                     result.push(glj);
                 }
                 }
                 else{
                 else{
-                    let rationGljs = this.getGljArrByRation(ration);
+                    let rationGljs = projectObj.project.calcProgram.getGljArrByRation(ration);
                     for (let glj of rationGljs) {
                     for (let glj of rationGljs) {
                         let sameGlj = findGlj(glj, result);
                         let sameGlj = findGlj(glj, result);
                         if (!sameGlj) {
                         if (!sameGlj) {

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

@@ -716,14 +716,14 @@ var gljOprObj = {
         }
         }
         this.sheetData = newList;
         this.sheetData = newList;
     },
     },
-    combineWithProjectGlj: function (ration_gljs,needRatio=true) {
+    combineWithProjectGlj: function (ration_gljs,needRatio=true,ration,p_gljMap) {
         let projectGLJData = projectObj.project.projectGLJ.datas;
         let projectGLJData = projectObj.project.projectGLJ.datas;
         let projectGljs = projectGLJData.gljList;
         let projectGljs = projectGLJData.gljList;
         let mixRatioMap = projectGLJData.mixRatioMap;
         let mixRatioMap = projectGLJData.mixRatioMap;
         if (ration_gljs && ration_gljs.length > 0 && projectGljs && projectGljs.length > 0) {
         if (ration_gljs && ration_gljs.length > 0 && projectGljs && projectGljs.length > 0) {
-
+            let pgljMap = p_gljMap?p_gljMap:_.indexBy(projectGljs, 'id');
             for (let i = 0; i < ration_gljs.length; i++) {
             for (let i = 0; i < ration_gljs.length; i++) {
-                let glj = _.find(projectGljs, {'id': ration_gljs[i].projectGLJID});
+                let glj = pgljMap[ration_gljs[i].projectGLJID];
                 if (glj) {
                 if (glj) {
                     if(projectObj.project.projectGLJ.isEstimateType(ration_gljs[i].type )){
                     if(projectObj.project.projectGLJ.isEstimateType(ration_gljs[i].type )){
                         ration_gljs[i].isEstimate = glj.is_evaluate;
                         ration_gljs[i].isEstimate = glj.is_evaluate;
@@ -736,6 +736,7 @@ var gljOprObj = {
                         let mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
                         let mixRatios = this.getMixRationShowDatas(mixRatioMap[connect_index], projectGljs);
                         ration_gljs[i].subList = mixRatios;
                         ration_gljs[i].subList = mixRatios;
                     }
                     }
+                    if(ration) gljOprObj.getTotalQuantity(ration_gljs[i], ration);
                 }
                 }
             }
             }
         }
         }