From 6ff602bb3607b71e0d3a190ea5e0e8c062047b66 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 2 Jul 2024 09:41:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=97=A7=E6=A8=A1=E7=89=88=E7=9A=84=E9=80=82=E9=85=8D?= =?UTF-8?q?=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TemplateManageService.java | 6 ++++ core/core-frontend/src/utils/canvasUtils.ts | 31 ++++++++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java index b8de15c4b3..88e507f563 100644 --- a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java +++ b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java @@ -107,6 +107,9 @@ public class TemplateManageService implements TemplateManageApi { VisualizationTemplate template = new VisualizationTemplate(); BeanUtils.copyBean(template, request); + if(template.getVersion() == null){ + template.setVersion(2); + } templateMapper.insert(template); // 插入分类关系 request.getCategories().forEach(categoryId -> { @@ -134,6 +137,9 @@ public class TemplateManageService implements TemplateManageApi { } VisualizationTemplate template = new VisualizationTemplate(); BeanUtils.copyBean(template, request); + if(template.getVersion() == null){ + template.setVersion(2); + } templateMapper.updateById(template); //更新分类 // 分类映射删除 diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index 42f389d4cc..3d20d9d8f1 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -89,6 +89,28 @@ export function commonHandleDragEnd(e, dvModel) { } } +function matrixAdaptor(componentItem) { + componentItem.x = 1 + (componentItem.x - 1) * 2 + componentItem.y = 1 + (componentItem.y - 1) * 2 + componentItem.sizeX = componentItem.sizeX * 2 + componentItem.sizeY = componentItem.sizeY * 2 + componentItem.mx = 1 + (componentItem.mx - 1) * 2 + componentItem.my = 1 + (componentItem.my - 1) * 2 + componentItem.mSizeX = componentItem.mSizeX * 2 + componentItem.mSizeY = componentItem.mSizeY * 2 + if (componentItem.component === 'Group') { + componentItem.propValue.forEach(groupItem => { + matrixAdaptor(groupItem) + }) + } else if (componentItem.component === 'DeTabs') { + componentItem.propValue.forEach(tabItem => { + tabItem.componentData.forEach(tabComponent => { + matrixAdaptor(tabComponent) + }) + }) + } +} + export function initCanvasDataPrepare(dvId, busiFlag, callBack) { const copyFlag = busiFlag != null && busiFlag.includes('-copy') const busiFlagCustom = copyFlag ? busiFlag.split('-')[0] : busiFlag @@ -152,14 +174,7 @@ export function initCanvasDataPrepare(dvId, busiFlag, callBack) { } // 2 为基础版本 此处需要增加仪表板矩阵密度 if ((!canvasVersion || canvasVersion === 2) && canvasInfo.type === 'dashboard') { - componentItem.x = 1 + (componentItem.x - 1) * 2 - componentItem.y = 1 + (componentItem.y - 1) * 2 - componentItem.sizeX = componentItem.sizeX * 2 - componentItem.sizeY = componentItem.sizeY * 2 - componentItem.mx = 1 + (componentItem.mx - 1) * 2 - componentItem.my = 1 + (componentItem.my - 1) * 2 - componentItem.mSizeX = componentItem.mSizeX * 2 - componentItem.mSizeY = componentItem.mSizeY * 2 + matrixAdaptor(componentItem) } }) const curPreviewGap =