From 8c10b4a7b62f9aef0b4aac21f4a3b4ed32cc4163 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 3 Jul 2024 10:44:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=9D=E5=A7=8B=E5=8C=96=E7=9F=A9=E9=98=B5?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=EF=BC=8C=E8=A7=A3=E5=86=B3=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E6=9D=BF=E4=BF=9D=E5=AD=98=E5=90=8E=E5=86=8D=E6=AC=A1=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E4=BD=8D=E7=BD=AE=E9=94=99=E4=B9=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-visualization/canvas/CanvasCore.vue | 7 ++++++- core/core-frontend/src/utils/canvasUtils.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue index c5fa8c2241..0253917e9a 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue @@ -25,8 +25,10 @@ import _ from 'lodash' import DragShadow from '@/components/data-visualization/canvas/DragShadow.vue' import { canvasSave, + componentPreSort, findDragComponent, findNewComponent, + isDashboard, isGroupCanvas, isMainCanvas, isSameCanvas @@ -1088,7 +1090,10 @@ const canvasInit = () => { reCalcCellWidth() resetPositionBox() - + // 根据高度排序 + if (isDashboard()) { + componentPreSort(componentData.value) + } let i = 0 let timeId = setInterval(function () { if (i >= componentData.value.length) { diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index bbfda5f9fa..cbb43c196f 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -546,3 +546,17 @@ export function trackBarStyleCheck(element, trackbarStyle, _scale, trackMenuNumb trackbarStyle.top = trackbarStyle.top - trackMenuHeight } } + +// 优化仪表板图层排序 根据所处的Y轴位置预先进行排序再渲染矩阵 防止出现串位 +export function componentPreSort(componentData) { + if (componentData && Array.isArray(componentData)) { + componentData.sort((c1, c2) => c1.y - c2.y) + componentData.forEach(componentItem => { + if (componentItem.component === 'DeTabs') { + componentItem.propValue.forEach(tabItem => { + componentPreSort(tabItem.componentData) + }) + } + }) + } +}