feat: approval, fix draft (#1281)

Reviewed-on: daoyoucloud/tachybase#1281
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
bai.zixv 2024-07-05 19:38:01 +08:00 committed by sealday
parent 7036f3216c
commit 7d121efb95
3 changed files with 16 additions and 14 deletions

View File

@ -136,7 +136,7 @@ export default class ApprovalInstruction extends Instruction {
}); });
const approvalExecution = approval.approvalExecutions.find((item) => item.executionId === processor.execution.id); const approvalExecution = approval.approvalExecutions.find((item) => item.executionId === processor.execution.id);
// NOTE: 属于重新提交的情况时候, 不必进入待办列表, 应该由用户手动提交 // NOTE: 属于重新提交的情况时候, 不必进入待办列表, 应该由用户手动提交
if (approval.status === APPROVAL_STATUS.RESUBMIT) { if ([APPROVAL_STATUS.RESUBMIT, APPROVAL_STATUS.DRAFT].includes(approval.status)) {
return job; return job;
} }
const RecordModel = db.getModel('approvalRecords'); const RecordModel = db.getModel('approvalRecords');

View File

@ -39,7 +39,9 @@ export default class ApprovalTrigger extends Trigger {
transaction, transaction,
}); });
const isChangedStatus = approval.changed('status'); const isChangedStatus = approval.changed('status');
const isAllowStatusList = [APPROVAL_STATUS.SUBMITTED, APPROVAL_STATUS.RESUBMIT].includes(approval.status); const isAllowStatusList = [APPROVAL_STATUS.DRAFT, APPROVAL_STATUS.SUBMITTED, APPROVAL_STATUS.RESUBMIT].includes(
approval.status,
);
if (!workflow || !isChangedStatus || !isAllowStatusList) { if (!workflow || !isChangedStatus || !isAllowStatusList) {
return; return;
} }

View File

@ -262,18 +262,18 @@ const approvals = {
// }); // });
// await Promise.all(promises); // 等待所有的 resume 操作完成 // await Promise.all(promises); // 等待所有的 resume 操作完成
// } // }
if (jobs.length) { // if (jobs.length) {
const waitList = []; // const waitList = [];
jobs.forEach((job) => { // jobs.forEach((job) => {
job.set('status', JOB_STATUS.CANCELED); // job.set('status', JOB_STATUS.CANCELED);
waitList.push(workflowPlugin.resume(job)); // waitList.push(workflowPlugin.resume(job));
}); // });
// await Promise.all(waitList) // // await Promise.all(waitList)
} else { // } else {
await execution.update({ await execution.update({
status: EXECUTION_STATUS.CANCELED, status: EXECUTION_STATUS.CANCELED,
}); });
} // }
/** FIXME: 以上 */ /** FIXME: 以上 */
}, },
async listCentralized(context, next) { async listCentralized(context, next) {