From 1ff8bc8157b30ed68e83e0aff4697e8fad8194ab Mon Sep 17 00:00:00 2001 From: wjh Date: Fri, 31 May 2024 15:42:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=AF=B9=E5=BA=94=E9=A2=9C=E8=89=B2=EF=BC=8C?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E9=A1=B5=E9=9D=A2=E6=B2=A1=E6=9C=89=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=AD=A3=E7=A1=AE=E7=9A=84=E5=88=9B=E5=BB=BA=E4=BA=BA?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20(#1090)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1090 Reviewed-by: sealday Co-authored-by: wjh Co-committed-by: wjh --- .../todos/component/TabApprovalItem.tsx | 10 ++++------ .../src/client/core/schema/CustomColor.tsx | 17 +++++++++++++++++ .../{components/form => }/CustomComponent.tsx | 0 .../antd-mobile/Checkbox/Checkbox.tsx | 4 +++- .../components/antd-mobile/Radio/Radio.tsx | 14 +++++++++----- .../collection-field/CollectionField.tsx | 2 +- .../form/MobileFormItemInitializers.tsx | 2 +- .../src/client/core/schema/index.ts | 2 ++ 8 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomColor.tsx rename packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/{components/form => }/CustomComponent.tsx (100%) 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 1ee6211ee..ae00d1a23 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 @@ -19,9 +19,8 @@ export const TabApprovalItem = observer((props) => { const navigate = useNavigate(); const cm = useCollectionManager(); useAsyncEffect(async () => { - const { data: user } = await api.request({ url: 'users:list', params: { pageSize: 999, appends: ['roles'] } }); if (collectionName === 'approvalRecords') { - changeApprovalRecordsService(api, params?.[tabKey], filter, user, cm, compile, t, setData, input); + changeApprovalRecordsService(api, params?.[tabKey], filter, cm, compile, t, setData, input); } else if (collectionName === 'users_jobs') { changeUsersJobsService(api, t, cm, compile, input, setData, params?.[tabKey], filter); } @@ -83,19 +82,18 @@ const approvalTodoListStatus = (item, t) => { } }; -const changeApprovalRecordsService = (api, params, filter, user, cm, compile, t, setData, input) => { +const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setData, input) => { api .request({ url: 'approvalRecords:listCentralized', params: { pageSize: 9999, - appends: ['execution', 'job', 'node', 'workflow'], + appends: ['execution', 'job', 'node', 'workflow', 'user'], filter: { ...params, ...filter }, }, }) .then((res) => { const result = res.data?.data.map((item) => { - const itemUser = user.data.find((value) => value.id === item.userId); const priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.snapshot.priority); const statusType = approvalTodoListStatus(item, t); const categoryTitle = item.workflow.title.replace('审批流:', ''); @@ -109,7 +107,7 @@ const changeApprovalRecordsService = (api, params, filter, user, cm, compile, t, }); return { ...item, - title: `${itemUser.nickname}的${categoryTitle}`, + title: `${item.snapshot.createdBy.nickname}的${categoryTitle}`, categoryTitle: categoryTitle, statusTitle: t(statusType.label), statusColor: statusType.color, diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomColor.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomColor.tsx new file mode 100644 index 000000000..6d7acf1bc --- /dev/null +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomColor.tsx @@ -0,0 +1,17 @@ +const customColor = { + red: '#fc9792', + magenta: '#ffa3cc', + volcano: '#ffb38b', + orange: '#ffcf86', + gold: '#ffe184', + lime: '#e7ff84', + + green: '#aee884', + cyan: '#7ce5d9', + blue: '#86c3ff', + geekblue: '#a3bfff', + purple: '#cda3f6', + default: '#d4d4d4', +}; + +export const getMobileColor = (color: string) => customColor[color]; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/CustomComponent.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomComponent.tsx similarity index 100% rename from packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/CustomComponent.tsx rename to packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/CustomComponent.tsx diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx index f1408d872..f202b9238 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Checkbox/Checkbox.tsx @@ -4,6 +4,8 @@ import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/ import { Checkbox, CheckboxGroupProps, CheckboxProps, Tag } from 'antd-mobile'; +import { getMobileColor } from '../../../CustomColor'; + type ComposedCheckBox = React.FC & { Group?: any; }; @@ -59,7 +61,7 @@ MCheckbox.Group = connect( {dataSource .filter((option) => option.value == value) .map((option, key) => ( - + {option.label} ))} diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx index bb3201f47..1078ad31c 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Radio/Radio.tsx @@ -4,6 +4,8 @@ import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/ import { Radio, RadioGroupProps, RadioProps, Tag } from 'antd-mobile'; +import { getMobileColor } from '../../../CustomColor'; + type ComposedRadio = React.FC & { Group?: any; }; @@ -55,11 +57,13 @@ MRadio.Group = connect(
{dataSource .filter((option) => option.value == value) - .map((option, key) => ( - - {option.label} - - ))} + .map((option, key) => { + return ( + + {option.label} + + ); + })}
); }), diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/collection-field/CollectionField.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/collection-field/CollectionField.tsx index 739055226..c4c7f47c9 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/collection-field/CollectionField.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/collection-field/CollectionField.tsx @@ -11,8 +11,8 @@ import { connect, Field, merge, useField, useFieldSchema } from '@tachybase/sche import { concat } from 'lodash'; +import { canMobileField } from '../../CustomComponent'; import { useIsMobile } from '../../hooks'; -import { canMobileField } from '../form/CustomComponent'; type Props = { component: any; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx index 4be7e2dc9..2c646b3c8 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/form/MobileFormItemInitializers.tsx @@ -11,8 +11,8 @@ import { } from '@tachybase/client'; import { Schema, useForm } from '@tachybase/schema'; +import { canMobileField } from '../../CustomComponent'; import { useIsMobile } from '../../hooks'; -import { canMobileField } from './CustomComponent'; export const useFormItemInitializerFields = (options?: any) => { const { name, currentFields } = useCollection_deprecated(); diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/index.ts b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/index.ts index a4a9472ee..44e6478f8 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/index.ts +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/index.ts @@ -3,3 +3,5 @@ export * from './components'; export * from './scopes'; export * from './hooks'; export * from './provider'; +export * from './CustomColor'; +export * from './CustomComponent';