CN-1075 table自定义列缓存功能有时会因字段变化导致缓存数据使用报错
This commit is contained in:
@@ -58,7 +58,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { storageKey } from '@/utils/constants'
|
import indexedDBUtils from '@/indexedDB'
|
||||||
|
import { storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
|
||||||
|
import { get } from '@/utils/http'
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
customTableTitle: Array, // 自定义的title
|
customTableTitle: Array, // 自定义的title
|
||||||
@@ -74,10 +76,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
|
/*
|
||||||
const localStorageTitle = JSON.parse(localStorage.getItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId))
|
const localStorageTitle = JSON.parse(localStorage.getItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId))
|
||||||
if (localStorageTitle) {
|
if (localStorageTitle) {
|
||||||
localStorage.setItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId, JSON.stringify(localStorageTitle))
|
localStorage.setItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId, JSON.stringify(localStorageTitle))
|
||||||
}
|
} */
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
customTableTitle: {
|
customTableTitle: {
|
||||||
@@ -147,10 +150,30 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 点击第二个cancel
|
// 点击第二个cancel
|
||||||
save () {
|
async save () {
|
||||||
this.$emit('update', this.custom)
|
this.$emit('update', this.custom)
|
||||||
localStorage.setItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId, JSON.stringify(this.custom))
|
const userId = localStorage.getItem(storageKey.userId)
|
||||||
// this.esc()
|
const tableName = dbTableColumnCustomizeConfigPre + '-' + this.tableId
|
||||||
|
|
||||||
|
const defaultConfigInDb = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
||||||
|
let fullVersion = ''
|
||||||
|
if (defaultConfigInDb && defaultConfigInDb.version) {
|
||||||
|
const oldVersion = defaultConfigInDb.version
|
||||||
|
if (oldVersion.startsWith(BASE_CONFIG.version)) {
|
||||||
|
const realVersion = Number(oldVersion.substring(BASE_CONFIG.version.length + 1))
|
||||||
|
fullVersion = BASE_CONFIG.version + '.' + (realVersion + 1)
|
||||||
|
} else {
|
||||||
|
fullVersion = BASE_CONFIG.version + '.1'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fullVersion = BASE_CONFIG.version + '.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
await indexedDBUtils.selectTable(tableName).put({
|
||||||
|
id: userId,
|
||||||
|
version: fullVersion,
|
||||||
|
config: _.cloneDeep(this.custom)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
import { dbName, dbGeoDataTableName, dbDrilldownTableConfig } from '@/utils/constants'
|
import { dbName, dbGeoDataTableName, dbDrilldownTableConfig, dbUserTableColumnCustomizeConfig, dbRoleTableColumnCustomizeConfig, dbOperationLogTableColumnCustomizeConfig, dbChartTableColumnCustomizeConfig, dbI18nTableColumnCustomizeConfig, dbReportTableColumnCustomizeConfig, dbGalaxySettingTableColumnCustomizeConfig } from '@/utils/constants'
|
||||||
import Dexie from 'dexie'
|
import Dexie from 'dexie'
|
||||||
/* https://dexie.org/ */
|
/* https://dexie.org/ */
|
||||||
|
|
||||||
const db = new Dexie(dbName)
|
const db = new Dexie(dbName)
|
||||||
db.version(3).stores({
|
db.version(4).stores({
|
||||||
[dbGeoDataTableName]: '++name, geo',
|
[dbGeoDataTableName]: '++name, geo',
|
||||||
[dbDrilldownTableConfig]: '++id, config',
|
[dbDrilldownTableConfig]: '++id, config',
|
||||||
|
[dbUserTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbRoleTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbOperationLogTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbChartTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbI18nTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbReportTableColumnCustomizeConfig]: '++id, config',
|
||||||
|
[dbGalaxySettingTableColumnCustomizeConfig]: '++id, config',
|
||||||
test: '++id, name'
|
test: '++id, name'
|
||||||
})
|
})
|
||||||
function selectTable (tableName) {
|
function selectTable (tableName) {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { tableSort } from '@/utils/tools'
|
import { tableSort } from '@/utils/tools'
|
||||||
import { defaultPageSize, fromRoute, position, storageKey } from '@/utils/constants'
|
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
|
||||||
import { get, del } from '@/utils/http'
|
import { get, del } from '@/utils/http'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import pagination from '@/components/common/Pagination'
|
import pagination from '@/components/common/Pagination'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { api } from '@/utils/api'
|
import { api } from '@/utils/api'
|
||||||
import Loading from '@/components/common/Loading'
|
import Loading from '@/components/common/Loading'
|
||||||
|
import indexedDBUtils from '@/indexedDB'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -395,13 +396,17 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
async mounted () {
|
||||||
const pageSize = localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
|
const pageSize = localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
|
||||||
if (pageSize && pageSize !== 'undefined') {
|
if (pageSize && pageSize !== 'undefined') {
|
||||||
this.pageObj.pageSize = pageSize
|
this.pageObj.pageSize = pageSize
|
||||||
}
|
}
|
||||||
let localStorageTableTitle = localStorage.getItem(storageKey.tableTitle + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
|
const userId = localStorage.getItem(storageKey.userId)
|
||||||
localStorageTableTitle = localStorageTableTitle ? JSON.parse(localStorageTableTitle) : this.$refs.dataTable.tableTitle
|
let localStorageTableTitle = await indexedDBUtils.selectTable(dbTableColumnCustomizeConfigPre + '-' + this.tableId).get({ id: userId })
|
||||||
|
|
||||||
|
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config
|
||||||
|
? localStorageTableTitle.config
|
||||||
|
: (this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : [])
|
||||||
// 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
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ export const dbName = 'cn-db'
|
|||||||
// indexedDB表名
|
// indexedDB表名
|
||||||
export const dbGeoDataTableName = 'geodata'
|
export const dbGeoDataTableName = 'geodata'
|
||||||
export const dbDrilldownTableConfig = 'cn-drilldown-table-config'
|
export const dbDrilldownTableConfig = 'cn-drilldown-table-config'
|
||||||
|
export const dbTableColumnCustomizeConfigPre = 'cn-table-column-customize-config'
|
||||||
|
export const dbUserTableColumnCustomizeConfig = 'cn-table-column-customize-config-userTable'
|
||||||
|
export const dbRoleTableColumnCustomizeConfig = 'cn-table-column-customize-config-rolesTable'
|
||||||
|
export const dbOperationLogTableColumnCustomizeConfig = 'cn-table-column-customize-config-operationLogTable'
|
||||||
|
export const dbChartTableColumnCustomizeConfig = 'cn-table-column-customize-config-chartTable'
|
||||||
|
export const dbI18nTableColumnCustomizeConfig = 'cn-table-column-customize-config-i18nTable'
|
||||||
|
export const dbReportTableColumnCustomizeConfig = 'cn-table-column-customize-config-reportTable'
|
||||||
|
export const dbGalaxySettingTableColumnCustomizeConfig = 'cn-table-column-customize-config-galaxySettingTable'
|
||||||
export const storageKey = {
|
export const storageKey = {
|
||||||
iso36112Capital: 'cn-iso3611-2-capital',
|
iso36112Capital: 'cn-iso3611-2-capital',
|
||||||
iso36112WorldLow: 'cn-iso3611-2-world-low',
|
iso36112WorldLow: 'cn-iso3611-2-world-low',
|
||||||
|
|||||||
Reference in New Issue
Block a user