소스 검색

修复新建一期费用计算式bug

laiguoran 5 년 전
부모
커밋
9959a75fb4
1개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 11 11
      app/lib/material_calc.js

+ 11 - 11
app/lib/material_calc.js

@@ -40,18 +40,18 @@ class MaterialCalculate {
     }
 
     _calculateExpr(expr) {
-        let formula = expr;
-        for (const b of this.bases) {
-            formula = formula.replace(b.reg, b.value);
-        }
-        const percent = formula.match(this.percentReg);
-        if (percent) {
-            for (const p of percent) {
-                const v = math.eval(p.replace('%', '/100'));
-                formula = formula.replace(p, v);
-            }
-        }
         try {
+            let formula = expr;
+            for (const b of this.bases) {
+                formula = formula.replace(b.reg, b.value);
+            }
+            const percent = formula.match(this.percentReg);
+            if (percent) {
+                for (const p of percent) {
+                    const v = math.eval(p.replace('%', '/100'));
+                    formula = formula.replace(p, v);
+                }
+            }
             const value = math.eval(formula);
             return value;
         } catch (err) {