fix: 修复表单重置某些input类型组件不生效问题,close #1519 (#1526)

Co-authored-by: bingguo <bingguo@gaoding.com>
This commit is contained in:
wangxiaoer5200 2021-12-28 18:46:17 +08:00 committed by GitHub
parent 1a43142252
commit 2423aeab64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -70,3 +70,5 @@ export function handleInputNumberValue(component?: ComponentType, val?: any) {
*
*/
export const dateItemType = genType();
export const defaultValueComponents = ['Input', 'InputPassword', 'InputSearch', 'InputTextArea'];

View File

@ -4,7 +4,7 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue';
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import { deepMerge } from '/@/utils';
import { dateItemType, handleInputNumberValue } from '../helper';
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
import { dateUtil } from '/@/utils/dateUtil';
import { cloneDeep, uniqBy } from 'lodash-es';
import { error } from '/@/utils/log';
@ -37,7 +37,9 @@ export function useFormEvents({
if (!formEl) return;
Object.keys(formModel).forEach((key) => {
formModel[key] = defaultValueRef.value[key];
const schema = unref(getSchema).find((item) => item.field === key);
const isInput = schema?.component && defaultValueComponents.includes(schema.component);
formModel[key] = isInput ? defaultValueRef.value[key] || '' : defaultValueRef.value[key];
});
nextTick(() => clearValidate());