diff --git a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx index 943132613..0b8e40b25 100644 --- a/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx +++ b/packages/plugins/@hera/plugin-approval-mobile/src/client/approval/todos/hook/useSubmit.tsx @@ -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) { diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx index d82e57692..654887dc9 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/components/antd-mobile/Select/Select.tsx @@ -28,7 +28,13 @@ export const MSelect = connect( return { ...filterProps }; }), mapReadPretty((props) => { - return ; + const collectionField = useCollectionField(); + if (typeof props.value === 'object') { + return ; + } else { + const option = collectionField?.uiSchema?.enum?.find((item) => item.value === props.value); + return {option?.label}; + } }), );