From eb8528d44c576e154a87c6aefaad3bf8c8a677e4 Mon Sep 17 00:00:00 2001 From: wjh Date: Mon, 1 Jul 2024 16:39:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=AB=AF=E5=AE=A1=E6=89=B9=E5=8A=9F=E8=83=BD=20(#1247)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1247 Co-authored-by: wjh Co-committed-by: wjh --- .../component/ApprovalProcess.view.tsx | 10 ++-- .../src/client/approval/todos/TodosBlock.tsx | 4 +- .../todos/component/TabApprovalItem.tsx | 48 ++++++++++++++----- .../todos/component/TabPendingItem.tsx | 1 - .../antd-mobile/Select/AntdSelect.tsx | 4 +- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx index ecbc72256..e61ef7a72 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/component/ApprovalProcess.view.tsx @@ -165,11 +165,12 @@ const getStepsResult = (result, t) => { status['color'] = approvalActionStatus?.color || approvalStatus?.color || 'default'; } } + if (Object.keys(stepItem).includes(value.nodeId ? value.nodeId.toString() : '')) { stepItem[value.nodeId].description.push({ userName: value.user.nickname, status, - date: value.status === 0 ? '' : dayjs(value.execution.updatedAt).format('YYYY-MM-DD hh:mm:ss'), + date: value.status === 0 ? '' : dayjs(value.updatedAt).format('YYYY-MM-DD hh:mm:ss'), }); } else { stepItem[value.nodeId || value.node?.title || t(status['label'])] = { @@ -179,12 +180,7 @@ const getStepsResult = (result, t) => { { userName: value.user.nickname, status, - date: - value.status === 0 - ? '' - : dayjs( - value.nodeId ? value.execution?.updatedAt : value.execution?.createdAt || value.updatedAt, - ).format('YYYY-MM-DD hh:mm:ss'), + date: value.status === 0 ? '' : dayjs(value.updatedAt).format('YYYY-MM-DD hh:mm:ss'), }, ], }; diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx index 0d9acda46..25730bb22 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/TodosBlock.tsx @@ -93,14 +93,14 @@ export const TodosBlock = observer((props) => { schema={tabDuplicateSchema(t, props, fieldSchema['x-uid'])} /> - + {/* - + */} 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 990bb78cd..4668d40be 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 @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'; import { useAPIClient, useCollectionManager, useCompile } from '@tachybase/client'; import { ExecutionStatusOptionsMap } from '@tachybase/plugin-workflow/client'; import { observer } from '@tachybase/schema'; +import { dayjs } from '@tachybase/utils/client'; import { useAsyncEffect } from 'ahooks'; import { Empty, List, Space, Tag } from 'antd-mobile'; @@ -45,10 +46,13 @@ export const TabApprovalItem = observer((props) => { {/* */} {item.title} - - {item.statusIcon} - {item.statusTitle} - + {item.statusTitle ? ( + + {item.statusIcon} + {item.statusTitle} + + ) : null} + {item.priorityTitle} @@ -99,9 +103,15 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa const summary = Object.entries(item.summary)?.map(([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'); + } + return { label: compile(field?.uiSchema?.title || key), - value: (Object.prototype.toString.call(value) === '[object Object]' ? value?.['name'] : value) || '', + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', }; }); const nickName = item.snapshot.createdBy?.nickname || item.execution?.context?.data.createdBy?.nickname; @@ -116,7 +126,11 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa priorityColor: priorityType.color, }; }); - const filterResult = result.filter((value) => value.title.includes(input)); + const filterResult = result.filter((value) => { + const reason = value?.reason.find((reasonItem) => reasonItem?.value.toString().includes(input)); + return value.title.includes(input) || reason; + }); + filterResult.sort((a, b) => { return Date.parse(b.createdAt) - Date.parse(a.createdAt); }); @@ -157,7 +171,10 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil priorityColor: priorityType.color, }; }); - const filterResult = result.filter((value) => value.title.includes(input)); + const filterResult = result.filter((value) => { + const reason = value?.reason.find((reasonItem) => reasonItem?.value.toString().includes(input)); + return value.title.includes(input) || reason; + }); filterResult.sort((a, b) => { return Date.parse(b.createdAt) - Date.parse(a.createdAt); @@ -197,14 +214,18 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, const priorityType = ApprovalPriorityType.find( (priorityItem) => priorityItem.value === item.snapshot?.priority, ); - const statusType = approvalStatusOptions.find((value) => value.value === item.status); const categoryTitle = item.workflow.title.replace('审批流:', ''); const collectionName = item.collectionName; const summary = Object.entries(item.summary).map(([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'); + } return { label: compile(field?.uiSchema?.title || key), - value: (Object.prototype.toString.call(value) === '[object Object]' ? value?.['name'] : value) || '', + value: + (Object.prototype.toString.call(value) === '[object Object]' ? resonValue?.['name'] : resonValue) || '', }; }); const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname; @@ -212,15 +233,18 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, ...item, title: `${nickName}的${categoryTitle}`, categoryTitle: categoryTitle, - statusTitle: t(statusType.label), - statusColor: statusType.color, + statusTitle: null, + statusColor: null, reason: summary, priorityTitle: priorityType.label, priorityColor: priorityType.color, }; }); - const filterResult = result.filter((value) => value.title.includes(input)); + const filterResult = result.filter((value) => { + const reason = value?.reason.find((reasonItem) => reasonItem?.value.toString().includes(input)); + return value.title.includes(input) || reason; + }); filterResult.sort((a, b) => { return Date.parse(b.createdAt) - Date.parse(a.createdAt); diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabPendingItem.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabPendingItem.tsx index d604000e7..e567d9f54 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabPendingItem.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/component/TabPendingItem.tsx @@ -6,7 +6,6 @@ import { Space } from 'antd-mobile'; import { ApprovalReachDataType } from '../../component/ApprovalReachDataType'; import { ApprovalTemplateType } from '../../component/ApprovalTemplateType'; -import { PendingStatus } from '../../constants'; import { useTodosContext } from '../provider/todosContext'; import { TabApplicantType } from './TabApplicantType'; import { TabApprovalItem } from './TabApprovalItem'; 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 c4bd1ae4c..e24841dda 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 @@ -35,7 +35,7 @@ export const AntdSelect = observer((props) => { const cm = useCollectionManager(); const collection = useCollection(); const [fieldServiceFilter] = useFieldServiceFilter(service?.params); - const [filter, setFilter] = useState(fieldServiceFilter); + const [filter, setFilter] = useState({}); const api = useAPIClient(); const [selectValue, setSelectValue] = useState(value); const fieldNamesLabel = fieldNames?.label || 'label'; @@ -54,7 +54,7 @@ export const AntdSelect = observer((props) => { resource: collectionName, action: 'list', params: { - filter, + filter: { ...fieldServiceFilter?.filter, ...filter }, }, }, {