|
|
@@ -1555,13 +1555,28 @@ module.exports = app => {
|
|
|
async _auditCheckCancelAnd(stage) {
|
|
|
const accountId = this.ctx.session.sessionUser.accountId;
|
|
|
const selfAuditor = stage.flowAuditors.find(x => { return x.aid === accountId; });
|
|
|
- if (!selfAuditor || selfAuditor.status !== auditConst.status.checked) throw '不可撤回';
|
|
|
+ const nextChecked = selfAuditor && selfAuditor.audit_group_order ? stage.flowAuditors.find(x => { return x.audit_group_order > selfAuditor.audit_group_order && x.status === auditConst.status.checked; }) : null;
|
|
|
+ if (!selfAuditor || selfAuditor.status !== auditConst.status.checked || nextChecked) throw '不可撤回';
|
|
|
+ const skipUpdateData = [];
|
|
|
+ if (selfAuditor.audit_group_order) {
|
|
|
+ const preChecked = stage.flowAuditors.filter(x => { return x.audit_group_order < selfAuditor.audit_group_order && x.status === auditConst.status.checked; }).sort((a, b) => { return a.audit_group_order - b.audit_group_order});
|
|
|
+ const minCancelOrder = preChecked.length > 0 ? preChecked[preChecked.length - 1].audit_group_order + 1 : 0;
|
|
|
+ for (const a of stage.flowAuditors) {
|
|
|
+ if (a.status !== auditConst.status.checkSkip) continue;
|
|
|
+ if (a.aid === accountId) continue;
|
|
|
+ if (a.audit_group_order > selfAuditor.audit_group_order || a.audit_group_order < minCancelOrder) continue;
|
|
|
+ skipUpdateData.push({ id: a.id, status: auditConst.status.checking, opinion: '', end_time: null });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
await transaction.update(this.tableName, {
|
|
|
id: selfAuditor.id, status: auditConst.status.checking, opinion: '', end_time: null,
|
|
|
});
|
|
|
+ if (skipUpdateData.length > 0) await transaction.updateRows(this.tableName, skipUpdateData);
|
|
|
+ // 2026-02-09,需求要求仅该撤回情况触发inner_flow
|
|
|
+ await this.ctx.service.specMsg.addStageMsg(transaction, this.ctx.session.sessionProject.id, stage, pushOperate.stage.inner_flow);
|
|
|
await transaction.commit();
|
|
|
} catch(err) {
|
|
|
await transaction.rollback();
|