fix: 修改执行处理没有显示数据,把审核内容和流程放在同一页面 (#1077)

Reviewed-on: daoyoucloud/tachybase#1077
Co-authored-by: wangjiahui <wwwjh0710@163.com>
Co-committed-by: wangjiahui <wwwjh0710@163.com>
This commit is contained in:
wangjiahui 2024-05-30 15:28:29 +08:00 committed by sealday
parent 15fd844617
commit f054e56647
4 changed files with 13 additions and 82 deletions

View File

@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
RemoteSchemaComponent,
SchemaComponent,
@ -6,21 +6,16 @@ import {
useAPIClient,
useDestroyAction,
useFormBlockContext,
useRecord,
useRequest,
} from '@tachybase/client';
import { DetailsBlockProvider, FlowContext } from '@tachybase/plugin-workflow/client';
import { useFieldSchema, useForm } from '@tachybase/schema';
import { DetailsBlockProvider } from '@tachybase/plugin-workflow/client';
import { useForm } from '@tachybase/schema';
import { Result, Spin } from 'antd';
import { NavBar, Skeleton, TabBar } from 'antd-mobile';
import { FileOutline, UserContactOutline } from 'antd-mobile-icons';
import { useNavigate, useParams } from 'react-router-dom';
import { ContextApprovalExecution } from '../../context/ApprovalExecution';
import { FormBlockProvider } from '../../context/FormBlock';
import { SchemaComponentContextProvider } from '../../context/SchemaComponent';
import { ContextWithActionEnabled } from '../../context/WithActionEnabled';
import { useTranslation } from '../../locale';
import { useFormBlockProps } from '../hook/useFormBlockProps';
import { useUpdateSubmit } from '../hook/useUpadteSubmit';
@ -37,10 +32,8 @@ export const ViewActionUserInitiationsContent = () => {
const params = useParams();
const navigate = useNavigate();
const { id } = params;
const { actionEnabled } = useContext(ContextWithActionEnabled);
const [noDate, setNoDate] = useState(false);
const [recordData, setRecordDate] = useState({});
const [currContext, setCurrContext] = useState('formContext');
const { t } = useTranslation();
const api = useAPIClient();
useEffect(() => {
@ -96,16 +89,7 @@ export const ViewActionUserInitiationsContent = () => {
<div className="approvalContext">
{Object.keys(recordData).length && !noDate ? (
<ContextApprovalExecution.Provider value={recordData}>
{UserInitiationsComponent(workflow?.config.applyForm, t, currContext)}
<TabBar
onChange={(item) => {
setCurrContext(item);
}}
className="tabsBarStyle"
>
<TabBar.Item key="formContext" icon={<FileOutline />} title="申请内容" />
{actionEnabled ? null : <TabBar.Item key="approval" icon={<UserContactOutline />} title="审批处理" />}
</TabBar>
{UserInitiationsComponent(workflow?.config.applyForm)}
</ContextApprovalExecution.Provider>
) : (
<div>
@ -119,7 +103,7 @@ export const ViewActionUserInitiationsContent = () => {
);
};
const UserInitiationsComponent = (applyDetail, t, currContext) => {
const UserInitiationsComponent = (applyDetail) => {
const formContextSchema = {
type: 'void',
'x-component': 'MobileProvider',
@ -141,21 +125,6 @@ const UserInitiationsComponent = (applyDetail, t, currContext) => {
noForm: true,
},
},
},
},
},
};
const approvalSchema = {
type: 'void',
'x-component': 'MobileProvider',
properties: {
page: {
type: 'void',
'x-component': 'MPage',
'x-designer': 'MPage.Designer',
'x-component-props': {},
properties: {
process: {
type: 'void',
'x-decorator': 'CardItem',
@ -187,7 +156,7 @@ const UserInitiationsComponent = (applyDetail, t, currContext) => {
useWithdrawAction,
useDestroyAction,
}}
schema={currContext === 'formContext' ? formContextSchema : approvalSchema}
schema={formContextSchema}
/>
);
};

View File

@ -57,7 +57,7 @@ export const TabApprovalItem = observer((props) => {
</Tag>
</Space>
{/* </Badge> */}
{item.reason.map((reasonItem, index) => {
{item.reason?.map((reasonItem, index) => {
return <Space block key={index}>{`${reasonItem.label}:${reasonItem.value}`}</Space>;
})}
</List.Item>
@ -146,14 +146,6 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil
);
const statusType = ExecutionStatusOptions.find((value) => value.value === item.status);
const categoryTitle = item.workflow.title.replace('审批流:', '');
const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName;
const summary = Object.entries(item.execution?.context?.summary).map(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`);
return {
label: compile(field?.uiSchema?.title || key),
value: (Object.prototype.toString.call(value) === '[object Object]' ? value?.['name'] : value) || '',
};
});
return {
...item,
title: `${item.user?.nickname}${categoryTitle}`,
@ -161,12 +153,13 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil
statusTitle: t(statusType.label),
statusColor: statusType.color,
statusIcon: statusType.icon,
reason: summary,
reason: [],
priorityTitle: priorityType.label,
priorityColor: priorityType.color,
};
});
const filterResult = result.filter((value) => value.title.includes(input));
filterResult.sort((a, b) => {
return Date.parse(b.createdAt) - Date.parse(a.createdAt);
});

View File

@ -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';

View File

@ -1,25 +1,21 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
RemoteSchemaComponent,
SchemaComponent,
SchemaComponentProvider,
useAPIClient,
useFormBlockContext,
useRecord,
useRequest,
} from '@tachybase/client';
import { DetailsBlockProvider } from '@tachybase/plugin-workflow/client';
import { Result } from 'antd';
import { NavBar, Skeleton, TabBar } from 'antd-mobile';
import { CouponOutline, FileOutline, ScanCodeOutline, UserContactOutline } from 'antd-mobile-icons';
import _ from 'lodash';
import { useNavigate, useParams } from 'react-router-dom';
import { ContextApprovalExecution } from '../../context/ApprovalExecution';
import { FormBlockProvider } from '../../context/FormBlock';
import { SchemaComponentContextProvider } from '../../context/SchemaComponent';
import { ContextWithActionEnabled } from '../../context/WithActionEnabled';
import { useTranslation } from '../../locale';
import { useApprovalDetailBlockProps } from '../hook/useApprovalDetailBlockProps';
import { useApprovalFormBlockProps } from '../hook/useApprovalFormBlockProps';
@ -35,14 +31,12 @@ import { MobileProvider } from '@tachybase/plugin-mobile-client/client';
// 审批-待办-查看: 内容
export const ViewActionTodosContent = () => {
const { t } = useTranslation();
const { actionEnabled } = useContext(ContextWithActionEnabled);
const navigate = useNavigate();
const params = useParams();
const { id } = params;
const api = useAPIClient();
const [noDate, setNoDate] = useState(false);
const [recordData, setRecordDate] = useState({});
const [currContext, setCurrContext] = useState('formContext');
useEffect(() => {
api
.request({
@ -110,16 +104,7 @@ export const ViewActionTodosContent = () => {
<div className="approvalContext">
{Object.keys(recordData).length && !noDate ? (
<ContextApprovalExecution.Provider value={recordData}>
{todosComponent(node?.config.applyDetail, t, currContext)}
<TabBar
onChange={(item) => {
setCurrContext(item);
}}
className="tabsBarStyle"
>
<TabBar.Item key="formContext" icon={<FileOutline />} title="申请内容" />
{actionEnabled ? null : <TabBar.Item key="approval" icon={<UserContactOutline />} title="审批处理" />}
</TabBar>
{todosComponent(node?.config.applyDetail)}
</ContextApprovalExecution.Provider>
) : (
<div>
@ -132,7 +117,7 @@ export const ViewActionTodosContent = () => {
);
};
const todosComponent = (applyDetail, t, currContext) => {
const todosComponent = (applyDetail) => {
const formContextSchema = {
type: 'void',
'x-component': 'MobileProvider',
@ -154,21 +139,6 @@ const todosComponent = (applyDetail, t, currContext) => {
noForm: true,
},
},
},
},
},
};
const approvalSchema = {
type: 'void',
'x-component': 'MobileProvider',
properties: {
page: {
type: 'void',
'x-component': 'MPage',
'x-designer': 'MPage.Designer',
'x-component-props': {},
properties: {
process: {
type: 'void',
'x-decorator': 'CardItem',
@ -199,7 +169,7 @@ const todosComponent = (applyDetail, t, currContext) => {
useDetailsBlockProps: useFormBlockContext,
useSubmit,
}}
schema={currContext === 'formContext' ? formContextSchema : approvalSchema}
schema={formContextSchema}
/>
);
};