fix: 修复移动端审批查看人名显示undefined,抄送人列表名字不正确 (#1164)

Reviewed-on: daoyoucloud/tachybase#1164
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-06-12 20:49:07 +08:00 committed by sealday
parent d7a3142ada
commit c31608b8cb
6 changed files with 28 additions and 10 deletions

View File

@ -24,7 +24,8 @@ export const TabApprovalItem = observer((props) => {
} else if (collectionName === 'users_jobs') {
changeUsersJobsService(api, t, cm, compile, input, setData, params?.[tabKey], filter);
} else if (collectionName === 'workflowNotice') {
changeWorkflowNoticeService(api, t, cm, compile, input, setData, params?.[tabKey], filter);
const user = await api.request({ url: 'users:list', params: { pageSize: 99999 } });
changeWorkflowNoticeService(api, t, cm, compile, input, setData, params?.[tabKey], filter, user?.data?.data);
}
}, [filter, params, input]);
@ -95,6 +96,7 @@ const changeApprovalRecordsService = (api, params, filter, cm, compile, t, setDa
const statusType = approvalTodoListStatus(item, t);
const categoryTitle = item.workflow.title.replace('审批流:', '');
const collectionName = item.workflow?.config?.collection || item.execution?.context?.collectionName;
const summary = Object.entries(item.summary)?.map(([key, value]) => {
const field = cm.getCollectionField(`${collectionName}.${key}`);
return {
@ -167,7 +169,7 @@ const changeUsersJobsService = (api, t, cm, compile, input, setData, params, fil
});
};
export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter) => {
export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData, params, filter, user) => {
api
.request({
url: 'workflowNotice:listCentralized',
@ -205,9 +207,10 @@ export const changeWorkflowNoticeService = (api, t, cm, compile, input, setData,
value: (Object.prototype.toString.call(value) === '[object Object]' ? value?.['name'] : value) || '',
};
});
const nickName = user.find((userItem) => userItem.id === item.snapshot?.createdById)?.nickname;
return {
...item,
title: `${item.user?.nickname}${categoryTitle}`,
title: `${nickName}${categoryTitle}`,
categoryTitle: categoryTitle,
statusTitle: t(statusType.label),
statusColor: statusType.color,

View File

@ -24,6 +24,7 @@ import { MobileProvider } from '@tachybase/plugin-mobile-client/client';
import { observer } from '@tachybase/schema';
import { ContextApprovalExecution } from '../../context/ApprovalExecution';
import { useWorkflowNoticeFormBlockProps } from '../hook/useFormBlockProps';
import { usePropsNoticeDetail } from '../hook/usePropsNoticeDetail';
// 审批-抄送-查看: 内容
@ -93,7 +94,7 @@ export const ViewTodosWorkflowNoticeContent = observer((props) => {
}}
scope={{
usePropsNoticeDetail,
useDetailsBlockProps: useFormBlockContext,
useDetailsBlockProps: useWorkflowNoticeFormBlockProps,
}}
schema={{
type: 'void',

View File

@ -52,3 +52,16 @@ export function useUserJobsFormBlockProps() {
return { form };
}
export const useWorkflowNoticeFormBlockProps = () => {
const ctx = useFormBlockContext();
const { snapshot } = useContextApprovalExecution();
useEffect(() => {
if (!ctx?.service?.loading) {
ctx.form?.setInitialValues(snapshot);
}
}, [snapshot]);
return {
form: ctx.form,
};
};

View File

@ -10,7 +10,7 @@ type ComposedInput = ((props: InputProps) => React.ReactNode) & {
export const MInput: ComposedInput = connect(
Input,
mapProps((props) => {
return { placeholder: '请输入内容', clearable: true, ...props, style: { '--font-size': '12px' } };
return { placeholder: '请输入内容', clearable: true, ...props, style: { '--font-size': '12px', ...props?.style } };
}),
mapReadPretty((props) => {
return <span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>{props.value}</span>;
@ -20,7 +20,7 @@ export const MInput: ComposedInput = connect(
const MTextArea = connect(
TextArea,
mapProps((props) => {
return { ...props, placeholder: '请输入内容', clearable: true, style: { '--font-size': '12px' } };
return { ...props, placeholder: '请输入内容', clearable: true, style: { '--font-size': '12px', ...props?.style } };
}),
mapReadPretty((props) => {
return <div style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>{props.value}</div>;

View File

@ -43,7 +43,7 @@ export const AntdSelect = observer((props) => {
let inputValue = '';
if (isArray(value)) {
value.forEach((item, index) => {
inputValue += `${item.label}${value.length - 1 === index ? '' : ','}`;
inputValue += `${item[fieldNamesLabel]}${value.length - 1 === index ? '' : ', '}`;
});
} else if (value && typeof value === 'object') {
inputValue = value[fieldNamesLabel];
@ -133,7 +133,7 @@ export const AntdSelect = observer((props) => {
style={{ color: '#c5c5c5' }}
>
{value?.length || (value && !isArray(value)) ? (
<MInput value={inputValue} disabled={fieldSchema['x-disabled']} />
<MInput style={{ '--color': '#1e8bf1' }} value={inputValue} disabled={fieldSchema['x-disabled']} />
) : (
<Space>{fieldSchema['x-disabled'] ? '' : '请选择内容'}</Space>
)}

View File

@ -57,8 +57,9 @@ export const MSelect = connect(
} else {
let redValue = '';
if (isArray(value)) {
redValue = value.reduce((prev, curr) => {
return prev + curr?.[fieldNamesLabel];
redValue = value.reduce((prev, curr, index) => {
const currContext = value.length - 1 === index ? '' : ', ';
return prev + curr?.[fieldNamesLabel] + currContext;
}, '');
} else {
redValue = value?.[fieldNamesLabel] || '';