Browse Source

优化公式结点存储时机。

chenshilong 7 years ago
parent
commit
f97e5746f1
1 changed files with 16 additions and 8 deletions
  1. 16 8
      web/building_saas/main/js/models/calc_program.js

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

@@ -496,6 +496,7 @@ let treeNodeTools = {
             treeNode.data.fees.push(fee);
             treeNode.data.feesIndex[fieldName] = fee;
         };
+        treeNode.changed = true;
     },
 
     getCalcType(treeNode) {
@@ -932,14 +933,21 @@ class CalcProgram {
             let tf = (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice) ? (b * f / 100).toDecimal(decimalObj.bills.totalPrice) : (uf * q).toDecimal(decimalObj.bills.totalPrice);
             let ttf = tf;
 
-            delete treeNode.data.fees;    // 直接删掉再新增,不用一个个费判断更新,效率更高。
-            delete treeNode.data.feesIndex;
-            treeNodeTools.initFeeField(treeNode, 'common');
-            treeNode.data.feesIndex.common.unitFee = uf;
-            treeNode.data.feesIndex.common.totalFee = tf;
-            treeNode.data.feesIndex.common.tenderUnitFee = tuf;
-            treeNode.data.feesIndex.common.tenderTotalFee = ttf;
-            treeNode.changed = true;
+            if (treeNode.data.feesIndex && treeNode.data.feesIndex.common){
+                if (treeNode.data.feesIndex.common.unitFee != uf ||
+                    treeNode.data.feesIndex.common.totalFee != tf ||
+                    treeNode.data.feesIndex.common.tenderUnitFee != tuf ||
+                    treeNode.data.feesIndex.common.tenderTotalFee != ttf ){
+                    delete treeNode.data.fees;    // 直接删掉再新增。从其它计算方式切换到公式计算方式,会多出其它的费(不光是common)所以这里直接删掉,不用一个个费判断更新,效率更高。
+                    delete treeNode.data.feesIndex;
+                    treeNodeTools.initFeeField(treeNode, 'common');
+                    treeNode.data.feesIndex.common.unitFee = uf;
+                    treeNode.data.feesIndex.common.totalFee = tf;
+                    treeNode.data.feesIndex.common.tenderUnitFee = tuf;
+                    treeNode.data.feesIndex.common.tenderTotalFee = ttf;
+                    treeNode.changed = true;
+                }
+            };
             treeNode.data.calcTemplate = {"calcItems": []};
         }
         // 定额或叶子清单自己的计算程序计算