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)"
|
||||
:key="item[mForm?.keyProp || '__key']"
|
||||
: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"
|
||||
:size="size"
|
||||
:label-width="tab.labelWidth || labelWidth"
|
||||
@ -34,7 +42,6 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/* eslint-disable vue/no-mutating-props */
|
||||
import { computed, defineComponent, inject, PropType, ref, watchEffect } from 'vue';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
@ -87,6 +94,8 @@ const Tab = defineComponent({
|
||||
|
||||
prop: String,
|
||||
|
||||
name: String,
|
||||
|
||||
size: String,
|
||||
},
|
||||
|
||||
|
@ -515,6 +515,7 @@ export interface TabPaneConfig {
|
||||
lazy?: boolean;
|
||||
labelWidth?: string;
|
||||
items: FormConfig;
|
||||
onTabClick?: (mForm: FormState | undefined, tab: any, data: any) => void;
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
||||
@ -527,6 +528,7 @@ export interface TabConfig extends FormItem, ContainerCommonConfig {
|
||||
onChange?: (mForm: FormState | undefined, data: any) => void;
|
||||
onTabAdd?: (mForm: FormState | undefined, 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;
|
||||
}
|
||||
|
||||
|
@ -53,16 +53,7 @@ const asyncLoadConfig = (value: FormValue, initValue: FormValue, { asyncLoad, na
|
||||
|
||||
const isMultipleValue = (type?: string | TypeFunction) =>
|
||||
typeof type === 'string' &&
|
||||
[
|
||||
'checkbox-group',
|
||||
'checkboxGroup',
|
||||
'table',
|
||||
'cascader',
|
||||
'group-list',
|
||||
'groupList',
|
||||
'dynamic-tab',
|
||||
'dynamicTab',
|
||||
].includes(type);
|
||||
['checkbox-group', 'checkboxGroup', 'table', 'cascader', 'group-list', 'groupList'].includes(type);
|
||||
|
||||
const initItemsValue = (
|
||||
mForm: FormState | undefined,
|
||||
@ -83,7 +74,7 @@ const initItemsValue = (
|
||||
const setValue = (mForm: FormState | undefined, value: FormValue, initValue: FormValue, item: any) => {
|
||||
const { items, name, type, checkbox } = item;
|
||||
// 值是数组, 有可能也有items配置,所以不能放到getDefaultValue里赋值
|
||||
if (isMultipleValue(type)) {
|
||||
if (isMultipleValue(type) || (type === 'tab' && item.dynamic)) {
|
||||
value[name] = initValue[name] || [];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user