fix: 修复动态tab渲染问题

This commit is contained in:
parisma 2023-03-10 12:59:18 +08:00
parent ad293fcd31
commit 67428f606a

View File

@ -15,7 +15,6 @@
:is="uiComponent.component"
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
:name="filter(tab.status) || tabIndex.toString()"
:label="filter(tab.title)"
:lazy="tab.lazy || false"
>
<template #label>
@ -29,8 +28,26 @@
:key="item[mForm?.keyProp || '__key']"
:config="item"
:disabled="disabled"
:model="getValues(model, tabIndex, tab)"
:last-values="getValues(lastValues, tabIndex, tab)"
:model="
config.dynamic
? (name ? model[name] : model)[tabIndex]
: tab.name
? (name ? model[name] : model)[tab.name]
: name
? model[name]
: model
"
:last-values="
isEmpty(lastValues)
? {}
: config.dynamic
? (name ? lastValues[name] : lastValues)[tabIndex]
: tab.name
? (name ? lastValues[name] : lastValues)[tab.name]
: name
? lastValues[name]
: lastValues
"
:is-compare="isCompare"
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
:size="size"
@ -46,7 +63,7 @@
<script setup lang="ts" name="MFormTabs">
import { computed, inject, ref, watchEffect } from 'vue';
import { cloneDeep } from 'lodash-es';
import { cloneDeep, isEmpty } from 'lodash-es';
import { getConfig, TMagicTabs } from '@tmagic/design';
@ -185,18 +202,6 @@ const changeHandler = () => {
}
};
const getValues = (model: any, tabIndex: number, tab: any) => {
const tabName = props.config.dynamic ? (model[props?.name] || model)[tabIndex] : tab.name;
let propName = props.name;
if (tabName) {
propName = (model[props?.name] || model)[tab.name];
}
if (propName) {
return model[props.name];
}
return model;
};
// tabstab
const onAddDiffCount = (tabIndex: number) => {
if (!diffCount.value[tabIndex]) {