mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-18 03:05:11 +08:00
fix: 修复动态tab渲染问题
This commit is contained in:
parent
ad293fcd31
commit
67428f606a
@ -15,7 +15,6 @@
|
|||||||
:is="uiComponent.component"
|
:is="uiComponent.component"
|
||||||
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
|
:key="tab[mForm?.keyProp || '__key'] ?? tabIndex"
|
||||||
:name="filter(tab.status) || tabIndex.toString()"
|
:name="filter(tab.status) || tabIndex.toString()"
|
||||||
:label="filter(tab.title)"
|
|
||||||
:lazy="tab.lazy || false"
|
:lazy="tab.lazy || false"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
@ -29,8 +28,26 @@
|
|||||||
:key="item[mForm?.keyProp || '__key']"
|
:key="item[mForm?.keyProp || '__key']"
|
||||||
:config="item"
|
:config="item"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:model="getValues(model, tabIndex, tab)"
|
:model="
|
||||||
:last-values="getValues(lastValues, tabIndex, tab)"
|
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"
|
:is-compare="isCompare"
|
||||||
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
||||||
:size="size"
|
:size="size"
|
||||||
@ -46,7 +63,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts" name="MFormTabs">
|
<script setup lang="ts" name="MFormTabs">
|
||||||
import { computed, inject, ref, watchEffect } from 'vue';
|
import { computed, inject, ref, watchEffect } from 'vue';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep, isEmpty } from 'lodash-es';
|
||||||
|
|
||||||
import { getConfig, TMagicTabs } from '@tmagic/design';
|
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 在tabs组件中收集事件触发次数,即该tab下的差异数
|
// 在tabs组件中收集事件触发次数,即该tab下的差异数
|
||||||
const onAddDiffCount = (tabIndex: number) => {
|
const onAddDiffCount = (tabIndex: number) => {
|
||||||
if (!diffCount.value[tabIndex]) {
|
if (!diffCount.value[tabIndex]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user