From 765ad45224ba9ac617801ba892c0bd2d5fc458dd Mon Sep 17 00:00:00 2001 From: Junyi Date: Tue, 6 Aug 2024 11:03:04 +0800 Subject: [PATCH] fix(plugin-workflow-manual): fix assign field value for all action buttons of manual node (#4983) --- .../plugin-workflow-manual/src/client/WorkflowTodo.tsx | 9 ++++++++- .../src/client/instruction/SchemaConfig.tsx | 3 ++- .../src/client/instruction/forms/update.tsx | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx index aeffb9297e..02609fd8a7 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/WorkflowTodo.tsx @@ -451,23 +451,30 @@ function useSubmit() { const api = useAPIClient(); const { setVisible } = useActionContext(); const { values, submit } = useForm(); + const field = useField(); const buttonSchema = useFieldSchema(); const { service } = useTableBlockContext(); const { userJob, execution } = useFlowContext(); const { name: actionKey } = buttonSchema; const { name: formKey } = buttonSchema.parent.parent; + const { assignedValues = {} } = buttonSchema?.['x-action-settings'] ?? {}; return { async run() { if (execution.status || userJob.status) { return; } await submit(); + field.data = field.data || {}; + field.data.loading = true; + await api.resource('users_jobs').submit({ filterByTk: userJob.id, values: { - result: { [formKey]: values, _: actionKey }, + result: { [formKey]: { ...values, ...assignedValues.values }, _: actionKey }, }, }); + + field.data.loading = false; setVisible(false); service.refresh(); }, diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/SchemaConfig.tsx b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/SchemaConfig.tsx index 5f049a3367..c882fd804d 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/SchemaConfig.tsx +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/SchemaConfig.tsx @@ -39,6 +39,7 @@ import { useSchemaInitializer, useSchemaInitializerItem, useSchemaOptionsContext, + useVariableScope, } from '@nocobase/client'; import WorkflowPlugin, { DetailsBlockProvider, @@ -358,7 +359,7 @@ function ActionInitializer() { ...actionProps, useAction: '{{ useSubmit }}', }, - 'x-designer': 'Action.Designer', + 'x-designer': 'ManualActionDesigner', 'x-action': `${action}`, }} type="x-action" diff --git a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/update.tsx b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/update.tsx index 48e6b5b2e9..d7cfe7996a 100644 --- a/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/update.tsx +++ b/packages/plugins/@nocobase/plugin-workflow-manual/src/client/instruction/forms/update.tsx @@ -70,6 +70,7 @@ function UpdateFormDesigner() { }); dn.refresh(); }} + width="60%" />