From c31608b8cbda32e7f1451e6f5ab916fe2945a17b Mon Sep 17 00:00:00 2001 From: wjh Date: Wed, 12 Jun 2024 20:49:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E5=AE=A1=E6=89=B9=E6=9F=A5=E7=9C=8B=E4=BA=BA=E5=90=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BAundefined=EF=BC=8C=E6=8A=84=E9=80=81=E4=BA=BA?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=90=8D=E5=AD=97=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=20(#1164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1164 Reviewed-by: sealday Co-authored-by: wjh Co-committed-by: wjh --- .../approval/todos/component/TabApprovalItem.tsx | 9 ++++++--- .../component/ViewTodosWorkflowNoticeContent.tsx | 3 ++- .../approval/todos/hook/useFormBlockProps.tsx | 13 +++++++++++++ .../schema/components/antd-mobile/Input/Input.tsx | 4 ++-- .../components/antd-mobile/Select/AntdSelect.tsx | 4 ++-- .../schema/components/antd-mobile/Select/Select.tsx | 5 +++-- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalItem.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalItem.tsx index db099c748..990bb78cd 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalItem.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabApprovalItem.tsx @@ -24,7 +24,8 @@ export const TabApprovalItem = observer((props) => { } else if (collectionName === 'users_jobs') { changeUsersJobsService(api, t, cm, compile, input, setData, params?.[tabKey], filter); } else if (collectionName === 'workflowNotice') { - changeWorkflowNoticeService(api, t, cm, compile, input, setData, params?.[tabKey], filter); + const user = await api.request({ url: 'users:list', params: { pageSize: 99999 } }); + changeWorkflowNoticeService(api, t, cm, compile, input, setData, params?.[tabKey], filter, user?.data?.data); } }, [filter, params, input]); @@ -95,6 +96,7 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa const statusType = approvalTodoListStatus(item, t); const categoryTitle = item.workflow.title.replace('审批流:', ''); const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName; + const summary = Object.entries(item.summary)?.map(([key, value]) => { const field = cm.getCollectionField(`${collectionName}.${key}`); return { @@ -167,7 +169,7 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil }); }; -export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter) => { +export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter, user) => { api .request({ url: 'workflowNotice:listCentralized', @@ -205,9 +207,10 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, value: (Object.prototype.toString.call(value) === '[object Object]' ? value?.['name'] : value) || '', }; }); + const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname; return { ...item, - title: `${item.user?.nickname}的${categoryTitle}`, + title: `${nickName}的${categoryTitle}`, categoryTitle: categoryTitle, statusTitle: t(statusType.label), statusColor: statusType.color, diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/ViewTodosWorkflowNoticeContent.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/ViewTodosWorkflowNoticeContent.tsx index 1c6e8ab24..0a7121c32 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/ViewTodosWorkflowNoticeContent.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/ViewTodosWorkflowNoticeContent.tsx @@ -24,6 +24,7 @@ import { MobileProvider } from '@tachybase/plugin-mobile-client/client'; import { observer } from '@tachybase/schema'; import { ContextApprovalExecution } from '../../context/ApprovalExecution'; +import { useWorkflowNoticeFormBlockProps } from '../hook/useFormBlockProps'; import { usePropsNoticeDetail } from '../hook/usePropsNoticeDetail'; // 审批-抄送-查看: 内容 @@ -93,7 +94,7 @@ export const ViewTodosWorkflowNoticeContent = observer((props) => { }} scope={{ usePropsNoticeDetail, - useDetailsBlockProps: useFormBlockContext, + useDetailsBlockProps: useWorkflowNoticeFormBlockProps, }} schema={{ type: 'void', diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx index f598ef44f..5938142a3 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useFormBlockProps.tsx @@ -52,3 +52,16 @@ export function useUserJobsFormBlockProps() { return { form }; } + +export const useWorkflowNoticeFormBlockProps = () => { + const ctx = useFormBlockContext(); + const { snapshot } = useContextApprovalExecution(); + useEffect(() => { + if (!ctx?.service?.loading) { + ctx.form?.setInitialValues(snapshot); + } + }, [snapshot]); + return { + form: ctx.form, + }; +}; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Input/Input.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Input/Input.tsx index 17627ca3e..78a28d551 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Input/Input.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Input/Input.tsx @@ -10,7 +10,7 @@ type ComposedInput = ((props: InputProps) => React.ReactNode) & { export const MInput: ComposedInput = connect( Input, mapProps((props) => { - return { placeholder: '请输入内容', clearable: true, ...props, style: { '--font-size': '12px' } }; + return { placeholder: '请输入内容', clearable: true, ...props, style: { '--font-size': '12px', ...props?.style } }; }), mapReadPretty((props) => { return {props.value}; @@ -20,7 +20,7 @@ export const MInput: ComposedInput = connect( const MTextArea = connect( TextArea, mapProps((props) => { - return { ...props, placeholder: '请输入内容', clearable: true, style: { '--font-size': '12px' } }; + return { ...props, placeholder: '请输入内容', clearable: true, style: { '--font-size': '12px', ...props?.style } }; }), mapReadPretty((props) => { return
{props.value}
; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/AntdSelect.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/AntdSelect.tsx index 44ebfde15..ebf99c17a 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/AntdSelect.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/AntdSelect.tsx @@ -43,7 +43,7 @@ export const AntdSelect = observer((props) => { let inputValue = ''; if (isArray(value)) { value.forEach((item, index) => { - inputValue += `${item.label}${value.length - 1 === index ? '' : ','}`; + inputValue += `${item[fieldNamesLabel]}${value.length - 1 === index ? '' : ', '}`; }); } else if (value && typeof value === 'object') { inputValue = value[fieldNamesLabel]; @@ -133,7 +133,7 @@ export const AntdSelect = observer((props) => { style={{ color: '#c5c5c5' }} > {value?.length || (value && !isArray(value)) ? ( - + ) : ( {fieldSchema['x-disabled'] ? '' : '请选择内容'} )} diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx index fc18ea6bc..ee94cfc0f 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx @@ -57,8 +57,9 @@ export const MSelect = connect( } else { let redValue = ''; if (isArray(value)) { - redValue = value.reduce((prev, curr) => { - return prev + curr?.[fieldNamesLabel]; + redValue = value.reduce((prev, curr, index) => { + const currContext = value.length - 1 === index ? '' : ', '; + return prev + curr?.[fieldNamesLabel] + currContext; }, ''); } else { redValue = value?.[fieldNamesLabel] || '';