mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:31:41 +08:00
fix(table): fix the problem that multi-level header configuration does not take effect
This commit is contained in:
@@ -23,18 +23,11 @@ export function useColumns(
|
||||
}
|
||||
let pushIndexColumns = false;
|
||||
columns.forEach((item) => {
|
||||
const { key, dataIndex } = item;
|
||||
item.align = item.align || 'center';
|
||||
if (ellipsis) {
|
||||
if (!key) {
|
||||
item.key = dataIndex;
|
||||
}
|
||||
if (!isBoolean(item.ellipsis)) {
|
||||
Object.assign(item, {
|
||||
ellipsis,
|
||||
});
|
||||
}
|
||||
}
|
||||
const { children } = item;
|
||||
handleItem(item, !!ellipsis);
|
||||
|
||||
handleChildren(children, !!ellipsis);
|
||||
|
||||
const indIndex = columns.findIndex((column) => column.flag === 'INDEX');
|
||||
if (showIndexColumn && !isTreeTable) {
|
||||
pushIndexColumns = indIndex === -1;
|
||||
@@ -88,6 +81,30 @@ export function useColumns(
|
||||
cacheColumnsRef.value = columns;
|
||||
});
|
||||
|
||||
function handleItem(item: BasicColumn, ellipsis: boolean) {
|
||||
const { key, dataIndex } = item;
|
||||
item.align = item.align || 'center';
|
||||
if (ellipsis) {
|
||||
if (!key) {
|
||||
item.key = dataIndex;
|
||||
}
|
||||
if (!isBoolean(item.ellipsis)) {
|
||||
Object.assign(item, {
|
||||
ellipsis,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleChildren(children: BasicColumn[] | undefined, ellipsis: boolean) {
|
||||
if (!children) return;
|
||||
children.forEach((item) => {
|
||||
const { children } = item;
|
||||
handleItem(item, ellipsis);
|
||||
handleChildren(children, ellipsis);
|
||||
});
|
||||
}
|
||||
|
||||
function setColumns(columns: BasicColumn[] | string[]) {
|
||||
if (!isArray(columns)) return;
|
||||
|
||||
|
Reference in New Issue
Block a user