From 9ec524171d1ce7ce0ca525f1a2a873d1ad07068d Mon Sep 17 00:00:00 2001 From: wjh Date: Wed, 9 Oct 2024 15:42:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=A1=E6=89=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E5=A4=8D=E5=88=B6=E5=90=8E=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=BF=98=E6=98=AF=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E6=9C=9F&=E5=AE=A1=E6=89=B9=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E5=A7=8B=E7=BB=88=E5=B0=86=E5=88=9B=E5=BB=BA=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E6=8E=92=E5=9C=A8=E7=AC=AC=E4=B8=80=E4=B8=AA(?= =?UTF-8?q?=E5=8F=96=E5=AE=A1=E6=89=B9=E7=9A=84=E5=88=9B=E5=BB=BA=E6=97=A5?= =?UTF-8?q?=E6=9C=9F)=20(#1581)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1581 Co-authored-by: wjh Co-committed-by: wjh --- .../initiations/component/ApprovalItem.tsx | 22 +++++++--- .../initiations/hook/useCreateSubmit.tsx | 3 +- .../todos/component/TabApprovalItem.tsx | 43 +++++++++++++------ .../apply-button/hooks/useSubmitCreate.tsx | 3 +- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx index 41e389a98..37e984d53 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/component/ApprovalItem.tsx @@ -95,18 +95,26 @@ const changService = (api, setData, user, filter, t, setDefaultData, cm, compile const statusType = approvalTodoListStatus(item, t); const categoryTitle = item.workflow.title; const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName; - const summary = Object.entries(item.summary)?.map(([key, value]) => { + const summary = []; + Object.entries(item.summary)?.forEach(([key, value]) => { const field = cm.getCollectionField(`${collectionName}.${key}`); let resonValue = value; if (field.type === 'date' && value) { resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); } - - return { - label: compile(field?.uiSchema?.title || key), - value: - (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', - }; + if (key === 'createdAt') { + summary.unshift({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } else { + summary.push({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } }); return { ...item, diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useCreateSubmit.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useCreateSubmit.tsx index 3ad12cb89..b51924f79 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useCreateSubmit.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/initiations/hook/useCreateSubmit.tsx @@ -27,7 +27,8 @@ export function useCreateSubmit() { from.submit(); field.data = field.data || {}; field.data.loading = true; - + delete from.values['createdAt']; + delete from.values['updatedAt']; const res = await apiClient.resource('approvals').create({ values: { collectionName: joinCollectionName(collection.dataSource, collection.name), 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 634b67e88..8d956d806 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 @@ -109,18 +109,26 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa const categoryTitle = item.workflow.title; const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName; - const summary = Object.entries(item.summary)?.map(([key, value]) => { + const summary = []; + Object.entries(item.summary)?.forEach(([key, value]) => { const field = cm.getCollectionField(`${collectionName}.${key}`); let resonValue = value; if (field.type === 'date' && value) { resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); } - - return { - label: compile(field?.uiSchema?.title || key), - value: - (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', - }; + if (key === 'createdAt') { + summary.unshift({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } else { + summary.push({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } }); const nickName = item.snapshot.createdBy?.nickname || item.execution?.context?.data.createdBy?.nickname; return { @@ -227,17 +235,26 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, ); const categoryTitle = item.workflow.title; const collectionName = item.collectionName; - const summary = Object.entries(item.summary).map(([key, value]) => { + const summary = []; + Object.entries(item.summary)?.forEach(([key, value]) => { const field = cm.getCollectionField(`${collectionName}.${key}`); let resonValue = value; if (field.type === 'date' && value) { resonValue = dayjs(value as string).format('YYYY-MM-DD HH:mm:ss'); } - return { - label: compile(field?.uiSchema?.title || key), - value: - (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', - }; + if (key === 'createdAt') { + summary.unshift({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } else { + summary.push({ + label: compile(field?.uiSchema?.title || key), + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', + }); + } }); const statusType = ApprovalStatusEnums.find((value) => value.value === item.approval?.status); const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname; diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/apply-button/hooks/useSubmitCreate.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/apply-button/hooks/useSubmitCreate.tsx index 47d477374..a704a5f44 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/apply-button/hooks/useSubmitCreate.tsx +++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/approval/usage/approval-block/launch/apply-button/hooks/useSubmitCreate.tsx @@ -28,7 +28,8 @@ export function useSubmitCreate() { from.submit(); field.data = field.data || {}; field.data.loading = true; - + delete from.values['createdAt']; + delete from.values['updatedAt']; await apiClient.resource('approvals').create({ values: { collectionName: joinCollectionName(collection.dataSource, collection.name),