在这里插入代码片
//缓存orderColumn
let cacheColumn = sessionStorage.getItem(‘column’)
cacheColumn = cacheColumn ? JSON.parse(sessionStorage.getItem(‘column’)) : {}
let router = this.KaTeX parse error: Expected 'EOF', got '&' at position 542: …(storageColumn &̲& Object.keys(s…route.path
let tbName = this.tableName
if (Object.keys(storageColumn).includes(router) && Object.keys(storageColumn[router]).includes(tbName)) {
let cls = this.newColumn
let scls = storageColumn[router][tbName]
let newItem = []
let param = {}
scls.forEach((item, index) => {
if (item.property && cls[index] && cls[index].field) {
if (!newItem.includes(item.property) && !newItem.includes(cls[index].field)) {
if (item.property != cls[index].field) {
param[cls[index].field] = {}
param[cls[index].field].oldIndex = cls.indexOf(cls[index])
newItem.push(cls[index].field)
newItem.push(item.property)
}
} else if (newItem.includes(item.property)) {
newItem.push(cls[index].field)
param[item.property].newIndex = index
}
}
})
Object.keys(param).forEach((item) => {
const currRow = this.newColumn.splice(param[item].oldIndex, 1)[0]
this.newColumn.splice(param[item].newIndex, 0, currRow)
})
}
}
columns: { deep: true, immediate: true, handler(n, o) { this.newColumn = n }, },
menuClicks(columnData) { let visibleCls = sessionStorage.getItem('visibleColumn') visibleCls = visibleCls ? JSON.parse(sessionStorage.getItem('visibleColumn')) : {} let router = this.$route.path let tbName = this.tableName if (!Object.keys(visibleCls).includes(router)) { visibleCls[router] = {} } if (!visibleCls[router][tbName]) { visibleCls[router][tbName] = [] if (columnData.columnIndex != undefined && columnData.menu.code === 'HIDDEN_COLUMN') { visibleCls[router][tbName].push(columnData.columnIndex) }else { visibleCls[router][tbName] = [] } } else { if (columnData.columnIndex != undefined && columnData.menu.code === 'HIDDEN_COLUMN') { visibleCls[router][tbName].push(columnData.columnIndex) } else { visibleCls[router][tbName] = [] } } sessionStorage.setItem('visibleColumn', JSON.stringify(visibleCls)) this.visibleColumn() },
visibleColumn() { let _this = this //visibleColumn let visibleColumn = sessionStorage.getItem('visibleColumn') ? JSON.parse(sessionStorage.getItem('visibleColumn')) : undefined if (visibleColumn && Object.keys(visibleColumn).length > 0) { let router = _this.$route.path let tbName = _this.tableName if (Object.keys(visibleColumn).includes(router) && Object.keys(visibleColumn[router]).includes(tbName)) { let vcls = visibleColumn[router][tbName] _this.myColumns.forEach((item, index) => { if (vcls.includes(index)) { item.visible = false } else if (this.newColumn[index].visible != false) { item.visible = true } }) _this.$nextTick(() => { _this.$refs.xGrid.loadColumn(_this.myColumns) _this.$refs.xGrid.refreshColumn() }) } } },
this.visibleColumn()
:custom-config=“{ storage: false }”
@menu-click=“menuClicks”
拉娇娇娇娇娇娇娇娇
于 2023-03-01 16:41:31 首次发布