refactor(仪表板): 优化隐藏组件镜像适配存储方式

This commit is contained in:
wangjiahao
2025-02-07 16:38:56 +08:00
committed by dataeaseShu
parent 34ff33e03e
commit 96aa3119f0
7 changed files with 25 additions and 7 deletions

View File

@@ -15,7 +15,6 @@ const componentsHidden = computed(() => {
const addToDashboard = item => {
item.dashboardHidden = false
item.y = 200
emit('cancelHidden', item)
}
</script>

View File

@@ -629,7 +629,8 @@ const handleMouseDownOnShape = e => {
const up = () => {
dashboardActive.value && emit('onMouseUp')
element.value['dragging'] = false
hasMove && snapshotStore.recordSnapshotCache('shape-handleMouseDownOnShape-up')
hasMove &&
snapshotStore.recordSnapshotCacheWithPositionChange('shape-handleMouseDownOnShape-up')
// 触发元素停止移动事件,用于隐藏标线
eventBus.emit('unMove')
document.removeEventListener('mousemove', move)
@@ -813,7 +814,8 @@ const handleMouseDownOnPoint = (point, e) => {
element.value['resizing'] = false
document.removeEventListener('mousemove', move)
document.removeEventListener('mouseup', up)
needSave && snapshotStore.recordSnapshotCache('shape-handleMouseDownOnPoint-up')
needSave &&
snapshotStore.recordSnapshotCacheWithPositionChange('shape-handleMouseDownOnPoint-up')
handleGroupComponent()
}

View File

@@ -508,8 +508,9 @@ const hiddenComponent = () => {
curComponent.value.dashboardHidden = true
eventBus.emit('removeMatrixItemPosition-' + canvasId.value, curComponent.value)
dvMainStore.setHiddenListStatus(true)
snapshotStore.recordSnapshotCache('hide')
dvMainStore.setLastHiddenComponent(curComponent.value.id)
}
snapshotStore.recordSnapshotCache('hide')
}
// 复用-Begin

View File

@@ -159,6 +159,8 @@ export const dvMainStore = defineStore('dataVisualization', {
batchOptStatus: false,
// 隐藏组件打开状态
hiddenListStatus: false,
// 最后隐藏组件
lastHiddenComponent: [],
// Currently selected components
curBatchOptComponents: [],
// Currently selected Multiplexing components
@@ -199,6 +201,13 @@ export const dvMainStore = defineStore('dataVisualization', {
}
},
actions: {
setLastHiddenComponent(value?) {
if (value) {
this.lastHiddenComponent = [value]
} else if (this.lastHiddenComponent.length > 0) {
this.lastHiddenComponent = []
}
},
setIframeFlag(value) {
this.isIframe = value
},

View File

@@ -80,6 +80,10 @@ export const snapshotStore = defineStore('snapshot', {
}
this.recordSnapshotCache(type)
},
recordSnapshotCacheWithPositionChange(type?, viewId = 'all') {
dvMainStore.setLastHiddenComponent()
this.recordSnapshotCache(type, viewId)
},
recordSnapshotCache(type?, viewId = 'all') {
if (dataPrepareState.value) {
if (type === 'calcData') {

View File

@@ -113,7 +113,7 @@ const handleNewFromCanvasMain = newComponentInfo => {
scrollTo(component.y)
})
})
snapshotStore.recordSnapshotCache('renderChart', component.id)
snapshotStore.recordSnapshotCacheWithPositionChange('renderChart', component.id)
}
}
@@ -126,7 +126,7 @@ const handleDrop = e => {
addComponent.isShow = true
syncShapeItemStyle(addComponent, baseWidth.value, baseHeight.value)
cyGridster.value.handleMouseUp(e, addComponent, componentData.value.length - 1)
snapshotStore.recordSnapshotCache('renderChart', addComponent.id)
snapshotStore.recordSnapshotCacheWithPositionChange('renderChart', addComponent.id)
}
}
@@ -223,7 +223,6 @@ const dashboardCanvasSizeInit = () => {
}
}
const addItemBox = component => {
console.log('==test2')
cyGridster.value.addItemBox(component)
}

View File

@@ -59,6 +59,7 @@ const {
editMode,
batchOptStatus,
hiddenListStatus,
lastHiddenComponent,
dvInfo
} = storeToRefs(dvMainStore)
const dataInitState = ref(false)
@@ -280,6 +281,9 @@ const dashboardComponentData = computed(() =>
const cancelHidden = item => {
if (deCanvasRef.value) {
if (!(lastHiddenComponent.value?.length && lastHiddenComponent.value.includes(item.id))) {
item.y = undefined
}
deCanvasRef.value.addItemBox(item)
nextTick(() => {
deCanvasRef.value.canvasInit(false)