mirror of https://github.com/jeecgboot/jeecg-boot
【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
parent
c22fd21233
commit
7d7fde63ec
|
@ -188,7 +188,7 @@
|
||||||
const sortableOrder = ref<string[]>();
|
const sortableOrder = ref<string[]>();
|
||||||
const localeStore = useLocaleStoreWithOut();
|
const localeStore = useLocaleStoreWithOut();
|
||||||
// 列表字段配置缓存
|
// 列表字段配置缓存
|
||||||
const { saveSetting, resetSetting } = useColumnsCache(
|
const { saveSetting, resetSetting, getCache } = useColumnsCache(
|
||||||
{
|
{
|
||||||
state,
|
state,
|
||||||
popoverVisible,
|
popoverVisible,
|
||||||
|
@ -204,8 +204,7 @@
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const columns = table.getColumns();
|
if (!state.isInit) {
|
||||||
if (columns.length && !state.isInit) {
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -227,7 +226,13 @@
|
||||||
|
|
||||||
function getColumns() {
|
function getColumns() {
|
||||||
const ret: Options[] = [];
|
const ret: Options[] = [];
|
||||||
table.getColumns({ ignoreIndex: true, ignoreAction: true }).forEach((item) => {
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
let t = table.getColumns({ ignoreIndex: true, ignoreAction: true });
|
||||||
|
if (!t.length) {
|
||||||
|
t = table.getCacheColumns();
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
t.forEach((item) => {
|
||||||
ret.push({
|
ret.push({
|
||||||
label: (item.title as string) || (item.customTitle as string),
|
label: (item.title as string) || (item.customTitle as string),
|
||||||
value: (item.dataIndex || item.title) as string,
|
value: (item.dataIndex || item.title) as string,
|
||||||
|
@ -237,7 +242,7 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
async function init() {
|
||||||
const columns = getColumns();
|
const columns = getColumns();
|
||||||
|
|
||||||
const checkList = table
|
const checkList = table
|
||||||
|
@ -249,11 +254,22 @@
|
||||||
return item.dataIndex || item.title;
|
return item.dataIndex || item.title;
|
||||||
})
|
})
|
||||||
.filter(Boolean) as string[];
|
.filter(Boolean) as string[];
|
||||||
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
const { sortedList = [] } = getCache() || {};
|
||||||
|
await nextTick();
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
if (!plainOptions.value.length) {
|
if (!plainOptions.value.length) {
|
||||||
plainOptions.value = columns;
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
plainSortOptions.value = columns;
|
let tmp = columns;
|
||||||
cachePlainOptions.value = columns;
|
if (sortedList?.length) {
|
||||||
|
tmp = columns.sort((prev, next) => {
|
||||||
|
return sortedList.indexOf(prev.value) - sortedList.indexOf(next.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
plainOptions.value = tmp;
|
||||||
|
plainSortOptions.value = tmp;
|
||||||
|
cachePlainOptions.value = tmp;
|
||||||
state.defaultCheckList = checkList;
|
state.defaultCheckList = checkList;
|
||||||
} else {
|
} else {
|
||||||
// const fixedColumns = columns.filter((item) =>
|
// const fixedColumns = columns.filter((item) =>
|
||||||
|
@ -266,6 +282,13 @@
|
||||||
item.fixed = findItem.fixed;
|
item.fixed = findItem.fixed;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// update-begin--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
|
if (sortedList?.length) {
|
||||||
|
plainOptions.value.sort((prev, next) => {
|
||||||
|
return sortedList.indexOf(prev.value) - sortedList.indexOf(next.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// update-end--author:liaozhiyang---date:20250403---for:【issues/7996】表格列组件取消所有或者只勾选中间,显示非预期
|
||||||
}
|
}
|
||||||
state.isInit = true;
|
state.isInit = true;
|
||||||
state.checkedList = checkList;
|
state.checkedList = checkList;
|
||||||
|
|
|
@ -144,5 +144,6 @@ export function useColumnsCache(opt, setColumns, handleColumnFixed) {
|
||||||
return {
|
return {
|
||||||
saveSetting,
|
saveSetting,
|
||||||
resetSetting,
|
resetSetting,
|
||||||
|
getCache: () => $ls.get(cacheKey.value),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue