Browse Source

Merge branch '分摊功能' of http://192.168.1.41:3000/SmartCost/YangHuCost into 分摊功能

zhangweicheng 5 years ago
parent
commit
9f747e3323

+ 14 - 58
web/building_saas/main/js/models/calc_program.js

@@ -1804,60 +1804,7 @@ class CalcProgram {
         }
         }
         // 定额:计算程序
         // 定额:计算程序
         else{
         else{
-            let fnArr = [];
-            calcTools.getGLJList(treeNode, true);
-
-            if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
-                // 量价、工料机类型的定额要求市场合价
-                if (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation){
-                    let muf = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
-                    let mtf = (muf * nQ).toDecimal(decimalObj.ration.totalPrice);
-                    if (treeNode.data.marketTotalFee != mtf){
-                        treeNode.data.marketTotalFee = mtf;
-                        treeNode.changed = true;
-                    } ;
-                };
-            };
-            // 2018-08-27   zhang  插入空定额的时候,取费专业也为空
-           // if (treeNode.data.programID == undefined) treeNode.data.programID = projectObj.project.projectInfo.property.engineering;
-            let template = me.compiledTemplates[treeNode.data.programID];
-            treeNode.data.calcTemplate = template;
-
-            if (treeNode && template && template.hasCompiled) {//2018-08-27 空行的时候,取费专业为空,template也为空,加入template非空判断
-                let $CE = executeObj;
-                $CE.treeNode = treeNode;
-                $CE.template = template;
-
-                calcTools.initFees(treeNode);
-
-                for (let idx of template.compiledSeq) {
-                    let calcItem = template.calcItems[idx];
-                    $CE.tempCalcItem = calcItem;
-                    let feeRate = 100;  // 100%
-                    if (calcItem.feeRate != undefined)
-                        feeRate = parseFloat(calcItem.feeRate).toDecimal(decimalObj.feeRate);
-                    // console.log(`[${calcItem.ID}]: ${calcItem.compiledExpr}`);   // for test.
-                    let tf = (eval(calcItem.compiledExpr) * feeRate * 0.01).toDecimal(decimalObj.process);
-                    calcItem.totalFee = tf.toDecimal(decimalObj.decimal('totalPrice', treeNode));
-                    let nodeQ = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 1;
-                    calcItem.unitFee = (tf / nodeQ).toDecimal(decimalObj.decimal('unitPrice', treeNode));
-
-                    if (tender == tenderTypes.ttCalc) {
-                        let tExpr = analyzer.getCompiledTenderExpr(calcItem.compiledExpr);
-                        calcItem.tenderUnitFee = (eval(tExpr) * feeRate * 0.01).toDecimal(decimalObj.decimal('unitPrice', treeNode));
-                        calcItem.tenderTotalFee = (calcItem.tenderUnitFee * treeNode.data.tenderQuantity).toDecimal(decimalObj.decimal('totalPrice', treeNode));
-                    };
-
-                    if (calcItem.fieldName) {
-                        fnArr.push(calcItem.fieldName);
-                        calcTools.checkFeeField(treeNode, calcItem);
-                    };
-                };
-
-                if (tender == tenderTypes.ttReverseRation || tender == tenderTypes.ttReverseGLJ)
-                    this.calcTenderReverse(treeNode, tender);
-                me.deleteUselessFees(treeNode, fnArr);
-            };
+            me.innerCalcRation(treeNode, tender);
         };
         };
 
 
         // if (!calcTools.isTotalCostBill(treeNode))  // 已在上面的分支中计算过
         // if (!calcTools.isTotalCostBill(treeNode))  // 已在上面的分支中计算过
@@ -1865,14 +1812,23 @@ class CalcProgram {
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);
     };
     };
 
 
-    innerCalcForFTRation(treeNode, tender = tenderTypes.ttCalc){          // 用于分摊定额计算:只有普通定额和量价类。
+    // 定额部分抽取出来,供分摊定额公用。
+    innerCalcRation(treeNode, tender = tenderTypes.ttCalc){
         let me = this;
         let me = this;
         let fnArr = [];
         let fnArr = [];
         calcTools.getGLJList(treeNode, true);
         calcTools.getGLJList(treeNode, true);
 
 
-        // 量价、工料机类型的定额要求市场合价
-        if (treeNode.data.type == rationType.volumePrice){
-            treeNode.data.totalPrice = (treeNode.data.unitPrice * treeNode.data.quantity).toDecimal(decimalObj.ration.totalPrice);
+        if (treeNode.calcType == treeNodeCalcType.ctRationCalcProgram) {
+            // 量价、工料机类型的定额要求"市场合价"
+            if (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation){
+                let u = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
+                let q = calcTools.uiNodeQty(treeNode);
+                let t = (u * q).toDecimal(decimalObj.ration.totalPrice);
+                if (treeNode.data.marketTotalFee != t){
+                    treeNode.data.marketTotalFee = t;
+                    treeNode.changed = true;
+                } ;
+            };
         };
         };
 
 
         let template = me.compiledTemplates[treeNode.data.programID];
         let template = me.compiledTemplates[treeNode.data.programID];

+ 1 - 1
web/building_saas/main/js/views/divide_view.js

@@ -582,7 +582,7 @@ let divideObj = {
                 },
                 },
                 callback: function (key, opt) {  
                 callback: function (key, opt) {  
                   let selected = me.getSelectedItem();
                   let selected = me.getSelectedItem();
-                  projectObj.project.calcProgram.innerCalcForFTRation({data:selected,sourceType:"ration",updateData:[]});
+                  projectObj.project.calcProgram.innerCalcRation({data:selected, sourceType:"ration", calcType: 1, updateData:[]});
                   console.log(selected)
                   console.log(selected)
                 }
                 }
             },
             },