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(); const { resource } = useResourceContext();
return { return {
async run() { async run() {
await form.submit(); try {
field.data = field.data || {}; await form.submit();
field.data.loading = true; field.data = field.data || {};
await resource.create({ values: form.values }); field.data.loading = true;
ctx.setVisible(false); await resource.create({ values: form.values });
await form.reset(); ctx.setVisible(false);
field.data.loading = false; await form.reset();
refresh(); field.data.loading = false;
refresh();
} catch (error) {
field.data.loading=false;
}
}, },
}; };
}; };