Browse Source

修复 updateSchema 多个field 属性时,第二个无效问题

pull/768/head
cKey 3 years ago
parent
commit
edc2091acc
  1. 16
      apps/vue/src/components/Form/src/hooks/useFormEvents.ts
  2. 6
      apps/vue/src/layouts/page/index.vue
  3. 2
      apps/vue/src/utils/index.ts

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

@ -227,15 +227,19 @@ export function useFormEvents({
return; return;
} }
const schema: FormSchema[] = []; const schema: FormSchema[] = [];
updateData.forEach((item) => { unref(getSchema).forEach((val) => {
unref(getSchema).forEach((val) => { let _val;
updateData.forEach((item) => {
if (val.field === item.field) { if (val.field === item.field) {
const newSchema = deepMerge(val, item); _val = item;
schema.push(newSchema as FormSchema);
} else {
schema.push(val);
} }
}); });
if (_val !== undefined && val.field === _val.field) {
const newSchema = deepMerge(val, _val);
schema.push(newSchema as FormSchema);
} else {
schema.push(val);
}
}); });
_setDefaultValue(schema); _setDefaultValue(schema);

6
apps/vue/src/layouts/page/index.vue

@ -15,9 +15,11 @@
appear appear
> >
<keep-alive v-if="openCache" :include="getCaches"> <keep-alive v-if="openCache" :include="getCaches">
<component :is="Component" :key="route.fullPath" /> <div :key="route.name!">
<component :is="Component" :key="route.fullPath" />
</div>
</keep-alive> </keep-alive>
<div v-else :key="route.name"> <div v-else :key="route.name!">
<component :is="Component" :key="route.fullPath" /> <component :is="Component" :key="route.fullPath" />
</div> </div>
</transition> </transition>

2
apps/vue/src/utils/index.ts

@ -35,7 +35,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string {
export function deepMerge<T = any>(src: any = {}, target: any = {}): T { export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
let key: string; let key: string;
const res: any = cloneDeep(src) const res: any = cloneDeep(src);
for (key in target) { for (key in target) {
res[key] = isObject(res[key]) ? deepMerge(res[key], target[key]) : (res[key] = target[key]); res[key] = isObject(res[key]) ? deepMerge(res[key], target[key]) : (res[key] = target[key]);
} }

Loading…
Cancel
Save