fix: 修复手机端审批无法通过和状态没有显示 (#1287)

Reviewed-on: daoyoucloud/tachybase#1287
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-07-08 16:55:46 +08:00 committed by sealday
parent 7d121efb95
commit 0b958cf528
2 changed files with 25 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { useActionContext, useAPIClient, useTableBlockContext } from '@tachybase/client';
import { useActionContext, useAPIClient, useCollection, useTableBlockContext } from '@tachybase/client';
import { useFlowContext } from '@tachybase/plugin-workflow/client';
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
@ -7,12 +7,14 @@ import { Toast } from 'antd-mobile';
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
import { useContextApprovalAction } from '../provider/ApprovalAction';
export function useSubmit() {
export function useSubmit(props) {
const field = useField();
const api = useAPIClient();
const form = useForm();
const { id } = useContextApprovalExecution();
const { status } = useContextApprovalAction();
const collection = useCollection();
const needUpdateRecord = props?.source === 'updateRecord';
return {
run: async () => {
try {
@ -22,9 +24,22 @@ export function useSubmit() {
await form.submit();
field.data = field.data ?? {};
field.data.loading = true;
if (needUpdateRecord) {
const collectionName = collection.name;
const targetId = form.values.id;
await api.resource(collectionName).update({
filterByTk: targetId,
values: form.values,
});
}
const res = await api.resource('approvalRecords').submit({
filterByTk: id,
values: { ...form.values, status },
values: {
status,
needUpdateRecord,
data: form.values,
},
});
field.data.loading = false;
if (res.status === 202) {

View File

@ -28,7 +28,13 @@ export const MSelect = connect(
return { ...filterProps };
}),
mapReadPretty((props) => {
return <AssociationField.ReadPretty {...props} />;
const collectionField = useCollectionField();
if (typeof props.value === 'object') {
return <AssociationField.ReadPretty {...props} />;
} else {
const option = collectionField?.uiSchema?.enum?.find((item) => item.value === props.value);
return <Tag color={getMobileColor(option?.color)}>{option?.label}</Tag>;
}
}),
);