fix(仪表板): 修复被联动图表被删除后,联动配置没有清理问题

This commit is contained in:
wangjiahao 2024-04-28 17:36:00 +08:00
parent 3d2395bccb
commit 93d4fd8f66
4 changed files with 28 additions and 3 deletions

View File

@ -867,6 +867,7 @@ function removeItem(index) {
})
}
componentData.value.splice(index, 1)
dvMainStore.removeLinkageInfo(item['id'])
if (!!checkedFields.length) {
Array.from(new Set(checkedFields)).forEach(ele => {
emitter.emit(`query-data-${ele}`)

View File

@ -793,6 +793,9 @@ export const dvMainStore = defineStore('dataVisualization', {
setNowPanelJumpInfo(jumpInfo) {
this.nowPanelJumpInfo = jumpInfo.baseJumpInfoMap
},
setNowPanelJumpInfoInner(jumpInfo) {
this.nowPanelJumpInfo = jumpInfo
},
setNowTargetPanelJumpInfo(jumpInfo) {
this.nowPanelJumpInfoTargetPanel = jumpInfo.baseJumpInfoVisualizationMap
},
@ -1122,6 +1125,24 @@ export const dvMainStore = defineStore('dataVisualization', {
this.componentData = []
this.canvasViewInfo = {}
},
removeLinkageInfo(targetId) {
if (!!targetId && !!this.nowPanelTrackInfo) {
Object.keys(this.nowPanelTrackInfo).forEach(trackId => {
const targetInfo = this.nowPanelTrackInfo[trackId]
for (let i = 0; i < targetInfo.length; i++) {
if (targetInfo[i].indexOf(targetId) > -1) {
targetInfo.splice(i, 1)
i--
}
}
})
Object.keys(this.nowPanelTrackInfo).forEach(trackId => {
if (trackId.indexOf(targetId) > -1 || this.nowPanelTrackInfo[trackId].length === 0) {
delete this.nowPanelTrackInfo[trackId]
}
})
}
},
canvasDataInit() {
this.canvasViewInfo = {}
this.componentData = []

View File

@ -13,7 +13,8 @@ const {
canvasStyleData,
canvasViewInfo,
curOriginThemes,
dataPrepareState
dataPrepareState,
nowPanelTrackInfo
} = storeToRefs(dvMainStore)
let defaultCanvasInfo = {
@ -81,6 +82,7 @@ export const snapshotStore = defineStore('snapshot', {
dvMainStore.setComponentData(snapshotInfo.componentData)
dvMainStore.setCanvasStyle(snapshotInfo.canvasStyleData)
dvMainStore.setCanvasViewInfo(snapshotInfo.canvasViewInfo)
dvMainStore.setNowPanelJumpInfoInner(snapshotInfo.nowPanelTrackInfo)
const curCacheViewIdInfo = deepCopy(this.cacheViewIdInfo)
this.cacheViewIdInfo = snapshotInfo.cacheViewIdInfo
@ -139,7 +141,8 @@ export const snapshotStore = defineStore('snapshot', {
componentData: deepCopy(componentData.value),
canvasStyleData: deepCopy(canvasStyleData.value),
canvasViewInfo: deepCopy(canvasViewInfo.value),
cacheViewIdInfo: deepCopy(this.cacheViewIdInfo)
cacheViewIdInfo: deepCopy(this.cacheViewIdInfo),
nowPanelTrackInfo: deepCopy(nowPanelTrackInfo.value)
}
this.snapshotData[++this.snapshotIndex] = newSnapshot
// undo 过程中添加新的快照时要将它后面的快照清理掉

View File

@ -21,7 +21,7 @@ import { BASE_VIEW_CONFIG } from '../util/chart'
import { cloneDeep, defaultsDeep } from 'lodash-es'
const dvMainStore = dvMainStoreWithOut()
const { nowPanelTrackInfo, nowPanelJumpInfo, dvInfo } = storeToRefs(dvMainStore)
const { nowPanelTrackInfo, nowPanelJumpInfo, dvInfo, componentData } = storeToRefs(dvMainStore)
const { t } = useI18n()
const linkJumpRef = ref(null)