Browse Source
fix(BasicTable): showIndexColumn/showRowSelection cache should by route name (#3489)
pull/3496/head
xachary
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
36 additions and
16 deletions
-
src/components/Table/src/components/settings/ColumnSetting.vue
-
src/store/modules/tableSetting.ts
-
types/store.d.ts
|
|
|
@ -210,7 +210,9 @@ |
|
|
|
// 更新 showIndexColumn |
|
|
|
showIndexColumnUpdate(e.target.checked); |
|
|
|
// 更新 showIndexColumn 缓存 |
|
|
|
props.cache && tableSettingStore.setShowIndexColumn(e.target.checked); |
|
|
|
props.cache && |
|
|
|
typeof route.name === 'string' && |
|
|
|
tableSettingStore.setShowIndexColumn(route.name, e.target.checked); |
|
|
|
}; |
|
|
|
|
|
|
|
// 是否显示选择列 |
|
|
|
@ -220,7 +222,9 @@ |
|
|
|
// 更新 showRowSelection |
|
|
|
showRowSelectionUpdate(e.target.checked); |
|
|
|
// 更新 showRowSelection 缓存 |
|
|
|
props.cache && tableSettingStore.setShowRowSelection(e.target.checked); |
|
|
|
props.cache && |
|
|
|
typeof route.name === 'string' && |
|
|
|
tableSettingStore.setShowRowSelection(route.name, e.target.checked); |
|
|
|
}; |
|
|
|
|
|
|
|
// 更新列缓存 |
|
|
|
@ -435,12 +439,18 @@ |
|
|
|
|
|
|
|
// 从缓存恢复 |
|
|
|
const restore = () => { |
|
|
|
// 设置过才恢复 |
|
|
|
if (typeof tableSettingStore.getShowIndexColumn === 'boolean') { |
|
|
|
isIndexColumnShow.value = defaultIsIndexColumnShow && tableSettingStore.getShowIndexColumn; |
|
|
|
} |
|
|
|
if (typeof tableSettingStore.getShowRowSelection === 'boolean') { |
|
|
|
isRowSelectionShow.value = defaultIsRowSelectionShow && tableSettingStore.getShowRowSelection; |
|
|
|
if (typeof route.name === 'string') { |
|
|
|
const isIndexColumnShowCache = tableSettingStore.getShowIndexColumn(route.name); |
|
|
|
// 设置过才恢复 |
|
|
|
if (typeof isIndexColumnShowCache === 'boolean') { |
|
|
|
isIndexColumnShow.value = defaultIsIndexColumnShow && isIndexColumnShowCache; |
|
|
|
} |
|
|
|
|
|
|
|
const isRowSelectionShowCache = tableSettingStore.getShowRowSelection(route.name); |
|
|
|
// 设置过才恢复 |
|
|
|
if (typeof isRowSelectionShowCache === 'boolean') { |
|
|
|
isRowSelectionShow.value = defaultIsRowSelectionShow && isRowSelectionShowCache; |
|
|
|
} |
|
|
|
} |
|
|
|
// 序号列更新 |
|
|
|
onIndexColumnShowChange({ |
|
|
|
|
|
|
|
@ -26,11 +26,15 @@ export const useTableSettingStore = defineStore({ |
|
|
|
}, |
|
|
|
//
|
|
|
|
getShowIndexColumn(state) { |
|
|
|
return state.setting?.showIndexColumn; |
|
|
|
return (routerName: string) => { |
|
|
|
return state.setting?.showIndexColumn?.[routerName]; |
|
|
|
}; |
|
|
|
}, |
|
|
|
//
|
|
|
|
getShowRowSelection(state) { |
|
|
|
return state.setting?.showRowSelection; |
|
|
|
return (routerName: string) => { |
|
|
|
return state.setting?.showRowSelection?.[routerName]; |
|
|
|
}; |
|
|
|
}, |
|
|
|
//
|
|
|
|
getColumns(state) { |
|
|
|
@ -59,18 +63,24 @@ export const useTableSettingStore = defineStore({ |
|
|
|
); |
|
|
|
}, |
|
|
|
//
|
|
|
|
setShowIndexColumn(show: boolean) { |
|
|
|
setShowIndexColumn(routerName: string, show: boolean) { |
|
|
|
this.setTableSetting( |
|
|
|
Object.assign({}, this.setting, { |
|
|
|
showIndexColumn: show, |
|
|
|
showIndexColumn: { |
|
|
|
...this.setting?.showIndexColumn, |
|
|
|
[routerName]: show, |
|
|
|
}, |
|
|
|
}), |
|
|
|
); |
|
|
|
}, |
|
|
|
//
|
|
|
|
setShowRowSelection(show: boolean) { |
|
|
|
setShowRowSelection(routerName: string, show: boolean) { |
|
|
|
this.setTableSetting( |
|
|
|
Object.assign({}, this.setting, { |
|
|
|
showRowSelection: show, |
|
|
|
showRowSelection: { |
|
|
|
...this.setting?.showRowSelection, |
|
|
|
[routerName]: show, |
|
|
|
}, |
|
|
|
}), |
|
|
|
); |
|
|
|
}, |
|
|
|
|
|
|
|
@ -54,7 +54,7 @@ export interface BeforeMiniState { |
|
|
|
|
|
|
|
export interface TableSetting { |
|
|
|
size: Nullable<SizeType>; |
|
|
|
showIndexColumn: Nullable<boolean>; |
|
|
|
showIndexColumn: Recordable<Nullable<boolean>>; |
|
|
|
columns: Recordable<Nullable<Array<ColumnOptionsType>>>; |
|
|
|
showRowSelection: Nullable<boolean>; |
|
|
|
showRowSelection: Recordable<Nullable<boolean>>; |
|
|
|
} |
|
|
|
|