fix(工作台): 修复旧模版的适配性问题

This commit is contained in:
wangjiahao 2024-07-02 09:41:11 +08:00
parent b978b40bd5
commit 6ff602bb36
2 changed files with 29 additions and 8 deletions

View File

@ -107,6 +107,9 @@ public class TemplateManageService implements TemplateManageApi {
VisualizationTemplate template = new VisualizationTemplate(); VisualizationTemplate template = new VisualizationTemplate();
BeanUtils.copyBean(template, request); BeanUtils.copyBean(template, request);
if(template.getVersion() == null){
template.setVersion(2);
}
templateMapper.insert(template); templateMapper.insert(template);
// 插入分类关系 // 插入分类关系
request.getCategories().forEach(categoryId -> { request.getCategories().forEach(categoryId -> {
@ -134,6 +137,9 @@ public class TemplateManageService implements TemplateManageApi {
} }
VisualizationTemplate template = new VisualizationTemplate(); VisualizationTemplate template = new VisualizationTemplate();
BeanUtils.copyBean(template, request); BeanUtils.copyBean(template, request);
if(template.getVersion() == null){
template.setVersion(2);
}
templateMapper.updateById(template); templateMapper.updateById(template);
//更新分类 //更新分类
// 分类映射删除 // 分类映射删除

View File

@ -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) { export function initCanvasDataPrepare(dvId, busiFlag, callBack) {
const copyFlag = busiFlag != null && busiFlag.includes('-copy') const copyFlag = busiFlag != null && busiFlag.includes('-copy')
const busiFlagCustom = copyFlag ? busiFlag.split('-')[0] : busiFlag const busiFlagCustom = copyFlag ? busiFlag.split('-')[0] : busiFlag
@ -152,14 +174,7 @@ export function initCanvasDataPrepare(dvId, busiFlag, callBack) {
} }
// 2 为基础版本 此处需要增加仪表板矩阵密度 // 2 为基础版本 此处需要增加仪表板矩阵密度
if ((!canvasVersion || canvasVersion === 2) && canvasInfo.type === 'dashboard') { if ((!canvasVersion || canvasVersion === 2) && canvasInfo.type === 'dashboard') {
componentItem.x = 1 + (componentItem.x - 1) * 2 matrixAdaptor(componentItem)
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
} }
}) })
const curPreviewGap = const curPreviewGap =