mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-23 20:00:19 +08:00
fix: 修复Table当dataIndex为数组时,列设置中勾选列是否展示时使column结构异常的问题 (#1626)
This commit is contained in:
parent
573a443007
commit
3d55b0d45b
@ -197,7 +197,7 @@ export function useColumns(
|
||||
* set columns
|
||||
* @param columnList key|column
|
||||
*/
|
||||
function setColumns(columnList: Partial<BasicColumn>[] | string[]) {
|
||||
function setColumns(columnList: Partial<BasicColumn>[] | (string | string[])[]) {
|
||||
const columns = cloneDeep(columnList);
|
||||
if (!isArray(columns)) return;
|
||||
|
||||
@ -210,23 +210,23 @@ export function useColumns(
|
||||
|
||||
const cacheKeys = cacheColumns.map((item) => item.dataIndex);
|
||||
|
||||
if (!isString(firstColumn)) {
|
||||
if (!isString(firstColumn) && !isArray(firstColumn)) {
|
||||
columnsRef.value = columns as BasicColumn[];
|
||||
} else {
|
||||
const columnKeys = columns as string[];
|
||||
const columnKeys = (columns as (string | string[])[]).map(m => m.toString());
|
||||
const newColumns: BasicColumn[] = [];
|
||||
cacheColumns.forEach((item) => {
|
||||
newColumns.push({
|
||||
...item,
|
||||
defaultHidden: !columnKeys.includes(item.dataIndex! || (item.key as string)),
|
||||
defaultHidden: !columnKeys.includes(item.dataIndex?.toString() || (item.key as string))
|
||||
});
|
||||
});
|
||||
// Sort according to another array
|
||||
if (!isEqual(cacheKeys, columns)) {
|
||||
newColumns.sort((prev, next) => {
|
||||
return (
|
||||
columnKeys.indexOf(prev.dataIndex as string) -
|
||||
columnKeys.indexOf(next.dataIndex as string)
|
||||
columnKeys.indexOf(prev.dataIndex?.toString() as string) -
|
||||
columnKeys.indexOf(next.dataIndex?.toString() as string)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user