diff --git a/core/core-frontend/src/components/dashboard/DashboardHiddenComponent.vue b/core/core-frontend/src/components/dashboard/DashboardHiddenComponent.vue index c97e6b8fc3..9c61f41c9d 100644 --- a/core/core-frontend/src/components/dashboard/DashboardHiddenComponent.vue +++ b/core/core-frontend/src/components/dashboard/DashboardHiddenComponent.vue @@ -15,7 +15,6 @@ const componentsHidden = computed(() => { const addToDashboard = item => { item.dashboardHidden = false - item.y = 200 emit('cancelHidden', item) } diff --git a/core/core-frontend/src/components/data-visualization/canvas/Shape.vue b/core/core-frontend/src/components/data-visualization/canvas/Shape.vue index 337aeeb74b..b9f9c1c8da 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/Shape.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/Shape.vue @@ -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() } diff --git a/core/core-frontend/src/components/visualization/ComponentEditBar.vue b/core/core-frontend/src/components/visualization/ComponentEditBar.vue index 0889ccc832..a4dc35e38d 100644 --- a/core/core-frontend/src/components/visualization/ComponentEditBar.vue +++ b/core/core-frontend/src/components/visualization/ComponentEditBar.vue @@ -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 diff --git a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts index e6ddbb687a..6e13ea7481 100644 --- a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts +++ b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts @@ -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 }, diff --git a/core/core-frontend/src/store/modules/data-visualization/snapshot.ts b/core/core-frontend/src/store/modules/data-visualization/snapshot.ts index 0e665b3c6e..8a88deaa96 100644 --- a/core/core-frontend/src/store/modules/data-visualization/snapshot.ts +++ b/core/core-frontend/src/store/modules/data-visualization/snapshot.ts @@ -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') { diff --git a/core/core-frontend/src/views/canvas/DeCanvas.vue b/core/core-frontend/src/views/canvas/DeCanvas.vue index 04b04b0b57..303970ffe4 100644 --- a/core/core-frontend/src/views/canvas/DeCanvas.vue +++ b/core/core-frontend/src/views/canvas/DeCanvas.vue @@ -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) } diff --git a/core/core-frontend/src/views/dashboard/index.vue b/core/core-frontend/src/views/dashboard/index.vue index cd74946c9b..8d06d8bb3b 100644 --- a/core/core-frontend/src/views/dashboard/index.vue +++ b/core/core-frontend/src/views/dashboard/index.vue @@ -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)