no message
parent
e830796e40
commit
0531a03026
|
|
@ -204,25 +204,39 @@ export default {
|
||||||
this.showcolumn();
|
this.showcolumn();
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
//vm.owner.store.commit('insertColumn', columnConfig, newIndex+myindex + 1 , null)
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
showcolumn() {
|
showcolumn() {
|
||||||
const strHidden = sessionStorage.getItem(this.tableKey)
|
try {
|
||||||
this.hiddenColumns = JSON.parse(strHidden);
|
// 从sessionStorage安全地获取并解析hiddenColumns
|
||||||
const table = this.crud.props.table
|
const strHidden = sessionStorage.getItem(this.tableKey)
|
||||||
this.hiddenColumns.forEach((column, index) => {
|
if (strHidden) {
|
||||||
const vm = table.$children.find(e => e.prop === column.property)
|
this.hiddenColumns = JSON.parse(strHidden);
|
||||||
const columnConfig = vm.columnConfig
|
} else {
|
||||||
if (column.visible) {
|
// 如果没有找到相应的存储信息,可以初始化为空数组或相应的默认值
|
||||||
columnConfig.width = column.width
|
this.hiddenColumns = [];
|
||||||
columnConfig.visible = column.visible
|
|
||||||
vm.owner.store.commit('insertColumn', columnConfig, index + 1, null)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
this.updateTableColumns();
|
const table = this.crud.props.table
|
||||||
|
// 优化循环中的条件判断和错误处理
|
||||||
|
this.hiddenColumns.forEach((column, index) => {
|
||||||
|
const vm = table.$children.find(e => e && e.prop === column.property)
|
||||||
|
if (vm) {
|
||||||
|
const columnConfig = vm.columnConfig;
|
||||||
|
// 确保columnConfig存在
|
||||||
|
if (columnConfig) {
|
||||||
|
if (column.visible) {
|
||||||
|
// 仅当列需要显示时,才更新其配置
|
||||||
|
columnConfig.width = column.width;
|
||||||
|
columnConfig.visible = column.visible;
|
||||||
|
vm.owner.store.commit('insertColumn', columnConfig, index + 1, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.updateTableColumns();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("处理列配置时发生错误:", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
//列拖拽
|
//列拖拽
|
||||||
columnDrop() {
|
columnDrop() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue