fix: 修改标签没有对应颜色,审批页面没有显示正确的创建人名称 (#1090)

Reviewed-on: daoyoucloud/tachybase#1090
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-05-31 15:42:15 +08:00 committed by sealday
parent fa167e24a1
commit 1ff8bc8157
8 changed files with 37 additions and 14 deletions

View File

@ -19,9 +19,8 @@ export const TabApprovalItem = observer((props) => {
const navigate = useNavigate(); const navigate = useNavigate();
const cm = useCollectionManager(); const cm = useCollectionManager();
useAsyncEffect(async () => { useAsyncEffect(async () => {
const { data: user } = await api.request({ url: 'users:list', params: { pageSize: 999, appends: ['roles'] } });
if (collectionName === 'approvalRecords') { 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') { } else if (collectionName === 'users_jobs') {
changeUsersJobsService(api, t, cm, compile, input, setData, params?.[tabKey], filter); 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 api
.request({ .request({
url: 'approvalRecords:listCentralized', url: 'approvalRecords:listCentralized',
params: { params: {
pageSize: 9999, pageSize: 9999,
appends: ['execution', 'job', 'node', 'workflow'], appends: ['execution', 'job', 'node', 'workflow', 'user'],
filter: { ...params, ...filter }, filter: { ...params, ...filter },
}, },
}) })
.then((res) => { .then((res) => {
const result = res.data?.data.map((item) => { 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 priorityType = ApprovalPriorityType.find((priorityItem) => priorityItem.value === item.snapshot.priority);
const statusType = approvalTodoListStatus(item, t); const statusType = approvalTodoListStatus(item, t);
const categoryTitle = item.workflow.title.replace('审批流:', ''); const categoryTitle = item.workflow.title.replace('审批流:', '');
@ -109,7 +107,7 @@ const changeApprovalRecordsService = (api, params, filter, user, cm, compile, t,
}); });
return { return {
...item, ...item,
title: `${itemUser.nickname}${categoryTitle}`, title: `${item.snapshot.createdBy.nickname}${categoryTitle}`,
categoryTitle: categoryTitle, categoryTitle: categoryTitle,
statusTitle: t(statusType.label), statusTitle: t(statusType.label),
statusColor: statusType.color, statusColor: statusType.color,

View File

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

View File

@ -4,6 +4,8 @@ import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/
import { Checkbox, CheckboxGroupProps, CheckboxProps, Tag } from 'antd-mobile'; import { Checkbox, CheckboxGroupProps, CheckboxProps, Tag } from 'antd-mobile';
import { getMobileColor } from '../../../CustomColor';
type ComposedCheckBox = React.FC<CheckboxProps> & { type ComposedCheckBox = React.FC<CheckboxProps> & {
Group?: any; Group?: any;
}; };
@ -59,7 +61,7 @@ MCheckbox.Group = connect(
{dataSource {dataSource
.filter((option) => option.value == value) .filter((option) => option.value == value)
.map((option, key) => ( .map((option, key) => (
<Tag key={key} color={option.color}> <Tag key={key} color={getMobileColor(option.color)}>
{option.label} {option.label}
</Tag> </Tag>
))} ))}

View File

@ -4,6 +4,8 @@ import { connect, isValid, mapProps, mapReadPretty, useField } from '@tachybase/
import { Radio, RadioGroupProps, RadioProps, Tag } from 'antd-mobile'; import { Radio, RadioGroupProps, RadioProps, Tag } from 'antd-mobile';
import { getMobileColor } from '../../../CustomColor';
type ComposedRadio = React.FC<RadioProps> & { type ComposedRadio = React.FC<RadioProps> & {
Group?: any; Group?: any;
}; };
@ -55,11 +57,13 @@ MRadio.Group = connect(
<div> <div>
{dataSource {dataSource
.filter((option) => option.value == value) .filter((option) => option.value == value)
.map((option, key) => ( .map((option, key) => {
<Tag key={key} color={option.color}> return (
{option.label} <Tag key={key} color={getMobileColor(option.color)}>
</Tag> {option.label}
))} </Tag>
);
})}
</div> </div>
); );
}), }),

View File

@ -11,8 +11,8 @@ import { connect, Field, merge, useField, useFieldSchema } from '@tachybase/sche
import { concat } from 'lodash'; import { concat } from 'lodash';
import { canMobileField } from '../../CustomComponent';
import { useIsMobile } from '../../hooks'; import { useIsMobile } from '../../hooks';
import { canMobileField } from '../form/CustomComponent';
type Props = { type Props = {
component: any; component: any;

View File

@ -11,8 +11,8 @@ import {
} from '@tachybase/client'; } from '@tachybase/client';
import { Schema, useForm } from '@tachybase/schema'; import { Schema, useForm } from '@tachybase/schema';
import { canMobileField } from '../../CustomComponent';
import { useIsMobile } from '../../hooks'; import { useIsMobile } from '../../hooks';
import { canMobileField } from './CustomComponent';
export const useFormItemInitializerFields = (options?: any) => { export const useFormItemInitializerFields = (options?: any) => {
const { name, currentFields } = useCollection_deprecated(); const { name, currentFields } = useCollection_deprecated();

View File

@ -3,3 +3,5 @@ export * from './components';
export * from './scopes'; export * from './scopes';
export * from './hooks'; export * from './hooks';
export * from './provider'; export * from './provider';
export * from './CustomColor';
export * from './CustomComponent';