parent
94c68c966e
commit
fe58af2e78
|
@ -13,13 +13,13 @@ import { toRaw } from 'vue';
|
||||||
import { Store } from '@vben-core/shared/store';
|
import { Store } from '@vben-core/shared/store';
|
||||||
import {
|
import {
|
||||||
bindMethods,
|
bindMethods,
|
||||||
|
createMerge,
|
||||||
isFunction,
|
isFunction,
|
||||||
|
isObject,
|
||||||
mergeWithArrayOverride,
|
mergeWithArrayOverride,
|
||||||
StateHandler,
|
StateHandler,
|
||||||
} from '@vben-core/shared/utils';
|
} from '@vben-core/shared/utils';
|
||||||
|
|
||||||
import { objectPick } from '@vueuse/core';
|
|
||||||
|
|
||||||
function getDefaultState(): VbenFormProps {
|
function getDefaultState(): VbenFormProps {
|
||||||
return {
|
return {
|
||||||
actionWrapperClass: '',
|
actionWrapperClass: '',
|
||||||
|
@ -250,8 +250,17 @@ export class FormApi {
|
||||||
form.setValues(fields, shouldValidate);
|
form.setValues(fields, shouldValidate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fieldNames = this.state?.schema?.map((item) => item.fieldName) ?? [];
|
|
||||||
const filteredFields = objectPick(fields, fieldNames);
|
const fieldMergeFn = createMerge((obj, key, value) => {
|
||||||
|
if (key in obj) {
|
||||||
|
obj[key] =
|
||||||
|
!Array.isArray(obj[key]) && isObject(obj[key])
|
||||||
|
? fieldMergeFn(obj[key], value)
|
||||||
|
: value;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
const filteredFields = fieldMergeFn(fields, form.values);
|
||||||
form.setValues(filteredFields, shouldValidate);
|
form.setValues(filteredFields, shouldValidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue