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:
parent
7d121efb95
commit
0b958cf528
@ -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 { useFlowContext } from '@tachybase/plugin-workflow/client';
|
||||||
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
|
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
|
||||||
|
|
||||||
@ -7,12 +7,14 @@ import { Toast } from 'antd-mobile';
|
|||||||
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
import { useContextApprovalExecution } from '../../context/ApprovalExecution';
|
||||||
import { useContextApprovalAction } from '../provider/ApprovalAction';
|
import { useContextApprovalAction } from '../provider/ApprovalAction';
|
||||||
|
|
||||||
export function useSubmit() {
|
export function useSubmit(props) {
|
||||||
const field = useField();
|
const field = useField();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const form = useForm();
|
const form = useForm();
|
||||||
const { id } = useContextApprovalExecution();
|
const { id } = useContextApprovalExecution();
|
||||||
const { status } = useContextApprovalAction();
|
const { status } = useContextApprovalAction();
|
||||||
|
const collection = useCollection();
|
||||||
|
const needUpdateRecord = props?.source === 'updateRecord';
|
||||||
return {
|
return {
|
||||||
run: async () => {
|
run: async () => {
|
||||||
try {
|
try {
|
||||||
@ -22,9 +24,22 @@ export function useSubmit() {
|
|||||||
await form.submit();
|
await form.submit();
|
||||||
field.data = field.data ?? {};
|
field.data = field.data ?? {};
|
||||||
field.data.loading = true;
|
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({
|
const res = await api.resource('approvalRecords').submit({
|
||||||
filterByTk: id,
|
filterByTk: id,
|
||||||
values: { ...form.values, status },
|
values: {
|
||||||
|
status,
|
||||||
|
needUpdateRecord,
|
||||||
|
data: form.values,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
field.data.loading = false;
|
field.data.loading = false;
|
||||||
if (res.status === 202) {
|
if (res.status === 202) {
|
||||||
|
@ -28,7 +28,13 @@ export const MSelect = connect(
|
|||||||
return { ...filterProps };
|
return { ...filterProps };
|
||||||
}),
|
}),
|
||||||
mapReadPretty((props) => {
|
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>;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user