|
@@ -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) {
|