fix: approval, approvalExecution snapshot (#1274)
Reviewed-on: https://git.daoyoucloud.com:8443/daoyoucloud/tachybase/pulls/1274 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
a094b9670d
commit
36be34b1bb
@ -73,12 +73,20 @@ export default class ApprovalTrigger extends Trigger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { approvalId, data, summary, collectionName } = execution.context;
|
const { approvalId, data, summary, collectionName } = execution.context;
|
||||||
|
|
||||||
|
// NOTE: 因为这里的原本的 data, 在重新提交后再次重新提交, 丢失了审批人之类的多对多关系数据
|
||||||
|
// 找不到上下文传递数据的来源在哪里, 因此在这里重新取数据.因为存储的是快照, 这样是有其合理性的.
|
||||||
|
const approval = await this.workflow.db.getRepository('approvals').findOne({
|
||||||
|
filterByTk: approvalId,
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
const approvalExecution = await this.workflow.db.getRepository('approvalExecutions').create({
|
const approvalExecution = await this.workflow.db.getRepository('approvalExecutions').create({
|
||||||
values: {
|
values: {
|
||||||
approvalId,
|
approvalId,
|
||||||
executionId: execution.id,
|
executionId: execution.id,
|
||||||
status: execution.status,
|
status: execution.status,
|
||||||
snapshot: data,
|
snapshot: approval?.data || data,
|
||||||
summary,
|
summary,
|
||||||
collectionName,
|
collectionName,
|
||||||
},
|
},
|
||||||
|
@ -107,7 +107,7 @@ const approvals = {
|
|||||||
context.action.mergeParams({
|
context.action.mergeParams({
|
||||||
values: {
|
values: {
|
||||||
status: status ?? APPROVAL_STATUS.SUBMITTED,
|
status: status ?? APPROVAL_STATUS.SUBMITTED,
|
||||||
data: target.toJSON(),
|
data: data,
|
||||||
applicantRoleName: context.state.currentRole,
|
applicantRoleName: context.state.currentRole,
|
||||||
summary,
|
summary,
|
||||||
},
|
},
|
||||||
@ -255,11 +255,10 @@ const approvals = {
|
|||||||
job.set('status', JOB_STATUS.CANCELED);
|
job.set('status', JOB_STATUS.CANCELED);
|
||||||
workflowPlugin.resume(job);
|
workflowPlugin.resume(job);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
await execution.update({
|
|
||||||
status: EXECUTION_STATUS.CANCELED,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
await execution.update({
|
||||||
|
status: EXECUTION_STATUS.CANCELED,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async listCentralized(context, next) {
|
async listCentralized(context, next) {
|
||||||
const centralizedApprovalFlow = await context.db.getRepository('workflows').find({
|
const centralizedApprovalFlow = await context.db.getRepository('workflows').find({
|
||||||
|
Loading…
Reference in New Issue
Block a user