chenshilong 7 lat temu
rodzic
commit
a3e746c52f
1 zmienionych plików z 49 dodań i 26 usunięć
  1. 49 26
      web/building_saas/main/js/models/calc_program.js

+ 49 - 26
web/building_saas/main/js/models/calc_program.js

@@ -642,7 +642,9 @@ let calcTools = {
             quantityEXP: treeNode.data.quantityEXP,
             summaryFees: treeNode.data.summaryFees,
             name:treeNode.data.name,
-            rationQuantityCoe: treeNode.data.rationQuantityCoe
+            rationQuantityCoe: treeNode.data.rationQuantityCoe,
+            targetUnitFee: treeNode.data.targetUnitFee,
+            targetTotalFee: treeNode.data.targetTotalFee
         };
 
         // 定额大类
@@ -665,6 +667,9 @@ let calcTools = {
     uiNodeQty: function (treeNode){
         return parseFloatPlus(treeNode.data.quantity).toDecimal(decimalObj.decimal("quantity", treeNode));
     },
+    uiNodeTenderQty: function (treeNode){
+        return this.calcNodeTenderQty(treeNode);
+    },
     calcNodeTenderQty: function (treeNode){
         let qCoe = (treeNode.data.rationQuantityCoe == undefined) ? 1 : treeNode.data.rationQuantityCoe;
         treeNode.data.tenderQuantity = (this.uiNodeQty(treeNode) * qCoe).toDecimal(decimalObj.decimal("quantity", treeNode));
@@ -1425,6 +1430,8 @@ class CalcProgram {
         if (treeNode.sourceType === ModuleNames.ration_glj) return;
 
         treeNode.calcType = calcTools.getCalcType(treeNode);
+        let nQ = calcTools.uiNodeQty(treeNode);
+        let nTQ = calcTools.uiNodeTenderQty(treeNode);
 
         function isBaseFeeType(type){
             return ['labour', 'material', 'machine', 'mainMaterial', 'equipment'].indexOf(type) > -1;
@@ -1476,7 +1483,8 @@ class CalcProgram {
                 ftObj.fieldName = ft.type;
                 ftObj.name = ft.name;
                 let buf = 0, btf = 0, btuf = 0, bttf = 0;
-                let bq = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 1;
+                let bq = nQ ? nQ : 1;
+                let btq = nTQ ? nTQ : 1;
 
                 if (treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
                     for (let node of nodes) {
@@ -1507,7 +1515,7 @@ class CalcProgram {
                     if (me.project.property.billsCalcMode == leafBillGetFeeType.rationPriceConverse ||
                         me.project.property.billsCalcMode == leafBillGetFeeType.rationPrice) {
                         buf = (sum_rtf / bq).toDecimal(decimalObj.process);
-                        btuf = (sum_rttf / bq).toDecimal(decimalObj.process);
+                        btuf = (sum_rttf / btq).toDecimal(decimalObj.process);
                     };
                     if (isBaseFeeType(ft.type) ||
                         (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice && ft.type == "common")){
@@ -1516,7 +1524,7 @@ class CalcProgram {
                     }
                     else{
                         btf = (buf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
-                        bttf = (btuf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
+                        bttf = (btuf.toDecimal(decimalObj.bills.unitPrice) * btq).toDecimal(decimalObj.process);
                     };
                 };
 
@@ -1546,6 +1554,11 @@ class CalcProgram {
                 treeNode.changed = true;
             }
 
+            if (treeNode.data.tenderCalcBaseValue){
+                treeNode.data.tenderCalcBaseValue = null;
+                treeNode.changed = true;
+            }
+
             if (treeNode.data.programID) {
                 treeNode.data.programID = null;
                 treeNode.changed = true;
@@ -1583,14 +1596,17 @@ class CalcProgram {
 
             let f = treeNode.data.feeRate ? treeNode.data.feeRate : 100;
             let b = treeNode.data.calcBaseValue ? treeNode.data.calcBaseValue : 0;
-            let q = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 1;
+            let tb = treeNode.data.tenderCalcBaseValue ? treeNode.data.tenderCalcBaseValue : 0;
+            let q = nQ ? nQ : 1;
+            let tq = nTQ ? nTQ : 1;
             let uf = (b * f * 0.01 / q).toDecimal(decimalObj.bills.unitPrice);
-            let tuf = uf;
+            let tuf = (tb * f * 0.01 / tq).toDecimal(decimalObj.bills.unitPrice);
             let tf = (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice) ? (b * f / 100) : (uf * q);
             tf = tf.toDecimal(decimalObj.bills.totalPrice);
-            let ttf = tf;
+            let ttf = (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice) ? (tb * f / 100) : (tuf * tq);
+            ttf = ttf.toDecimal(decimalObj.bills.totalPrice);
             deleteUselessFees(treeNode);
-            calcTools.checkFeeField(treeNode, {'fieldName': 'common', 'unitFee': uf, 'totalFee': tf});
+            calcTools.checkFeeField(treeNode, {'fieldName': 'common', 'unitFee': uf, 'totalFee': tf, 'tenderUnitFee': tuf, 'tenderTotalFee': ttf});
 
             // 总造价清单还要做单项工程、建设项目的四大项金额汇总
             if (calcTools.isTotalCostBill(treeNode)){
@@ -1614,8 +1630,7 @@ class CalcProgram {
                 // 量价、工料机类型的定额要求市场合价
                 if (treeNode.data.type == rationType.volumePrice || treeNode.data.type == rationType.gljRation){
                     let muf = treeNode.data.marketUnitFee ? treeNode.data.marketUnitFee : 0;
-                    let q = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 0;
-                    let mtf = (muf * q).toDecimal(decimalObj.ration.totalPrice);
+                    let mtf = (muf * nQ).toDecimal(decimalObj.ration.totalPrice);
                     if (treeNode.data.marketTotalFee != mtf){
                         treeNode.data.marketTotalFee = mtf;
                         treeNode.changed = true;
@@ -1634,7 +1649,6 @@ class CalcProgram {
 
                 calcTools.initFees(treeNode);
 
-                if (tender == tenderTypes.ttCalc) calcTools.calcNodeTenderQty(treeNode);
                 for (let idx of template.compiledSeq) {
                     let calcItem = template.calcItems[idx];
                     $CE.tempCalcItem = calcItem;
@@ -1658,8 +1672,8 @@ class CalcProgram {
                     };
                 };
 
-                if (tender == tenderTypes.ttReverseRation)
-                    this.calcTenderReverse(treeNode);
+                if (tender == tenderTypes.ttReverseRation || tender == tenderTypes.ttReverseGLJ)
+                    this.calcTenderReverse(treeNode, tender);
 
                 deleteUselessFees(treeNode, fnArr);
             };
@@ -1888,7 +1902,7 @@ class CalcProgram {
         return me.getTotalFee(baseNodes, excludeNodes);
     };
 
-    clearTenders(){
+    /*clearTenders(){
         let nodes = projectObj.project.mainTree.items;
         for (let node of nodes) {
             delete node.data.targetTotalFee;
@@ -1901,29 +1915,38 @@ class CalcProgram {
             delete node.data.rationQuantityCoe;
         };
         projectObj.project.property.tenderSetting.gljPriceTenderCoe = 1;
-    };
+    };*/
 
     // 反向调价
-    calcTenderReverse(treeNode){
-        treeNode.data.feesIndex.common.tenderUnitFee = treeNode.data.feesIndex.common.unitFee;
-
-        if (treeNode.data.targetTotalFee){
+    calcTenderReverse(treeNode, tender){
+        if (treeNode.data.feesIndex.common.tenderUnitFee != treeNode.data.feesIndex.common.unitFee){
+            treeNode.data.feesIndex.common.tenderUnitFee = treeNode.data.feesIndex.common.unitFee;
+            treeNode.changed = true;
+        };
 
-        }
-        else{
+        if (!treeNode.data.targetTotalFee){
             if (treeNode.data.targetUnitFee){
-                treeNode.data.targetTotalFee = treeNode.data.targetUnitFee * treeNode.data.quantity;
+                treeNode.data.targetTotalFee = (treeNode.data.targetUnitFee * treeNode.data.quantity).toDecimal(decimalObj.decimal('totalPrice', treeNode));
+                treeNode.changed = true;
             }
             else{
                 return;
             }
         };
 
-        treeNode.data.rationQuantityCoe = treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee;
-        treeNode.data.tenderQuantity = treeNode.data.quantity * treeNode.data.rationQuantityCoe;
-        treeNode.data.feesIndex.common.tenderTotalFee = treeNode.data.tenderQuantity * treeNode.data.feesIndex.common.tenderUnitFee;
+        let coe = (treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee).toDecimal(decimalObj.process);
+        if (treeNode.data.rationQuantityCoe != coe){
+            treeNode.data.rationQuantityCoe = coe;
+            treeNode.changed = true;
+        };
+
+        treeNode.data.tenderQuantity = (treeNode.data.quantity * coe).toDecimal(decimalObj.decimal("quantity", treeNode));
 
-        treeNode.changed = true;
+        let ttf = (treeNode.data.tenderQuantity * treeNode.data.feesIndex.common.tenderUnitFee).toDecimal(decimalObj.decimal('totalPrice', treeNode));
+        if (treeNode.data.feesIndex.common.tenderTotalFee != ttf){
+            treeNode.data.feesIndex.common.tenderTotalFee = ttf;
+            treeNode.changed = true;
+        };
     };
 };