fix: 表格自定义缓存修改(1. 初始化读取缓存时,判断缓存里的version和当前version是否一致,不一致则清掉缓存,改用代码里的tableTitle;2. 在保存时,version字段直接用当前version,不用加小版本)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const BASE_CONFIG = {
|
const BASE_CONFIG = {
|
||||||
baseUrl: 'http://192.168.44.54:8090/',
|
baseUrl: 'http://192.168.44.54:8090/',
|
||||||
version: '24.03',
|
version: '24.04',
|
||||||
apiVersion: 'v1'
|
apiVersion: 'v1'
|
||||||
}
|
}
|
||||||
// 默认时间过滤条件,单位分钟. 0表示请求接口时不传时间参数
|
// 默认时间过滤条件,单位分钟. 0表示请求接口时不传时间参数
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import indexedDBUtils from '@/indexedDB'
|
import indexedDBUtils from '@/indexedDB'
|
||||||
import { storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
|
import { storageKey, dbTableColumnCustomizeConfigPre,dbTableColumnCustomizeConfig } from '@/utils/constants'
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
customTableTitle: Array, // 自定义的title
|
customTableTitle: Array, // 自定义的title
|
||||||
@@ -153,7 +153,7 @@ export default {
|
|||||||
this.$emit('update', this.custom)
|
this.$emit('update', this.custom)
|
||||||
const userId = localStorage.getItem(storageKey.userId)
|
const userId = localStorage.getItem(storageKey.userId)
|
||||||
const tableName = dbTableColumnCustomizeConfigPre + '-' + this.tableId
|
const tableName = dbTableColumnCustomizeConfigPre + '-' + this.tableId
|
||||||
|
/*
|
||||||
const defaultConfigInDb = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
const defaultConfigInDb = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
||||||
let fullVersion = ''
|
let fullVersion = ''
|
||||||
if (defaultConfigInDb && defaultConfigInDb.version) {
|
if (defaultConfigInDb && defaultConfigInDb.version) {
|
||||||
@@ -167,12 +167,15 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
fullVersion = BASE_CONFIG.version + '.1'
|
fullVersion = BASE_CONFIG.version + '.1'
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
await indexedDBUtils.selectTable(tableName).put({
|
let curTableConfig = dbTableColumnCustomizeConfig.find(item => item.tableName === tableName)
|
||||||
id: userId,
|
if(curTableConfig) {
|
||||||
version: fullVersion,
|
await indexedDBUtils.selectTable(tableName).put({
|
||||||
config: _.cloneDeep(this.custom)
|
id: userId,
|
||||||
})
|
version: curTableConfig.version,
|
||||||
|
config: _.cloneDeep(this.custom)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { tableSort } from '@/utils/tools'
|
import { tableSort } from '@/utils/tools'
|
||||||
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
|
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre,dbTableColumnCustomizeConfig } from '@/utils/constants'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import pagination from '@/components/common/Pagination'
|
import pagination from '@/components/common/Pagination'
|
||||||
@@ -428,9 +428,19 @@ export default {
|
|||||||
localStorageTableTitle = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
localStorageTableTitle = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config
|
let curTableTitles = this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : []
|
||||||
? localStorageTableTitle.config
|
let curTableConfig = dbTableColumnCustomizeConfig.find(item => item.tableName === tableName)
|
||||||
: (this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : [])
|
if(localStorageTableTitle && curTableConfig &&
|
||||||
|
localStorageTableTitle.version !== curTableConfig.version && curTableTitles) {
|
||||||
|
this.$emit('update', curTableTitles)
|
||||||
|
await indexedDBUtils.selectTable(tableName).put({
|
||||||
|
id: userId,
|
||||||
|
version: curTableConfig.version,
|
||||||
|
config: _.cloneDeep(curTableTitles)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config ? localStorageTableTitle.config : curTableTitles
|
||||||
// this.tools.customTableTitle = this.$refs.dataTable.tableTitle.map((item, index) => { // 修复切换中英文的问题
|
// this.tools.customTableTitle = this.$refs.dataTable.tableTitle.map((item, index) => { // 修复切换中英文的问题
|
||||||
// if (localStorageTableTitle[index]) {
|
// if (localStorageTableTitle[index]) {
|
||||||
// item.show = localStorageTableTitle[index].show
|
// item.show = localStorageTableTitle[index].show
|
||||||
|
|||||||
@@ -52,6 +52,31 @@ export const storageKey = {
|
|||||||
}
|
}
|
||||||
export const largeCountryList = ['CN', 'US', 'RU', 'AU', 'CA', 'KZ', 'IN', 'BR']
|
export const largeCountryList = ['CN', 'US', 'RU', 'AU', 'CA', 'KZ', 'IN', 'BR']
|
||||||
|
|
||||||
|
export const dbTableColumnCustomizeConfig = [
|
||||||
|
{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbUserTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbRoleTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbOperationLogTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbChartTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbI18nTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbReportTableColumnCustomizeConfig
|
||||||
|
},{
|
||||||
|
version: '24.04.01',
|
||||||
|
tableName: dbGalaxySettingTableColumnCustomizeConfig
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
// 统一定义跳转来源
|
// 统一定义跳转来源
|
||||||
export const fromRoute = {
|
export const fromRoute = {
|
||||||
trafficSummary: 'trafficSummary',
|
trafficSummary: 'trafficSummary',
|
||||||
|
|||||||
Reference in New Issue
Block a user