Browse Source

修复bug

laiguoran 3 years ago
parent
commit
d079c848a0
2 changed files with 6 additions and 5 deletions
  1. 2 2
      app/controller/change_controller.js
  2. 4 3
      app/service/change_audit_list.js

+ 2 - 2
app/controller/change_controller.js

@@ -825,9 +825,9 @@ module.exports = app => {
                         break;
                     case 'paste_amount_rows':
                         await ctx.service.changeAuditList.saveDatas(data.updateData);
-                        let changeList = await ctx.service.changeAuditList.getList(ctx.change.cid);
+                        const changeList = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         const auditList2 = await ctx.service.changeAudit.getListGroupByTimes(ctx.change.cid, ctx.change.times);
-                        changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
+                        // changeList = JSON.parse(JSON.stringify(changeList.sort())).sort().sort();
                         for (const cl of changeList) {
                             const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
                             // 清单表页赋值

+ 4 - 3
app/service/change_audit_list.js

@@ -283,6 +283,7 @@ module.exports = app => {
             // 判断t_type是否为费用
             const transaction = await this.db.beginTransaction();
             try {
+                let usedList = [];
                 let order = null;
                 if (order_by) {
                     if (data) {
@@ -294,6 +295,9 @@ module.exports = app => {
                         order = order ? order + 1 : 1;
                     }
                 } else {
+                    const sql1 = 'SELECT a.* FROM ?? as b LEFT JOIN ?? as a ON b.cbid = a.id WHERE b.cid = ? GROUP BY b.cbid';
+                    const sqlParam1 = [this.ctx.service.stageChange.tableName, this.tableName, this.ctx.change.cid];
+                    usedList = await transaction.query(sql1, sqlParam1);
                     // 先删除原本的台账清单数据
                     const sql = 'DELETE FROM ?? WHERE cid = ? and lid != "0"';
                     const sqlParam = [this.tableName, this.ctx.change.cid];
@@ -312,9 +316,6 @@ module.exports = app => {
                 if (insertDatas.length > 0) await transaction.insert(this.tableName, insertDatas);
                 await this.calcCamountSum(transaction);
                 if (!order_by) {
-                    const sql1 = 'SELECT a.* FROM ?? as b LEFT JOIN ?? as a ON b.cbid = a.id WHERE b.cid = ? GROUP BY b.cbid';
-                    const sqlParam1 = [this.ctx.service.stageChange.tableName, this.tableName, this.ctx.change.cid];
-                    const usedList = await transaction.query(sql1, sqlParam1);
                     // 更新stage_change和stage_change_final的cbid
                     if (usedList.length > 0) {
                         const updateList = [];