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