fix: grid tools in toolbar config not working as expected (#5190)

dev-v5^2
Netfan 2024-12-19 21:34:47 +08:00 committed by GitHub
parent acd87b2250
commit a44ff73dd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import type {
VxeGridListeners,
VxeGridPropTypes,
VxeGridProps as VxeTableGridProps,
VxeToolbarPropTypes,
} from 'vxe-table';
import type { ExtendedVxeGridApi, VxeGridProps } from './types';
@ -107,28 +108,28 @@ const showToolbar = computed(() => {
const toolbarOptions = computed(() => {
const slotActions = slots[TOOLBAR_ACTIONS]?.();
const slotTools = slots[TOOLBAR_TOOLS]?.();
const toolbarConfig: VxeGridPropTypes.ToolbarConfig = {
tools:
gridOptions.value?.toolbarConfig?.search && !!formOptions.value
? [
{
code: 'search',
icon: 'vxe-icon--search',
circle: true,
status: showSearchForm.value ? 'primary' : undefined,
title: $t('common.search'),
},
]
: [],
const searchBtn: VxeToolbarPropTypes.ToolConfig = {
code: 'search',
icon: 'vxe-icon--search',
circle: true,
status: showSearchForm.value ? 'primary' : undefined,
title: $t('common.search'),
};
// toolbarConfig.tools
const toolbarConfig: VxeGridPropTypes.ToolbarConfig = {
tools: (gridOptions.value?.toolbarConfig?.tools ??
[]) as VxeToolbarPropTypes.ToolConfig[],
};
if (gridOptions.value?.toolbarConfig?.search && !!formOptions.value) {
toolbarConfig.tools = Array.isArray(toolbarConfig.tools)
? [...toolbarConfig.tools, searchBtn]
: [searchBtn];
}
if (!showToolbar.value) {
return { toolbarConfig };
}
// if (gridOptions.value?.toolbarConfig?.search) {
// }
// 使toolbar
//
toolbarConfig.slots = {
@ -137,7 +138,6 @@ const toolbarOptions = computed(() => {
: {}),
...(slotTools ? { tools: TOOLBAR_TOOLS } : {}),
};
return { toolbarConfig };
});
@ -147,7 +147,7 @@ const options = computed(() => {
const mergedOptions: VxeTableGridProps = cloneDeep(
mergeWithArrayOverride(
{},
toolbarOptions.value,
toRaw(toolbarOptions.value),
toRaw(gridOptions.value),
globalGridConfig,
),