Commit 2423aeab640b218712717b0329f881f8add654dc
Committed by
GitHub
1 parent
1a431422
fix: 修复表单重置某些input类型组件不生效问题,close #1519 (#1526)
Co-authored-by: bingguo <bingguo@gaoding.com>
Showing
2 changed files
with
6 additions
and
2 deletions
src/components/Form/src/helper.ts
src/components/Form/src/hooks/useFormEvents.ts
... | ... | @@ -4,7 +4,7 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface'; |
4 | 4 | import { unref, toRaw, nextTick } from 'vue'; |
5 | 5 | import { isArray, isFunction, isObject, isString } from '/@/utils/is'; |
6 | 6 | import { deepMerge } from '/@/utils'; |
7 | -import { dateItemType, handleInputNumberValue } from '../helper'; | |
7 | +import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper'; | |
8 | 8 | import { dateUtil } from '/@/utils/dateUtil'; |
9 | 9 | import { cloneDeep, uniqBy } from 'lodash-es'; |
10 | 10 | import { error } from '/@/utils/log'; |
... | ... | @@ -37,7 +37,9 @@ export function useFormEvents({ |
37 | 37 | if (!formEl) return; |
38 | 38 | |
39 | 39 | Object.keys(formModel).forEach((key) => { |
40 | - formModel[key] = defaultValueRef.value[key]; | |
40 | + const schema = unref(getSchema).find((item) => item.field === key); | |
41 | + const isInput = schema?.component && defaultValueComponents.includes(schema.component); | |
42 | + formModel[key] = isInput ? defaultValueRef.value[key] || '' : defaultValueRef.value[key]; | |
41 | 43 | }); |
42 | 44 | nextTick(() => clearValidate()); |
43 | 45 | ... | ... |