From 1797292dbc46751710f35acf84d32e7a6ceee2e6 Mon Sep 17 00:00:00 2001 From: "bai.zixv" Date: Fri, 26 Jul 2024 14:30:48 +0800 Subject: [PATCH] feat(approval): hidden updateForm when approvaled (#1397) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1397 Reviewed-by: sealday Co-authored-by: bai.zixv Co-committed-by: bai.zixv --- .../instruction-approval/forms/FormBlock.factory.tsx | 4 ++++ .../todos/ApprovalUpdateForm.provider.tsx | 11 +++++++++++ .../todos/VC.ViewActionTodosContent.tsx | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/ApprovalUpdateForm.provider.tsx diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction-approval/forms/FormBlock.factory.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction-approval/forms/FormBlock.factory.tsx index 0a9b6b020..bb34e6aa4 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction-approval/forms/FormBlock.factory.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/configuration/instruction-approval/forms/FormBlock.factory.tsx @@ -43,6 +43,10 @@ function InternalFormBlockInitializer({ schema, ...others }) { marginTop: '1.5em', flexWrap: 'wrap', }; + + // NOTE: 给表单区域添加 Provider, 方便根据不同进程,控制显示隐藏; ProviderApprovalUpdateForm 在 usage 文件夹里声明和注册 + result.properties[formKey].properties['grid']['x-decorator'] = 'ProviderApprovalUpdateForm'; + traverseSchema(result, (node) => { if (node['x-uid']) { delete node['x-uid']; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/ApprovalUpdateForm.provider.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/ApprovalUpdateForm.provider.tsx new file mode 100644 index 000000000..068628107 --- /dev/null +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/ApprovalUpdateForm.provider.tsx @@ -0,0 +1,11 @@ +import { APPROVAL_ACTION_STATUS } from '../../../constants'; +import { useContextApprovalExecutions } from './Pd.ApprovalExecutions'; + +export const ProviderApprovalUpdateForm = (props) => { + const { status } = useContextApprovalExecutions(); + if (status === APPROVAL_ACTION_STATUS.PENDING) { + return props.children; + } else { + return null; + } +}; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/VC.ViewActionTodosContent.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/VC.ViewActionTodosContent.tsx index b1d091032..301186bdc 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/VC.ViewActionTodosContent.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/todos/VC.ViewActionTodosContent.tsx @@ -19,6 +19,7 @@ import { ApprovalContext } from '../../approval-common/ApprovalData.provider'; import { ContextWithActionEnabled } from '../../approval-common/WithActionEnabled.provider'; import { ContextApprovalExecution } from '../common/ApprovalExecution.provider'; import { SchemaComponentContextProvider } from '../common/SchemaComponent.provider'; +import { ProviderApprovalUpdateForm } from './ApprovalUpdateForm.provider'; import { ApprovalFormBlockDecorator } from './Dt.ApprovalFormBlock'; import { useApprovalDetailBlockProps } from './hooks/useApprovalDetailBlockProps'; import { useApprovalFormBlockProps } from './hooks/useApprovalFormBlockProps'; @@ -98,6 +99,7 @@ export const ViewActionTodosContent = () => { ApprovalActionProvider, ApprovalFormBlockProvider: ApprovalFormBlockDecorator, DetailsBlockProvider, + ProviderApprovalUpdateForm, }} scope={{ useApprovalDetailBlockProps,