|
@@ -17,7 +17,7 @@ function getStageId() {
|
|
|
}
|
|
|
|
|
|
class PayCalculate {
|
|
|
- constructor (bases) {
|
|
|
+ constructor (bases, decimal) {
|
|
|
this.bases = _.sortBy(bases, function (a, b) {
|
|
|
if (a && b) {
|
|
|
return b.code.indexOf(a.code) === -1 ? 1 : -1;
|
|
@@ -29,6 +29,7 @@ class PayCalculate {
|
|
|
b.reg = new RegExp(b.code, 'igm');
|
|
|
}
|
|
|
this.percentReg = /[0-9]+%/g;
|
|
|
+ this.decimal = decimal.pay ? decimal.payTp : decimal.tp;
|
|
|
}
|
|
|
|
|
|
calculateExpr(expr) {
|
|
@@ -49,10 +50,10 @@ class PayCalculate {
|
|
|
calculateStartRangePrice (pays) {
|
|
|
for (const p of pays) {
|
|
|
if (!p.sprice && p.sexpr && p.sexpr !== '') {
|
|
|
- p.sprice = this.calculateExpr(p.sexpr);
|
|
|
+ p.sprice = _.round(this.calculateExpr(p.sexpr), this.decimal);
|
|
|
}
|
|
|
if (!p.rprice && p.rexpr && p.rexpr !== '') {
|
|
|
- p.rprice = this.calculateExpr(p.rexpr);
|
|
|
+ p.rprice = _.round(this.calculateExpr(p.rexpr), this.decimal);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -61,17 +62,17 @@ class PayCalculate {
|
|
|
for (const p of pays) {
|
|
|
if (p.ptype === 1 || p.ptype === 4) {
|
|
|
if (p.expr && p.expr !== '') {
|
|
|
- p.tp = this.calculateExpr(p.expr);
|
|
|
+ p.tp = _.round(this.calculateExpr(p.expr), this.decimal);
|
|
|
}
|
|
|
}
|
|
|
- p.end_tp = _.add(p.tp, p.pre_tp);
|
|
|
+ p.end_tp = _.round(_.add(p.tp, p.pre_tp), this.decimal);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
autoFlashHeight();
|
|
|
- const calcualtor = new PayCalculate(calcBase);
|
|
|
+ const calcualtor = new PayCalculate(calcBase, decimal);
|
|
|
calcualtor.calculateStartRangePrice(dealPay);
|
|
|
calcualtor.calculate(dealPay);
|
|
|
|