fix: loading did not disappear after submission failure (#2252)

This commit is contained in:
katherinehhh 2023-07-16 16:58:31 +08:00 committed by GitHub
parent 4812cc5692
commit 1d942d9910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -332,14 +332,18 @@ export const useCreateAction = () => {
const { resource } = useResourceContext();
return {
async run() {
await form.submit();
field.data = field.data || {};
field.data.loading = true;
await resource.create({ values: form.values });
ctx.setVisible(false);
await form.reset();
field.data.loading = false;
refresh();
try {
await form.submit();
field.data = field.data || {};
field.data.loading = true;
await resource.create({ values: form.values });
ctx.setVisible(false);
await form.reset();
field.data.loading = false;
refresh();
} catch (error) {
field.data.loading=false;
}
},
};
};