From 0e092ab66ebb76db364a033ce978800456b533b0 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 13 Feb 2025 17:10:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=9C=89=E9=9A=90=E8=97=8F=E7=BB=84=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8Ctab=E7=A7=BB=E5=85=A5=E5=90=8E=E4=B8=BB=E7=94=BB?= =?UTF-8?q?=E5=B8=83=E7=BB=84=E4=BB=B6=E6=9C=AA=E5=88=A0=E9=99=A4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-component/de-tabs/Component.vue | 29 +++++++++++-------- core/core-frontend/src/utils/canvasUtils.ts | 15 ++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/core/core-frontend/src/custom-component/de-tabs/Component.vue b/core/core-frontend/src/custom-component/de-tabs/Component.vue index 13f9c944f9..7c7a4bf9b3 100644 --- a/core/core-frontend/src/custom-component/de-tabs/Component.vue +++ b/core/core-frontend/src/custom-component/de-tabs/Component.vue @@ -161,7 +161,12 @@ import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { storeToRefs } from 'pinia' import { guid } from '@/views/visualized/data/dataset/form/util' import eventBus from '@/utils/eventBus' -import { canvasChangeAdaptor, findComponentIndexById, isDashboard } from '@/utils/canvasUtils' +import { + canvasChangeAdaptor, + findComponentIndexById, + findComponentIndexByIdWithFilterHidden, + isDashboard +} from '@/utils/canvasUtils' import DeCustomTab from '@/custom-component/de-tabs/DeCustomTab.vue' import DePreview from '@/components/data-visualization/canvas/DePreview.vue' import { getPanelAllLinkageInfo } from '@/api/visualization/linkage' @@ -407,10 +412,9 @@ const componentMoveIn = component => { element.value.propValue.forEach((tabItem, index) => { if (editableTabsValue.value === tabItem.name) { //获取主画布当前组件的index - const curIndex = findComponentIndexById(component.id) - if (curIndex > -1) { - // 从主画布中移除 - if (isDashboard()) { + if (isDashboard()) { + const curIndex = findComponentIndexByIdWithFilterHidden(component.id) + if (curIndex > -1) { eventBus.emit('removeMatrixItem-canvas-main', curIndex) dvMainStore.setCurComponent({ component: null, index: null }) component.canvasId = element.value.id + '--' + tabItem.name @@ -428,14 +432,15 @@ const componentMoveIn = component => { refInstance.canvasInitImmediately() }) } - } else { - // 从主画布删除 - dvMainStore.deleteComponent(curIndex) - dvMainStore.setCurComponent({ component: null, index: null }) - component.canvasId = element.value.id + '--' + tabItem.name - dataVTabComponentAdd(component, element.value) - tabItem.componentData.push(component) } + } else { + const curIndex = findComponentIndexById(component.id) + // 从主画布删除 + dvMainStore.deleteComponent(curIndex) + dvMainStore.setCurComponent({ component: null, index: null }) + component.canvasId = element.value.id + '--' + tabItem.name + dataVTabComponentAdd(component, element.value) + tabItem.componentData.push(component) } } }) diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index 7756da4ec6..2b740357c4 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -738,6 +738,21 @@ export function isTabCanvas(canvasId) { return canvasId && !canvasId.includes('Group') && !isMainCanvas(canvasId) } +export function findComponentIndexByIdWithFilterHidden( + componentId, + componentDataMatch = componentData.value +) { + let indexResult = -1 + componentDataMatch + .filter(item => !item.dashboardHidden) + .forEach((component, index) => { + if (component.id === componentId) { + indexResult = index + } + }) + return indexResult +} + export function findComponentIndexById(componentId, componentDataMatch = componentData.value) { let indexResult = -1 componentDataMatch.forEach((component, index) => {