fix: column setting index column sort (#3463)

* fix: keep rowSelection onChange call outside

* fix: ColumnSetting index column sort wrong
This commit is contained in:
xachary
2023-12-26 20:41:03 +08:00
committed by GitHub
parent 141f3bdbd0
commit fc002d3db3

View File

@@ -113,6 +113,7 @@
import { getPopupContainer as getParentContainer } from '@/utils';
import { cloneDeep, omit } from 'lodash-es';
import Sortablejs from 'sortablejs';
import { INDEX_COLUMN_FLAG } from '@/components/Table/src/const';
// 列表设置缓存
import { useTableSettingStore } from '@/store/modules/tableSetting';
@@ -210,22 +211,6 @@
showIndexColumnUpdate(e.target.checked);
// 更新 showIndexColumn 缓存
props.cache && tableSettingStore.setShowIndexColumn(e.target.checked);
// 从无到有需要处理
if (e.target.checked) {
const columns = cloneDeep(table?.getColumns());
const idx = columns.findIndex((o) => o.flag === 'INDEX');
// 找到序号列
if (idx > -1) {
const cache = columns[idx];
// 强制左fix
cache.fixed = 'left';
// 强制移动到 第一/选择列后
columns.splice(idx, 1);
columns.splice(0, 0, cache);
// 设置列表列
tableColumnsSet(columns);
}
}
};
// 是否显示选择列
@@ -340,8 +325,15 @@
// 考虑了所有列
const columns = cloneDeep(table.getColumns());
// 从左 fixed 最一列开始排序
let count = columns.filter((o) => o.fixed === 'left' || o.fixed === true).length;
// 从左 fixed 最一列开始排序(除了 序号列)
let count = columns.filter(
(o) => o.flag !== INDEX_COLUMN_FLAG && (o.fixed === 'left' || o.fixed === true),
).length;
// 序号列提前
if (isIndexColumnShow.value) {
count++;
}
// 按 columnOptions 的排序 调整 table.getColumns() 的顺序和值
for (const opt of columnOptions.value) {