zzc0217
2023-12-27 3de22b44b15e3fb430e1fc1e4ba3e08fb20fbc02
chore: 表单使用updateSchema时只对更新的schema重设默认值

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

* fix: set all schema to default value

---------

Co-authored-by: likui628 <90845831+likui628@users.noreply.github.com>
1个文件已修改
16 ■■■■■ 已修改文件
src/components/Form/src/hooks/useFormEvents.ts 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Form/src/hooks/useFormEvents.ts
@@ -284,21 +284,19 @@
      return;
    }
    const schema: FormSchema[] = [];
    const updatedSchema: FormSchema[] = [];
    unref(getSchema).forEach((val) => {
      let _val;
      updateData.forEach((item) => {
        if (val.field === item.field) {
          _val = item;
        }
      });
      if (_val !== undefined && val.field === _val.field) {
        const newSchema = deepMerge(val, _val);
      const updatedItem = updateData.find((item) => val.field === item.field);
      if (updatedItem) {
        const newSchema = deepMerge(val, updatedItem);
        updatedSchema.push(newSchema as FormSchema);
        schema.push(newSchema as FormSchema);
      } else {
        schema.push(val);
      }
    });
    _setDefaultValue(schema);
    _setDefaultValue(updatedSchema);
    schemaRef.value = uniqBy(schema, 'field');
  }