|
@@ -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();
|