Browse Source

修复重新审批总的变更金额bug

laiguoran 5 years atrás
parent
commit
4360720576
2 changed files with 3 additions and 3 deletions
  1. 0 1
      app/controller/change_controller.js
  2. 3 2
      app/service/change.js

+ 0 - 1
app/controller/change_controller.js

@@ -393,7 +393,6 @@ module.exports = app => {
                         stotalCost += cl.samount !== '' && cl.unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
                         const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
                         auditTotalCost.push(audit_amount);
-                        console.log(cl.unit_price, ototalCost, ctotalCost);
                     }
                     renderData.ototalCost = ototalCost;
                     renderData.ctotalCost = ctotalCost;

+ 3 - 2
app/service/change.js

@@ -915,7 +915,7 @@ module.exports = app => {
             let result = false;
             try {
                 const changeInfo = await this.getDataByCondition({ cid });
-                const tenderInfo  = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
+                const tenderInfo = await this.ctx.service.tenderInfo.getTenderInfo(changeInfo.tid);
 
                 // 获取终审
                 const auditInfo = (await this.ctx.service.changeAudit.getAllDataByCondition({ where: { cid }, orders: [['usort', 'desc']], limit: 1, offset: 0 }))[0];
@@ -957,6 +957,7 @@ module.exports = app => {
                 const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
                 for (const cl of changeList) {
                     const audit_amount = cl.audit_amount.split(',');
+                    const last_amount = audit_amount[audit_amount.length - 1];
                     audit_amount.splice(-1, 1);
                     const list_update = {
                         id: cl.id,
@@ -964,7 +965,7 @@ module.exports = app => {
                         samount: '',
                     };
                     total_price = this.ctx.helper.add(total_price,
-                        this.ctx.helper.mul(cl.unit_price, cl.camount, tenderInfo.decimal.tp));
+                        this.ctx.helper.mul(cl.unit_price, parseFloat(last_amount), tenderInfo.decimal.tp));
                     await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
                 }