ソースを参照

修复3种变更退回原报审批列表bug

ellisran 1 年間 前
コミット
052f2c4ab6

+ 14 - 4
app/service/change_apply_audit.js

@@ -470,15 +470,25 @@ module.exports = app => {
             if (!audit) {
                 throw '审核数据错误';
             }
-            const sql = 'SELECT `tid`, `caid`, `aid`, `order` FROM ?? WHERE `caid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
-            const sqlParam = [this.tableName, caId, times];
-            const auditors = await this.db.query(sql, sqlParam);
+            // const sql = 'SELECT `tid`, `caid`, `aid`, `order` FROM ?? WHERE `caid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
+            // const sqlParam = [this.tableName, caId, times];
+            // const auditors = await this.db.query(sql, sqlParam);
+            const auditors = await this.getAuditGroupByList(caId, times);
             let order = 1;
+            const newAuditors = [];
             for (const a of auditors) {
                 a.times = times + 1;
                 a.order = order;
                 a.status = auditConst.status.uncheck;
                 order++;
+                newAuditors.push({
+                    tid: a.tid,
+                    caid: caId,
+                    times: a.times,
+                    order: a.order,
+                    status: a.status,
+                    aid: a.aid,
+                });
             }
             const transaction = await this.db.beginTransaction();
             try {
@@ -496,7 +506,7 @@ module.exports = app => {
                     times: times + 1,
                 });
                 // 拷贝新一次审核流程列表
-                await transaction.insert(this.tableName, auditors);
+                await transaction.insert(this.tableName, newAuditors);
                 // 微信模板通知
                 // const begin_audit = await this.getDataByCondition({
                 //     mid: materialId,

+ 14 - 4
app/service/change_plan_audit.js

@@ -483,15 +483,25 @@ module.exports = app => {
             if (!audit) {
                 throw '审核数据错误';
             }
-            const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
-            const sqlParam = [this.tableName, cpId, times];
-            const auditors = await this.db.query(sql, sqlParam);
+            // const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
+            // const sqlParam = [this.tableName, cpId, times];
+            // const auditors = await this.db.query(sql, sqlParam);
+            const auditors = await this.getAuditGroupByList(cpId, times);
             let order = 1;
+            const newAuditors = [];
             for (const a of auditors) {
                 a.times = times + 1;
                 a.order = order;
                 a.status = auditConst.status.uncheck;
                 order++;
+                newAuditors.push({
+                    tid: a.tid,
+                    cpid: cpId,
+                    times: a.times,
+                    order: a.order,
+                    status: a.status,
+                    aid: a.aid,
+                });
             }
             const transaction = await this.db.beginTransaction();
             try {
@@ -509,7 +519,7 @@ module.exports = app => {
                     times: times + 1,
                 });
                 // 拷贝新一次审核流程列表
-                await transaction.insert(this.tableName, auditors);
+                await transaction.insert(this.tableName, newAuditors);
                 // 清单审批值删除并重算变更金额
                 await this.ctx.service.changePlanList.delAuditAmount(transaction, cpId);
                 // 微信模板通知

+ 16 - 5
app/service/change_project_audit.js

@@ -73,7 +73,7 @@ module.exports = app => {
          * @return {Promise<*>}
          */
         async getAuditGroupByList(changeId, times) {
-            const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
+            const sql = 'SELECT pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`cpid`, la.`aid`, la.`order` ' +
                 '  FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
                 '  WHERE la.`cpid` = ? and la.`times` = ? and la.`status` != ? and la.`status` != ? GROUP BY la.`aid` ORDER BY la.`order`';
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, changeId, times, auditConst.status.revise, auditConst.status.cancelRevise];
@@ -472,15 +472,26 @@ module.exports = app => {
             if (!audit) {
                 throw '审核数据错误';
             }
-            const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC';
-            const sqlParam = [this.tableName, cpId, times];
-            const auditors = await this.db.query(sql, sqlParam);
+            // 需要剔除原报可能存在修订进入流程的情况
+            // const sql = 'SELECT `tid`, `cpid`, `aid`, `order` FROM ?? WHERE `cpid` = ? and `times` = ? and `status` != ? AND `status` != ? GROUP BY `aid` ORDER BY `id` ASC';
+            // const sqlParam = [this.tableName, cpId, times];
+            // const auditors = await this.db.query(sql, sqlParam);
+            const auditors = await this.getAuditGroupByList(cpId, times);
             let order = 1;
+            const newAuditors = [];
             for (const a of auditors) {
                 a.times = times + 1;
                 a.order = order;
                 a.status = auditConst.status.uncheck;
                 order++;
+                newAuditors.push({
+                    tid: a.tid,
+                    cpid: cpId,
+                    times: a.times,
+                    order: a.order,
+                    status: a.status,
+                    aid: a.aid,
+                });
             }
             const transaction = await this.db.beginTransaction();
             try {
@@ -498,7 +509,7 @@ module.exports = app => {
                     times: times + 1,
                 });
                 // 拷贝新一次审核流程列表
-                await transaction.insert(this.tableName, auditors);
+                await transaction.insert(this.tableName, newAuditors);
                 // 微信模板通知
                 const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), this.ctx.change.uid));
                 const wechatData = {