mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
refactor: loading wthen action submjit
This commit is contained in:
parent
4b78c2161e
commit
2ba95787c3
@ -1,6 +1,6 @@
|
|||||||
import { DownOutlined, PlusOutlined } from '@ant-design/icons';
|
import { DownOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
import { ArrayTable } from '@formily/antd';
|
import { ArrayTable } from '@formily/antd';
|
||||||
import { ISchema, useForm } from '@formily/react';
|
import { ISchema, useField, useForm } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import { Button, Dropdown, Menu } from 'antd';
|
import { Button, Dropdown, Menu } from 'antd';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
@ -28,7 +28,7 @@ const getSchema = (schema, category, compile): ISchema => {
|
|||||||
properties['defaultValue']['x-decorator'] = 'FormItem';
|
properties['defaultValue']['x-decorator'] = 'FormItem';
|
||||||
}
|
}
|
||||||
const initialValue: any = {
|
const initialValue: any = {
|
||||||
name : `t_${uid()}`,
|
name: `t_${uid()}`,
|
||||||
template: schema.name,
|
template: schema.name,
|
||||||
view: schema.name === 'view',
|
view: schema.name === 'view',
|
||||||
category,
|
category,
|
||||||
@ -195,8 +195,11 @@ const useCreateCollection = (schema?: any) => {
|
|||||||
const ctx = useActionContext();
|
const ctx = useActionContext();
|
||||||
const { refresh } = useResourceActionContext();
|
const { refresh } = useResourceActionContext();
|
||||||
const { resource } = useResourceContext();
|
const { resource } = useResourceContext();
|
||||||
|
const field = useField();
|
||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
|
field.data = field.data || {};
|
||||||
|
field.data.loading = true;
|
||||||
await form.submit();
|
await form.submit();
|
||||||
const values = cloneDeep(form.values);
|
const values = cloneDeep(form.values);
|
||||||
if (schema?.events?.beforeSubmit) {
|
if (schema?.events?.beforeSubmit) {
|
||||||
@ -218,6 +221,7 @@ const useCreateCollection = (schema?: any) => {
|
|||||||
});
|
});
|
||||||
ctx.setVisible(false);
|
ctx.setVisible(false);
|
||||||
await form.reset();
|
await form.reset();
|
||||||
|
field.data.loading = false;
|
||||||
refresh();
|
refresh();
|
||||||
await refreshCM();
|
await refreshCM();
|
||||||
},
|
},
|
||||||
|
@ -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, Dropdown, Menu } from 'antd';
|
import { Button, Dropdown, Menu } from 'antd';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
@ -136,9 +136,12 @@ const useCreateCollectionField = () => {
|
|||||||
const ctx = useActionContext();
|
const ctx = useActionContext();
|
||||||
const { refresh } = useResourceActionContext();
|
const { refresh } = useResourceActionContext();
|
||||||
const { resource } = useResourceContext();
|
const { resource } = useResourceContext();
|
||||||
|
const field = useField();
|
||||||
return {
|
return {
|
||||||
async run() {
|
async run() {
|
||||||
await form.submit();
|
await form.submit();
|
||||||
|
field.data = field.data || {};
|
||||||
|
field.data.loading = true;
|
||||||
const values = cloneDeep(form.values);
|
const values = cloneDeep(form.values);
|
||||||
if (values.autoCreateReverseField) {
|
if (values.autoCreateReverseField) {
|
||||||
} else {
|
} else {
|
||||||
@ -148,6 +151,7 @@ const useCreateCollectionField = () => {
|
|||||||
await resource.create({ values });
|
await resource.create({ values });
|
||||||
ctx.setVisible(false);
|
ctx.setVisible(false);
|
||||||
await form.reset();
|
await form.reset();
|
||||||
|
field.data.loading = false;
|
||||||
refresh();
|
refresh();
|
||||||
await refreshCM();
|
await refreshCM();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user