Commit d09406e3cb8cfc069ce79b5f4194f7d959f63daf

Authored by vben
1 parent 74d47424

feat: add the parameter submitOnReset to the form (#54)

src/components/Form/src/BasicForm.vue
@@ -266,7 +266,7 @@ @@ -266,7 +266,7 @@
266 } 266 }
267 267
268 async function resetFields(): Promise<any> { 268 async function resetFields(): Promise<any> {
269 - const { resetFunc } = unref(getProps); 269 + const { resetFunc, submitOnReset } = unref(getProps);
270 resetFunc && isFunction(resetFunc) && (await resetFunc()); 270 resetFunc && isFunction(resetFunc) && (await resetFunc());
271 const formEl = unref(formElRef); 271 const formEl = unref(formElRef);
272 if (!formEl) return; 272 if (!formEl) return;
@@ -276,6 +276,7 @@ @@ -276,6 +276,7 @@
276 // const values = formEl.resetFields(); 276 // const values = formEl.resetFields();
277 emit('reset', toRaw(formModel)); 277 emit('reset', toRaw(formModel));
278 // return values; 278 // return values;
  279 + submitOnReset && handleSubmit();
279 } 280 }
280 281
281 /** 282 /**
src/components/Form/src/props.ts
@@ -30,6 +30,10 @@ export const basicProps = { @@ -30,6 +30,10 @@ export const basicProps = {
30 type: Boolean, 30 type: Boolean,
31 default: true, 31 default: true,
32 }, 32 },
  33 + submitOnReset: {
  34 + type: Boolean,
  35 + default: false,
  36 + },
33 size: { 37 size: {
34 type: String as PropType<'default' | 'small' | 'large'>, 38 type: String as PropType<'default' | 'small' | 'large'>,
35 default: 'default', 39 default: 'default',
src/components/Form/src/types/form.ts
@@ -30,7 +30,8 @@ export type UseFormReturnType = [RegisterFn, FormActionType]; @@ -30,7 +30,8 @@ export type UseFormReturnType = [RegisterFn, FormActionType];
30 export interface FormProps { 30 export interface FormProps {
31 // 整个表单所有项宽度 31 // 整个表单所有项宽度
32 labelWidth?: number | string; 32 labelWidth?: number | string;
33 - 33 + // 重置时提交
  34 + submitOnReset?: boolean;
34 // 整个表单通用Col配置 35 // 整个表单通用Col配置
35 labelCol?: Partial<ColEx>; 36 labelCol?: Partial<ColEx>;
36 // 整个表单通用Col配置 37 // 整个表单通用Col配置
src/components/Table/src/BasicTable.vue
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 <BasicForm 9 <BasicForm
10 v-bind="getFormProps" 10 v-bind="getFormProps"
11 v-if="getBindValues.useSearchForm" 11 v-if="getBindValues.useSearchForm"
  12 + :submitOnReset="true"
12 :submitButtonOptions="{ loading }" 13 :submitButtonOptions="{ loading }"
13 @register="registerForm" 14 @register="registerForm"
14 @submit="handleSearchInfoChange" 15 @submit="handleSearchInfoChange"