Skip to content

Commit

Permalink
fix(useFormModal): onOk logic
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Jun 6, 2023
1 parent 4d7d9fc commit a0510f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/core/schema-form/src/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function useFormEvents(formActionContext: UseFormActionContext) {
await schemaFormRef.value?.scrollToField(name, options);
}

async function handleSubmit(e?: Event): Promise<void> {
async function handleSubmit(e?: Event) {
e && e.preventDefault();
const { submitFunc } = unref(getFormProps);
if (submitFunc && isFunction(submitFunc)) {
Expand All @@ -250,6 +250,7 @@ export function useFormEvents(formActionContext: UseFormActionContext) {
const values = await validate();
const res = handleFormValues(values);
emit('submit', res);
return res;
} catch (error: any) {
return Promise.reject(error);
}
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useModal/useFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function useFormModal<T = any>() {
const onOk = async () => {
// const values = (formRef?.formModel || {}) as any;
try {
await formRef.value?.submit();
const values = await formRef.value?.submit();
await onSubmit(values);
} catch (error) {
modalProps?.onFail?.({} as any);
return Promise.reject(error);
Expand All @@ -43,7 +44,7 @@ export function useFormModal<T = any>() {
onCancel,
onOk,
content: () => {
const _formProps = Object.assign({}, { showActionButtonGroup: false, onSubmit }, formProps);
const _formProps = Object.assign({}, { showActionButtonGroup: false }, formProps);

return <SchemaForm ref={formRef} {..._formProps}></SchemaForm>;
},
Expand Down

2 comments on commit a0510f7

@vercel
Copy link

@vercel vercel bot commented on a0510f7 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vue3-antd-admin – ./

vue3-antd-admin-git-main-buqiyuan.vercel.app
vue3-antd-admin.vercel.app
vue3-antd-admin-buqiyuan.vercel.app

@Eastboat
Copy link

@Eastboat Eastboat commented on a0510f7 Jun 6, 2023 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.