Skip to content

Commit

Permalink
feat: add the parameter submitOnReset to the form (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 25, 2020
1 parent 623729d commit 7558cbf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/Form/src/BasicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
}
async function resetFields(): Promise<any> {
const { resetFunc } = unref(getProps);
const { resetFunc, submitOnReset } = unref(getProps);
resetFunc && isFunction(resetFunc) && (await resetFunc());
const formEl = unref(formElRef);
if (!formEl) return;
Expand All @@ -276,6 +276,7 @@
// const values = formEl.resetFields();
emit('reset', toRaw(formModel));
// return values;
submitOnReset && handleSubmit();
}
/**
Expand Down
4 changes: 4 additions & 0 deletions src/components/Form/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const basicProps = {
type: Boolean,
default: true,
},
submitOnReset: {
type: Boolean,
default: false,
},
size: {
type: String as PropType<'default' | 'small' | 'large'>,
default: 'default',
Expand Down
3 changes: 2 additions & 1 deletion src/components/Form/src/types/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export type UseFormReturnType = [RegisterFn, FormActionType];
export interface FormProps {
// 整个表单所有项宽度
labelWidth?: number | string;

// 重置时提交
submitOnReset?: boolean;
// 整个表单通用Col配置
labelCol?: Partial<ColEx>;
// 整个表单通用Col配置
Expand Down
1 change: 1 addition & 0 deletions src/components/Table/src/BasicTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<BasicForm
v-bind="getFormProps"
v-if="getBindValues.useSearchForm"
:submitOnReset="true"
:submitButtonOptions="{ loading }"
@register="registerForm"
@submit="handleSearchInfoChange"
Expand Down

0 comments on commit 7558cbf

Please sign in to comment.