Browse Source

反向调价

chenshilong 7 years ago
parent
commit
bc4685f062

+ 16 - 5
web/building_saas/main/js/models/calc_program.js

@@ -643,6 +643,7 @@ let calcTools = {
             summaryFees: treeNode.data.summaryFees,
             name:treeNode.data.name,
             rationQuantityCoe: treeNode.data.rationQuantityCoe,
+            quantityCoe: treeNode.data.quantityCoe,
             targetUnitFee: treeNode.data.targetUnitFee,
             targetTotalFee: treeNode.data.targetTotalFee
         };
@@ -1935,7 +1936,10 @@ class CalcProgram {
             }
         };
 
-        let coe = (treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee).toDecimal(decimalObj.process);
+        let coe = 1;
+        if (treeNode.data.feesIndex.common.totalFee != 0)
+            coe = (treeNode.data.targetTotalFee / treeNode.data.feesIndex.common.totalFee).toDecimal(decimalObj.process);
+
         if (tender == tenderTypes.ttReverseRation){
             if (treeNode.data.rationQuantityCoe != coe){
                 treeNode.data.rationQuantityCoe = coe;
@@ -1943,10 +1947,17 @@ class CalcProgram {
             };
         }else if (tender == tenderTypes.ttReverseGLJ){
             let coeObj = treeNode.data.quantityCoe;
-            for (let pn in coeObj){
-                coeObj[pn] = coe;
-            }
-            treeNode.changed = true;
+            if (!coeObj){
+                treeNode.data.quantityCoe = {labour: coe, material: coe, machine: coe, main: coe, equipment: coe};
+                treeNode.changed = true;
+            }else{
+                for (let pn in coeObj){
+                    if (coeObj[pn] != coe){
+                        coeObj[pn] = coe;
+                        treeNode.changed = true;
+                    }
+                };
+            };
         };
 
         treeNode.data.tenderQuantity = (treeNode.data.quantity * coe).toDecimal(decimalObj.decimal("quantity", treeNode));

+ 19 - 4
web/building_saas/main/js/views/tender_price_view.js

@@ -173,6 +173,12 @@ let tender_obj={
             }
         }
     },
+    cleanCacheCoes: function (){
+        for(let node of tender_obj.tenderTree.items){
+            if (node.data.rationQuantityCoe) node.data.rationQuantityCoe = null;
+            if (node.data.quantityCoe) node.data.quantityCoe = null;
+        };
+    },
 
     calcOptionsChecking:function (option) {//调整选项检查,返回需要更新的数组
         let datas = [];
@@ -317,6 +323,12 @@ let tender_obj={
             $('#tenderRationQuantity').removeAttr("disabled");
         }
         //gljPriceTenderCoe
+    },
+    doTenderCalc: function(tender){
+        if (tender != tenderTypes.ttCalc)
+            tender_obj.cleanCacheCoes();
+        let callback = function () { tender_obj.showTenderData() };
+        projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll, callback, tender);
     }
 };
 
@@ -378,12 +390,15 @@ $(function () {
     });
 
     $('#tenderPrice').on('click', function () {
-        let callback = function () {tender_obj.showTenderData()};
-        projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll, callback, tenderTypes.ttCalc);
+        tender_obj.doTenderCalc(tenderTypes.ttCalc);
+    });
+
+    $('#tenderGLJQuantity').on('click', function () {
+        tender_obj.doTenderCalc(tenderTypes.ttReverseGLJ);
     });
 
     $('#tenderRationQuantity').on('click', function () {
-        let callback = function () {tender_obj.showTenderData()};
-        projectObj.project.calcProgram.calcAllNodesAndSave(calcAllType.catAll, callback, tenderTypes.ttReverseRation);
+        tender_obj.doTenderCalc(tenderTypes.ttReverseRation);
     });
+
 });