diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/common/Cn.ApprovalTodos.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/common/Cn.ApprovalTodos.tsx index f1d22c9c5..02df9065d 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/common/Cn.ApprovalTodos.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/common/Cn.ApprovalTodos.tsx @@ -70,7 +70,11 @@ export const CollectionApprovalTodos = { type: 'text', name: 'comment', interface: 'markdown', - uiSchema: { type: 'string', 'x-component': 'Markdown', title: `{{t("Comment", { ns: "${NAMESPACE}" })}}` }, + uiSchema: { + type: 'string', + 'x-component': 'Markdown', + title: `{{t("Comment", { ns: "${NAMESPACE}" })}}`, + }, }, { name: 'createdAt', diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverBlock.view.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverBlock.view.tsx index 14f94772b..cfe151c8f 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverBlock.view.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverBlock.view.tsx @@ -21,13 +21,15 @@ export const ApproverBlock = ({ value: srcID, onChange }) => { const { setFormValueChanged } = useContext(ContextApproverConfig) as any; const onChangeFunc = useCallback( (data) => { - const flatSet = flatSchemaArray( - data.toJSON(), - (field) => field['x-decorator'] === 'ApprovalFormBlockProvider', - ).reduce((accSet, curr) => { - flatSchemaArray(curr, (field) => field['x-component'] === 'Action').forEach((field) => { + const arr = flatSchemaArray(data.toJSON(), (field) => field['x-decorator'] === 'ApprovalFormBlockProvider'); + + const flatSet = arr.reduce((accSet, curr) => { + const currArr = flatSchemaArray(curr, (field) => field['x-component'] === 'Action'); + + for (const field of currArr) { accSet.add(Number.parseInt(field['x-action'], 10)); - }); + } + return accSet; }, new Set()); @@ -57,7 +59,9 @@ export const ApproverBlock = ({ value: srcID, onChange }) => { }; await apiClient.resource('uiSchemas').insert({ values: schema }); + onChange(id); + return schema; }); diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverInterface.schema.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverInterface.schema.tsx index 4c6fe88ac..cda8e9694 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverInterface.schema.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction/approver-interface/ApproverInterface.schema.tsx @@ -26,6 +26,24 @@ const useStyles = createStyles(({ css }) => { }; }); +function getSchema({ styles }) { + return { + name: 'drawer', + type: 'void', + title: `{{t("Approver's interface", { ns: "${NAMESPACE}" })}}`, + 'x-component': 'Action.Drawer', + 'x-component-props': { + className: styles.container, + }, + properties: { + applyDetail: { + type: 'string', + 'x-component': 'ApproverBlock', + }, + }, + }; +} + // 审批人操作界面 export const ApproverInterfaceComponent = () => { const context = useContext(SchemaComponentContext); @@ -64,21 +82,3 @@ export const ApproverInterfaceComponent = () => { ); }; - -function getSchema({ styles }) { - return { - name: 'drawer', - type: 'void', - title: `{{t("Approver's interface", { ns: "${NAMESPACE}" })}}`, - 'x-component': 'Action.Drawer', - 'x-component-props': { - className: styles.container, - }, - properties: { - applyDetail: { - type: 'string', - 'x-component': 'ApproverBlock', - }, - }, - }; -} diff --git a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/ApprovalInstruction.ts b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/ApprovalInstruction.ts index 90f4b60fb..fb5234216 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/ApprovalInstruction.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/ApprovalInstruction.ts @@ -197,8 +197,7 @@ export default class ApprovalInstruction extends Instruction { }, []); const processing = Boolean(distribution.find((item) => item.status !== APPROVAL_ACTION_STATUS.PENDING)); const status = - job.status || - (getNegotiationMode(negotiation).getStatus(distribution, assignees, negotiation) ?? JOB_STATUS.PENDING); + getNegotiationMode(+negotiation).getStatus(distribution, assignees, negotiation) ?? JOB_STATUS.PENDING; const result = ApprovalJobStatusMap[status]; processor.logger.debug(`approval resume job and next status: ${status}`); job.set({ diff --git a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts index de313e6de..5cb5c9cf4 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/server/features/approval/actions.ts @@ -53,6 +53,13 @@ const approvals = { context, }); const instance = values.get(); + const summary = getSummary({ + summaryConfig: workflow.config.summary, + data: { + ...instance, + ...data, + }, + }); Object.keys(model.associations).forEach((key) => { delete instance[key]; }); @@ -63,10 +70,7 @@ const approvals = { dataKey: values[collection.filterTargetKey], workflowKey: workflow.key, applicantRoleName: context.state.currentRole, - summary: getSummary({ - summaryConfig: workflow.config.summary, - data: instance, - }), + summary, }, }); return actions.create(context, next);