Jelajahi Sumber

小数位设置调整自定义值

laiguoran 3 tahun lalu
induk
melakukan
29620b6fa6
1 mengubah file dengan 9 tambahan dan 0 penghapusan
  1. 9 0
      app/service/material.js

+ 9 - 0
app/service/material.js

@@ -380,11 +380,20 @@ module.exports = app => {
                 this.ctx.material.decimal.up = newUp;
                 this.ctx.material.decimal.tp = newTp;
                 const m_tp = await this.ctx.service.materialBills.calcMaterialMTp(transaction);
+                let update_calc = false;
+                if (this.ctx.material.ex_calc) {
+                    const ex_calc = JSON.parse(this.ctx.material.ex_calc);
+                    const zdy = this._.find(ex_calc, { code: 'zdy' });
+                    zdy.value = this.ctx.helper.round(zdy.value, newTp);
+                    this.ctx.material.ex_calc = JSON.stringify(ex_calc);
+                    update_calc = true;
+                }
                 const [ex_tp, ex_expr] = await this.ctx.service.materialExponent.calcMaterialExTp(transaction);
                 const updateData = {
                     id: this.ctx.material.id,
                     decimal: JSON.stringify(this.ctx.material.decimal),
                 };
+                if (update_calc) updateData.ex_calc = this.ctx.material.ex_calc;
                 await transaction.update(this.tableName, updateData);
                 await transaction.commit();
                 return true;