Kaynağa Gözat

暂估费算法变更。

chenshilong 7 yıl önce
ebeveyn
işleme
55c5b327a7
1 değiştirilmiş dosya ile 56 ekleme ve 41 silme
  1. 56 41
      web/building_saas/main/js/models/calc_program.js

+ 56 - 41
web/building_saas/main/js/models/calc_program.js

@@ -271,60 +271,75 @@ let calcTools = {
         }
         else{
             if (!treeNode.data.gljList) return;
-            let GLJObjs = [];
+            // 单价
             for (let glj of treeNode.data.gljList) {
-                if (allMaterialTypes.indexOf(glj.type) >= 0) {
+                if (!allMaterialTypes.includes(glj.type)) continue;
+                if (glj.isEstimate){
+                    sumU = sumU + (me.uiGLJQty(glj.quantity) * me.uiGLJPrice(glj.marketPrice)).toDecimal(decimalObj.process);
+                    sumU = sumU.toDecimal(decimalObj.process);
+                }
+                else{   // 组成物
+                    if (!compositionTypes.includes(glj.type)) continue;
+                    let mds = projectObj.project.composition.getCompositionByGLJ(glj);
+                    if (!mds) mds = [];
+                    for (let md of mds){
+                        if (!md.isEstimate) continue;
+                        let mdU = (me.uiGLJQty(md.consumption) * me.uiGLJPrice(md.marketPrice)).toDecimal(decimalObj.glj.unitPrice);
+                        sumU = sumU + (mdU * me.uiGLJQty(glj.quantity)).toDecimal(decimalObj.process);
+                        sumU = sumU.toDecimal(decimalObj.process);
+                    }
+                }
+            };
+            sumU = sumU.toDecimal(decimalObj.bills.unitPrice);
+            if (isBase) return sumU;
+
+            // 合价:数量要先累计,然后乘单价,最后汇总
+            let isGatherEstimate = (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial);
+            if (isGatherEstimate){
+                let GLJObjs = [];
+                let rq = me.uiNodeQty(treeNode);
+                for (let glj of treeNode.data.gljList) {
+                    if (!allMaterialTypes.includes(glj.type)) continue;
                     if (glj.isEstimate){
                         GLJObjs.push({code: glj.code, name: glj.name, specs: glj.specs, unit: glj.unit, type: glj.type,
-                            quantity: glj.quantity, marketPrice: glj.marketPrice});
+                            quantity: (rq * glj.quantity).toDecimal(decimalObj.process),
+                            marketPrice: glj.marketPrice});
                     }
                     else{   // 组成物
-                        if (compositionTypes.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 = (me.uiGLJQty(glj.quantity) * me.uiGLJQty(md.consumption)).toDecimal(decimalObj.process);
-
-                                    for (let obj of GLJObjs){
-                                        if (gljOprObj.getIndex(md, gljKeyArray) == gljOprObj.getIndex(obj, gljKeyArray)){
-                                            isExist = true;
-                                            obj.quantity = (me.uiGLJQty(obj.quantity) + mdQ).toDecimal(decimalObj.process);
-                                            break;
-                                        }
-                                    };
-                                    if (!isExist)
-                                        GLJObjs.push({code: md.code, name: md.name, specs: md.specs, unit: md.unit, type: md.type,
-                                            quantity: mdQ, marketPrice: md.marketPrice});
-                                }
+                        if (!compositionTypes.includes(glj.type)) continue;
+                        let mds = projectObj.project.composition.getCompositionByGLJ(glj);
+                        if (!mds) mds = [];
+                        for (let md of mds){
+                            if (md.isEstimate){
+                                let isExist = false;
+                                let mdQ = (rq * me.uiGLJQty(glj.quantity) * me.uiGLJQty(md.consumption)).toDecimal(decimalObj.process);
+
+                                for (let obj of GLJObjs){
+                                    if (gljOprObj.getIndex(md, gljKeyArray) == gljOprObj.getIndex(obj, gljKeyArray)){
+                                        isExist = true;
+                                        obj.quantity = (obj.quantity + mdQ).toDecimal(decimalObj.glj.quantity);
+                                        break;
+                                    }
+                                };
+                                if (!isExist)
+                                    GLJObjs.push({code: md.code, name: md.name, specs: md.specs, unit: md.unit, type: md.type,
+                                        quantity: mdQ, marketPrice: md.marketPrice});
                             }
                         }
                     }
                 };
-            };
-
-            for (let obj of GLJObjs){
-                sumU = sumU + (me.uiGLJQty(obj.quantity) * me.uiGLJPrice(obj.marketPrice)).toDecimal(decimalObj.process);
-                sumU = sumU.toDecimal(decimalObj.process);
 
-                let q = (me.uiGLJQty(obj.quantity) * me.uiNodeQty(treeNode)).toDecimal(decimalObj.glj.quantity);
-                sumT = sumT + (q * me.uiGLJPrice(obj.marketPrice)).toDecimal(decimalObj.process);
-                sumT = sumT.toDecimal(decimalObj.process);
-            };
-            sumU = sumU.toDecimal(decimalObj.bills.unitPrice);
-            if (projectObj.project.property.zanguCalcMode == zanguCalcType.common){
-                sumT = (me.uiNodeQty(treeNode) * sumU).toDecimal(decimalObj.bills.totalPrice);
-            }
-            else if (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial){
+                for (let obj of GLJObjs){
+                    sumT = sumT + (obj.quantity * me.uiGLJPrice(obj.marketPrice)).toDecimal(decimalObj.process);
+                    sumT = sumT.toDecimal(decimalObj.process);
+                };
                 sumT = sumT.toDecimal(decimalObj.bills.totalPrice);
-            };
+            }
+            else
+                sumT = (me.uiNodeQty(treeNode) * sumU).toDecimal(decimalObj.bills.totalPrice);
         };
 
-        if (isBase)
-            return sumU
-        else
-            me.checkFeeField(treeNode, {'fieldName': 'estimate', 'unitFee': sumU, 'totalFee': sumT});
+        me.checkFeeField(treeNode, {'fieldName': 'estimate', 'unitFee': sumU, 'totalFee': sumT});
     },
     marketPriceToBase: function (treeNode, baseName) {
         if (treeNode.data.type != rationType.volumePrice && treeNode.data.type != rationType.gljRation) return;