fix(client): initialize values in drawer form
This commit is contained in:
parent
9175ddc90e
commit
3cd0ea3d01
@ -1,5 +1,6 @@
|
|||||||
import { useForm } from '@formily/react';
|
import { useForm } from '@formily/react';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { useCollection, useCollectionManager } from '.';
|
import { useCollection, useCollectionManager } from '.';
|
||||||
import { useRequest } from '../api-client';
|
import { useRequest } from '../api-client';
|
||||||
import { useRecord } from '../record-provider';
|
import { useRecord } from '../record-provider';
|
||||||
@ -202,10 +203,17 @@ export const useBulkDestroyAction = () => {
|
|||||||
|
|
||||||
export const useValuesFromRecord = (options) => {
|
export const useValuesFromRecord = (options) => {
|
||||||
const record = useRecord();
|
const record = useRecord();
|
||||||
return useRequest(() => Promise.resolve({ data: record }), {
|
const result = useRequest(() => Promise.resolve({ data: record }), {
|
||||||
...options,
|
...options,
|
||||||
refreshDeps: [record],
|
manual: true,
|
||||||
});
|
});
|
||||||
|
const ctx = useActionContext();
|
||||||
|
useEffect(() => {
|
||||||
|
if (ctx.visible) {
|
||||||
|
result.run();
|
||||||
|
}
|
||||||
|
}, [ctx.visible]);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useValuesFromRA = (options) => {
|
export const useValuesFromRA = (options) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user