浏览代码

定额暂估价计算

chenshilong 7 年之前
父节点
当前提交
820422ca7f
共有 2 个文件被更改,包括 67 次插入3 次删除
  1. 66 2
      web/building_saas/main/js/models/calc_program.js
  2. 1 1
      web/building_saas/pm/js/pm_main.js

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

@@ -166,7 +166,7 @@ let cpFeeTypes = [
     {type: 'machineDiff', name: '机械价差'},
     {type: 'adjustLabour', name: '调整人工费'},
     {type: 'adjustMachineLabour', name: '调整机上人工费'},
-    {type: 'zangu', name: '暂估'},
+    {type: 'estimate', name: '暂估'},
     {type: 'fee1', name: '甲供材料费'},
     // 模拟用户新增
     {type: 'common', name: '工程造价'}
@@ -774,6 +774,7 @@ class CalcProgram {
         };
 
         function checkFee(treeNode, feeObj){
+            if (!feeObj) return;
             if (feeObj.fieldName == '') return;
 
             if (!treeNode.data.feesIndex[feeObj.fieldName]){
@@ -805,6 +806,66 @@ class CalcProgram {
             return ['labour', 'material', 'machine', 'mainMaterial', 'equipment'].indexOf(type) > -1;
         };
 
+        function estimateFee(treeNode){
+            if (!treeNode.data.gljList) return undefined;
+
+            let eTypes = [
+                gljType.GENERAL_MATERIAL, gljType.MAIN_MATERIAL, gljType.EQUIPMENT,
+                gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO,
+                gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR];
+            let eDetailTypes = [gljType.MAIN_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO];
+
+            let GLJObjs = [];
+            for (let glj of treeNode.data.gljList) {
+                if (eTypes.indexOf(glj.type) >= 0) {
+                    if (glj.isEstimate){
+                        GLJObjs.push({code: glj.code, quantity: glj.quantity, marketPrice: glj.marketPrice});
+                    }
+                    else{   // 组成物
+                        if (eDetailTypes.indexOf(glj.type) >= 0){
+                            let mds = projectObj.project.composition.getCompositionByGLJ(glj);
+                            if (!mds) mds = [];
+                            for (let md of mds){
+                                if (md.isEstimate){
+                                    let isExist = false;
+                                    let mdQ = (parseFloatPlus(glj.quantity) * parseFloatPlus(md.consumption)).toDecimal(decimalObj.process);
+
+                                    for (let obj of GLJObjs){
+                                        if (md.code == obj.code){
+                                            isExist = true;
+                                            obj.quantity = (parseFloatPlus(obj.quantity) + mdQ).toDecimal(decimalObj.process);
+                                            break;
+                                        }
+                                    };
+                                    if (!isExist)
+                                        GLJObjs.push({code: md.code, quantity: mdQ, marketPrice: md.marketPrice});
+                                }
+                            }
+                        }
+                    }
+                };
+            };
+
+            let sumU = 0, sumT = 0, unitFee = 0, totalFee = 0;
+            for (let obj of GLJObjs){
+                sumU = sumU + (parseFloatPlus(obj.quantity) * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
+                sumU = sumU.toDecimal(decimalObj.process);
+
+                let q = (parseFloatPlus(obj.quantity) * parseFloatPlus(treeNode.data.quantity)).toDecimal(decimalObj.process);
+                sumT = sumT + (q * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
+                sumT = sumT.toDecimal(decimalObj.process);
+            };
+            unitFee = sumU.toDecimal(decimalObj.bills.unitPrice);
+            if (projectObj.project.property.zanguCalcMode == zanguCalcType.common){
+                totalFee = (parseFloatPlus(treeNode.data.quantity) * unitFee).toDecimal(decimalObj.bills.totalPrice);
+            }
+            else if (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial){
+                totalFee = sumT.toDecimal(decimalObj.bills.totalPrice);
+            };
+
+            return {'fieldName': 'estimate', 'unitFee': unitFee, 'totalFee': totalFee};
+        };
+
         // 父清单汇总子项(定额或子清单)的费用类别
         if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees ||
             treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
@@ -1003,7 +1064,10 @@ class CalcProgram {
 
                     checkFee(treeNode, calcItem);
                 };
-            }
+            };
+
+            checkFee(treeNode, estimateFee(treeNode));
+
         };
 
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);

+ 1 - 1
web/building_saas/pm/js/pm_main.js

@@ -102,7 +102,7 @@ let ProjTreeSetting = {
                 getText: function (html, node, text) {
                     if(node.data.projType === projectType.tender){
                         // let engineeringCostText = node.data.engineeringCost ? node.data.engineeringCost : 0;
-                        let engineeringCostText = node.data.summaryFees ? node.data.summaryFees.totalFee : 0;
+                        let engineeringCostText = node.data.summaryFees ? parseFloat(node.data.summaryFees.totalFee).toFixed(2) : '0.00';
                         html.push(engineeringCostText);
                     }
                 }