refactor: loading wthen action submit
This commit is contained in:
parent
83daf55741
commit
28ef3b6952
@ -1,6 +1,6 @@
|
|||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { ArrayTable } from '@formily/antd';
|
import { ArrayTable } from '@formily/antd';
|
||||||
import { useForm } from '@formily/react';
|
import { useForm, useField } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
@ -130,15 +130,19 @@ const useSyncFromDatabase = () => {
|
|||||||
const { targetKey } = useResourceContext();
|
const { targetKey } = useResourceContext();
|
||||||
const { [targetKey]: filterByTk } = useRecord();
|
const { [targetKey]: filterByTk } = useRecord();
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
|
const field = useField();
|
||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
await form.submit();
|
await form.submit();
|
||||||
|
field.data = field.data || {};
|
||||||
|
field.data.loading = true;
|
||||||
await api.resource(`collections`).setFields({
|
await api.resource(`collections`).setFields({
|
||||||
filterByTk,
|
filterByTk,
|
||||||
values: form.values,
|
values: form.values,
|
||||||
});
|
});
|
||||||
ctx.setVisible(false);
|
ctx.setVisible(false);
|
||||||
await form.reset();
|
await form.reset();
|
||||||
|
field.data.loading = false;
|
||||||
refresh();
|
refresh();
|
||||||
await refreshCM();
|
await refreshCM();
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user