|
@ -52,26 +52,56 @@ export const mixins = { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
// 结合默认及缓存中的列表tableColumns数据做初始化
|
|
|
initTableColumns(){ |
|
|
initTableColumns(){ |
|
|
let _local = localStorage.getItem(this.$store.getters.name.userName + '_' + this.$route.name) |
|
|
let _local = localStorage.getItem(this.$store.getters.name.userName + '_' + this.$route.name) |
|
|
let _list_local = JSON.parse(localStorage.getItem(this.$store.getters.name.userName + '_' + this.$route.name)) |
|
|
let _list_local = JSON.parse(localStorage.getItem(this.$store.getters.name.userName + '_' + this.$route.name)) |
|
|
let _list_defalut = this.$isTableColumns[this.$route.name] |
|
|
let _list_defalut = this.$isTableColumns[this.$route.name] |
|
|
let _new_list = [] //格式化后的数据
|
|
|
let _new_list = [] //格式化后的数据
|
|
|
|
|
|
// 如果没有缓存则直接为默认值
|
|
|
if(!_local){ |
|
|
if(!_local){ |
|
|
_new_list = _list_defalut |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 如果默认中已经删除掉的,本地中缓存中也不显示,新增字段,缓存中也显示(默认为眼睛关闭)
|
|
|
|
|
|
_list_defalut.forEach((defalutItem,index) => { |
|
|
_list_defalut.forEach((defalutItem,index) => { |
|
|
defalutItem.isture = false |
|
|
defalutItem.isture = true |
|
|
_new_list.push(defalutItem) |
|
|
_new_list.push(defalutItem) |
|
|
_list_local.forEach(localItem => { |
|
|
}) |
|
|
if(!defalutItem.showProp && defalutItem.prop == localItem.prop){ |
|
|
} |
|
|
_new_list[index].isture = localItem.isture |
|
|
// 如果有缓存:默认中已经删除掉的,本地中缓存中也不显示,新增字段,缓存中也显示(默认为眼睛关闭)
|
|
|
}else if(defalutItem.showProp && defalutItem.showProp == localItem.showProp){ |
|
|
else{ |
|
|
_new_list[index].isture = localItem.isture |
|
|
// 先处理缓存数据,设置索引
|
|
|
} |
|
|
let _locals = {} |
|
|
}); |
|
|
_list_local.forEach((localItem,index) => { |
|
|
}); |
|
|
localItem.itemIndex = index |
|
|
|
|
|
if(localItem.showProp && typeof localItem.showProp == 'string'){ |
|
|
|
|
|
_locals[localItem.showProp] = localItem |
|
|
|
|
|
}else{ |
|
|
|
|
|
_locals[localItem.prop] = localItem |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
// 将缓存与默认设置合并,索引同步
|
|
|
|
|
|
let _number = 0 |
|
|
|
|
|
_list_defalut.forEach((defalutItem) => { |
|
|
|
|
|
if(_locals[defalutItem.showProp]){ |
|
|
|
|
|
defalutItem.isture = _locals[defalutItem.showProp].isture |
|
|
|
|
|
defalutItem.itemIndex = _locals[defalutItem.showProp].itemIndex |
|
|
|
|
|
}else if(_locals[defalutItem.prop]){ |
|
|
|
|
|
defalutItem.isture = _locals[defalutItem.prop].isture |
|
|
|
|
|
defalutItem.itemIndex = _locals[defalutItem.prop].itemIndex |
|
|
|
|
|
}else{ |
|
|
|
|
|
defalutItem.isture = false |
|
|
|
|
|
defalutItem.itemIndex = _number |
|
|
|
|
|
} |
|
|
|
|
|
_number ++ |
|
|
|
|
|
_new_list.push(defalutItem) |
|
|
|
|
|
}) |
|
|
|
|
|
// 按索引排序
|
|
|
|
|
|
function compare(property) { |
|
|
|
|
|
return function (a, b) { |
|
|
|
|
|
var value1 = a[property]; |
|
|
|
|
|
var value2 = b[property]; |
|
|
|
|
|
return value1 - value2; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
_new_list.sort(compare("itemIndex")) |
|
|
} |
|
|
} |
|
|
return _new_list |
|
|
return _new_list |
|
|
}, |
|
|
}, |
|
|