瀏覽代碼

加强汇总表数据处理

Tony Kang 3 年之前
父節點
當前提交
ebe338e33e
共有 1 個文件被更改,包括 10 次插入6 次删除
  1. 10 6
      modules/main/facade/project_facade.js

+ 10 - 6
modules/main/facade/project_facade.js

@@ -349,15 +349,19 @@ function getReportData(nameList, items, prjTypeNames, compilationScopes, decimal
     let totalExp = item.calcBase;
     if (totalExp.indexOf('@') == -1) return;
     if (isProgressiveType && progressiveInterval) { //有累进的要重新计算总金额和技术经济综合指标
+      let hasReplace = false;
       for (let t of datas) {
+        if (totalExp.includes(t.ID)) hasReplace = true; // 强壮性处理:控制提前计算问题(ID在datas中找不到)
         totalExp = totalExp.replace(t.ID, t.billsTtlPrice + "");
       }
-      totalExp = totalExp.replace(/@/g, "");
-      //还有其他符号(如%)
-      totalExp = totalExp.replace(/%/g, " / 100 ");
-      let nTotal = eval(totalExp);
-      item.billsTtlPrice = scMathUtil.roundForObj(nTotal, decimal.bills.totalPrice);
-      item['技术经济综合指标'] = (item.billsTtlAmt && parseFloat(item.billsTtlAmt) !== 0) ? scMathUtil.roundForObj(item.billsTtlPrice / item.billsTtlAmt, 2) : scMathUtil.roundForObj(item.billsTtlPrice, 2);
+      if (hasReplace) {
+        totalExp = totalExp.replace(/@/g, "");
+        //还有其他符号(如%)
+        totalExp = totalExp.replace(/%/g, " / 100 ");
+        let nTotal = eval(totalExp);
+        item.billsTtlPrice = scMathUtil.roundForObj(nTotal, decimal.bills.totalPrice);
+        item['技术经济综合指标'] = (item.billsTtlAmt && parseFloat(item.billsTtlAmt) !== 0) ? scMathUtil.roundForObj(item.billsTtlPrice / item.billsTtlAmt, 2) : scMathUtil.roundForObj(item.billsTtlPrice, 2);
+      }
     }
   }