mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-25 09:49:57 +08:00
fix(form): tabs配置name后出错
This commit is contained in:
parent
26c60c316a
commit
9454bb3679
@ -21,7 +21,15 @@
|
|||||||
v-for="item in tabItems(tab)"
|
v-for="item in tabItems(tab)"
|
||||||
:key="item[mForm?.keyProp || '__key']"
|
:key="item[mForm?.keyProp || '__key']"
|
||||||
:config="item"
|
:config="item"
|
||||||
:model="config.dynamic ? model[config.name || ''][tabIndex] : tab.name ? model[tab.name] : model"
|
:model="
|
||||||
|
config.dynamic
|
||||||
|
? (name ? model[name] : model)[tabIndex]
|
||||||
|
: tab.name
|
||||||
|
? (name ? model[name] : model)[tab.name]
|
||||||
|
: name
|
||||||
|
? model[name]
|
||||||
|
: model
|
||||||
|
"
|
||||||
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
:prop="config.dynamic ? `${prop}${prop ? '.' : ''}${String(tabIndex)}` : prop"
|
||||||
:size="size"
|
:size="size"
|
||||||
:label-width="tab.labelWidth || labelWidth"
|
:label-width="tab.labelWidth || labelWidth"
|
||||||
@ -34,7 +42,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
/* eslint-disable vue/no-mutating-props */
|
|
||||||
import { computed, defineComponent, inject, PropType, ref, watchEffect } from 'vue';
|
import { computed, defineComponent, inject, PropType, ref, watchEffect } from 'vue';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
@ -87,6 +94,8 @@ const Tab = defineComponent({
|
|||||||
|
|
||||||
prop: String,
|
prop: String,
|
||||||
|
|
||||||
|
name: String,
|
||||||
|
|
||||||
size: String,
|
size: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -515,6 +515,7 @@ export interface TabPaneConfig {
|
|||||||
lazy?: boolean;
|
lazy?: boolean;
|
||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
items: FormConfig;
|
items: FormConfig;
|
||||||
|
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
||||||
@ -527,6 +528,7 @@ export interface TabConfig extends FormItem, ContainerCommonConfig {
|
|||||||
onChange?: (mForm: FormState | undefined, data: any) => void;
|
onChange?: (mForm: FormState | undefined, data: any) => void;
|
||||||
onTabAdd?: (mForm: FormState | undefined, data: any) => void;
|
onTabAdd?: (mForm: FormState | undefined, data: any) => void;
|
||||||
onTabRemove?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
onTabRemove?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
||||||
|
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
|
||||||
activeChange?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
activeChange?: (mForm: FormState | undefined, tabName: string, data: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,16 +53,7 @@ const asyncLoadConfig = (value: FormValue, initValue: FormValue, { asyncLoad, na
|
|||||||
|
|
||||||
const isMultipleValue = (type?: string | TypeFunction) =>
|
const isMultipleValue = (type?: string | TypeFunction) =>
|
||||||
typeof type === 'string' &&
|
typeof type === 'string' &&
|
||||||
[
|
['checkbox-group', 'checkboxGroup', 'table', 'cascader', 'group-list', 'groupList'].includes(type);
|
||||||
'checkbox-group',
|
|
||||||
'checkboxGroup',
|
|
||||||
'table',
|
|
||||||
'cascader',
|
|
||||||
'group-list',
|
|
||||||
'groupList',
|
|
||||||
'dynamic-tab',
|
|
||||||
'dynamicTab',
|
|
||||||
].includes(type);
|
|
||||||
|
|
||||||
const initItemsValue = (
|
const initItemsValue = (
|
||||||
mForm: FormState | undefined,
|
mForm: FormState | undefined,
|
||||||
@ -83,7 +74,7 @@ const initItemsValue = (
|
|||||||
const setValue = (mForm: FormState | undefined, value: FormValue, initValue: FormValue, item: any) => {
|
const setValue = (mForm: FormState | undefined, value: FormValue, initValue: FormValue, item: any) => {
|
||||||
const { items, name, type, checkbox } = item;
|
const { items, name, type, checkbox } = item;
|
||||||
// 值是数组, 有可能也有items配置,所以不能放到getDefaultValue里赋值
|
// 值是数组, 有可能也有items配置,所以不能放到getDefaultValue里赋值
|
||||||
if (isMultipleValue(type)) {
|
if (isMultipleValue(type) || (type === 'tab' && item.dynamic)) {
|
||||||
value[name] = initValue[name] || [];
|
value[name] = initValue[name] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user