Browse Source

chore: 表单使用updateSchema时只对更新的schema重设默认值

* fix: 修复搜索表单使用updateSchema时,如果使用fieldMapToTime引起的bug

* fix: set all schema to default value

---------

Co-authored-by: likui628 <90845831+likui628@users.noreply.github.com>
pull/3475/head
zzc0217 3 years ago
committed by GitHub
parent
commit
3de22b44b1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/components/Form/src/hooks/useFormEvents.ts

16
src/components/Form/src/hooks/useFormEvents.ts

@ -284,21 +284,19 @@ export function useFormEvents({
return; return;
} }
const schema: FormSchema[] = []; const schema: FormSchema[] = [];
const updatedSchema: FormSchema[] = [];
unref(getSchema).forEach((val) => { unref(getSchema).forEach((val) => {
let _val; const updatedItem = updateData.find((item) => val.field === item.field);
updateData.forEach((item) => {
if (val.field === item.field) { if (updatedItem) {
_val = item; const newSchema = deepMerge(val, updatedItem);
} updatedSchema.push(newSchema as FormSchema);
});
if (_val !== undefined && val.field === _val.field) {
const newSchema = deepMerge(val, _val);
schema.push(newSchema as FormSchema); schema.push(newSchema as FormSchema);
} else { } else {
schema.push(val); schema.push(val);
} }
}); });
_setDefaultValue(schema); _setDefaultValue(updatedSchema);
schemaRef.value = uniqBy(schema, 'field'); schemaRef.value = uniqBy(schema, 'field');
} }

Loading…
Cancel
Save