fix: approval, jsonata fix (#1277)

Reviewed-on: daoyoucloud/tachybase#1277
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 13:03:29 +08:00 committed by sealday
parent fbc9ee8e26
commit b02ef1833b
2 changed files with 31 additions and 9 deletions

View File

@ -85,7 +85,7 @@ const approvals = {
/** 以下为,处理子表单子表格等关联字段的更新逻辑 */
const schemaOfForm = await context.db.getRepository('uiSchemas').getJsonSchema(schemaFormId);
const itemsOfSchema = await jsonParse(`**["x-component-props".mode]`, schemaOfForm);
const fieldAssociationName = (itemsOfSchema || [])
const fieldAssociationName = itemsOfSchema
.filter((item) => {
return ['Nester', 'SubTable', 'PopoverNester'].includes(item?.['x-component-props']?.mode);
})
@ -249,16 +249,32 @@ const approvals = {
context.body = approval;
context.status = 202;
await next();
const workflowPlugin = context.app.getPlugin(PluginWorkflow);
const workflowPlugin = context.app.getPlugin(PluginWorkflow) as PluginWorkflow;
/** FIXME: workflowPlugin.resume , await .
* , .
* 问题表现是: 有时候会出现, ,
*/
// if (jobs.length) {
// const promises = jobs.map(async (job) => {
// job.set('status', JOB_STATUS.CANCELED);
// await workflowPlugin.resume(job);
// });
// await Promise.all(promises); // 等待所有的 resume 操作完成
// }
if (jobs.length) {
const waitList = [];
jobs.forEach((job) => {
job.set('status', JOB_STATUS.CANCELED);
workflowPlugin.resume(job);
waitList.push(workflowPlugin.resume(job));
});
// await Promise.all(waitList)
} else {
await execution.update({
status: EXECUTION_STATUS.CANCELED,
});
}
await execution.update({
status: EXECUTION_STATUS.CANCELED,
});
/** FIXME: 以上 */
},
async listCentralized(context, next) {
const centralizedApprovalFlow = await context.db.getRepository('workflows').find({

View File

@ -8,7 +8,13 @@ export function getAssociationName(str) {
return str;
}
export function jsonParse(expression, scope) {
const result = jsonata(expression).evaluate(scope);
return result;
export async function jsonParse(expression, scope): Promise<any[]> {
const result = await jsonata(expression).evaluate(scope);
if (result === null || result === undefined) {
return [];
} else if (Array.isArray(result)) {
return result;
} else {
return [result];
}
}