|
@@ -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)
|
|
|
);
|
|
|
});
|
|
|
}
|