Commit f964533701389109d90144cbefff7042cdcedbf6
Committed by
GitHub
1 parent
dd158a17
feat(BasicForm): add `submitOnChange` option (#1521)
Showing
5 changed files
with
15 additions
and
3 deletions
src/components/Form/src/BasicForm.vue
... | ... | @@ -58,6 +58,7 @@ |
58 | 58 | import { createFormContext } from './hooks/useFormContext'; |
59 | 59 | import { useAutoFocus } from './hooks/useAutoFocus'; |
60 | 60 | import { useModalContext } from '/@/components/Modal'; |
61 | + import { useDebounceFn } from '@vueuse/core'; | |
61 | 62 | |
62 | 63 | import { basicProps } from './props'; |
63 | 64 | import { useDesign } from '/@/hooks/web/useDesign'; |
... | ... | @@ -225,6 +226,14 @@ |
225 | 226 | }, |
226 | 227 | ); |
227 | 228 | |
229 | + watch( | |
230 | + () => formModel, | |
231 | + useDebounceFn(() => { | |
232 | + unref(getProps).submitOnChange && handleSubmit(); | |
233 | + }, 300), | |
234 | + { deep: true }, | |
235 | + ); | |
236 | + | |
228 | 237 | async function setProps(formProps: Partial<FormProps>): Promise<void> { |
229 | 238 | propsRef.value = deepMerge(unref(propsRef) || {}, formProps); |
230 | 239 | } | ... | ... |
src/components/Form/src/props.ts
... | ... | @@ -40,6 +40,7 @@ export const basicProps = { |
40 | 40 | // 在INPUT组件上单击回车时,是否自动提交 |
41 | 41 | autoSubmitOnEnter: propTypes.bool.def(false), |
42 | 42 | submitOnReset: propTypes.bool, |
43 | + submitOnChange: propTypes.bool, | |
43 | 44 | size: propTypes.oneOf(['default', 'small', 'large']).def('default'), |
44 | 45 | // 禁用表单 |
45 | 46 | disabled: propTypes.bool, | ... | ... |
src/components/Form/src/types/form.ts
... | ... | @@ -60,6 +60,8 @@ export interface FormProps { |
60 | 60 | rowProps?: RowProps; |
61 | 61 | // Submit form on reset |
62 | 62 | submitOnReset?: boolean; |
63 | + // Submit form on form changing | |
64 | + submitOnChange?: boolean; | |
63 | 65 | // Col configuration for the entire form |
64 | 66 | labelCol?: Partial<ColEx>; |
65 | 67 | // Col configuration for the entire form | ... | ... |
src/layouts/default/feature/index.vue
... | ... | @@ -23,7 +23,7 @@ |
23 | 23 | const { getUseOpenBackTop, getShowSettingButton, getSettingButtonPosition, getFullContent } = |
24 | 24 | useRootSetting(); |
25 | 25 | const userStore = useUserStoreWithOut(); |
26 | - const { prefixCls } = useDesign('setting-drawer-fearure'); | |
26 | + const { prefixCls } = useDesign('setting-drawer-feature'); | |
27 | 27 | const { getShowHeader } = useHeaderSetting(); |
28 | 28 | |
29 | 29 | const getIsSessionTimeout = computed(() => userStore.getSessionTimeout); |
... | ... | @@ -59,7 +59,7 @@ |
59 | 59 | </template> |
60 | 60 | |
61 | 61 | <style lang="less"> |
62 | - @prefix-cls: ~'@{namespace}-setting-drawer-fearure'; | |
62 | + @prefix-cls: ~'@{namespace}-setting-drawer-feature'; | |
63 | 63 | |
64 | 64 | .@{prefix-cls} { |
65 | 65 | position: absolute; | ... | ... |
src/settings/projectSetting.ts
... | ... | @@ -134,7 +134,7 @@ const setting: ProjectConfig = { |
134 | 134 | // Transition Setting |
135 | 135 | transitionSetting: { |
136 | 136 | // Whether to open the page switching animation |
137 | - // The disabled state will also disable pageLoadinng | |
137 | + // The disabled state will also disable pageLoading | |
138 | 138 | enable: true, |
139 | 139 | |
140 | 140 | // Route basic switching animation | ... | ... |