Przeglądaj źródła

合同支付审批人,进入标段鉴权

MaiXinRong 6 miesięcy temu
rodzic
commit
a7b6989c9f
2 zmienionych plików z 14 dodań i 10 usunięć
  1. 3 1
      app/middleware/tender_check.js
  2. 11 9
      app/service/settle_audit.js

+ 3 - 1
app/middleware/tender_check.js

@@ -68,6 +68,8 @@ module.exports = options => {
                 .map(x => { return x.ass_user_id; });
             const settleAuditors = yield this.service.settleAudit.getAllAuditors(tender.id);
             const settleAuditorsId = this.helper._.map(settleAuditors, 'audit_id');
+            const phasePayAuditors = yield this.service.phasePayAudit.getAllAuditors(tender.id);
+            const phasePayAuditorsId = this.helper._.map(phasePayAuditors, 'audit_id');
             const changeAuditors = yield this.service.changeAudit.getAllAuditors(tender.id);
             const changeAuditorsId = this.helper._.map(changeAuditors, 'uid');
             const reviseAuditors = yield this.service.reviseAudit.getAllAuditors(tender.id);
@@ -91,7 +93,7 @@ module.exports = options => {
             if (auditorsId.indexOf(accountId) === -1 && tender.data.user_id !== accountId &&
                 (tenderPermission === null || tenderPermission === undefined || tenderPermission.indexOf('2') === -1) &&
                 stageAuditorsId.indexOf(accountId) === -1 && auditAssistsId.indexOf(accountId) === -1 &&
-                settleAuditorsId.indexOf(accountId) === -1 && changeAuditorsId.indexOf(accountId) === -1 &&
+                settleAuditorsId.indexOf(accountId) === -1 && phasePayAuditorsId.indexOf(accountId) === -1 && changeAuditorsId.indexOf(accountId) === -1 &&
                 reviseAuditorsId.indexOf(accountId) === -1 && materialAuditorsId.indexOf(accountId) === -1 &&
                 changeProjectAuditorsId.indexOf(accountId) === -1 && changeProjectXsAuditorsId.indexOf(accountId) === -1 &&
                 changeApplyAuditorsId.indexOf(accountId) === -1 && changePlanAuditorsId.indexOf(accountId) === -1 &&

+ 11 - 9
app/service/settle_audit.js

@@ -66,7 +66,7 @@ module.exports = app => {
             if (auditTimes >= 1) {
                 for (let i = 1; i <= auditTimes; i++) {
                     const auditors = await this.getAuditors(settleId, i);
-                    const group = this.ctx.helper.groupAuditors(auditors);
+                    const group = this.ctx.helper.groupAuditors(auditors, 'active_order');
                     const historyGroup = [];
                     const max_order = group.length > 0 && group[group.length - 1].length > 0 ? group[group.length - 1][0].audit_order : -1;
                     for (const g of group) {
@@ -279,7 +279,7 @@ module.exports = app => {
         }
         // 固定终审-更新
         async updateLastAudit(settle, auditList, lastId) {
-            const lastUser = await this.ctx.service.projectAccount.getDataById(lastId);
+            const lastUser = lastId ? await this.ctx.service.projectAccount.getDataById(lastId) : null;
             const transaction = await this.db.beginTransaction();
             try {
                 // 先判断auditList里的aid是否与lastId相同,相同则删除并重新更新order
@@ -301,13 +301,15 @@ module.exports = app => {
                     }
                 }
                 // 添加终审
-                const newAuditor = {
-                    tid: settle.tid, settle_id: settle.id, audit_id: lastId,
-                    name: lastUser.name, company: lastUser.company, role: lastUser.role, mobile: lastUser.mobile,
-                    audit_times: settle.audit_times, active_order: auditOrder, audit_status: auditConst.settle.status.uncheck,
-                    audit_type: auditType.key.common, audit_order: auditOrder,
-                };
-                await transaction.insert(this.tableName, newAuditor);
+                if (lastUser) {
+                    const newAuditor = {ttle_id: settle.id, audit_id: lastId,
+                        name: lastUser.name, company: lastUser.company, role: lastUser.role, mobile: lastUser.mobile,
+                        audit_times: settle.audit_times, active_order: auditOrder, audit_status: auditConst.settle.status.uncheck,
+                        audit_type: auditType.key.common, audit_order: auditOrder,
+                    };
+                    await transaction.insert(this.tableName, newAuditor);
+                }
+                tid: settle.tid, se
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();