diff --git a/core/core-frontend/src/components/data-visualization/CanvasAttr.vue b/core/core-frontend/src/components/data-visualization/CanvasAttr.vue index 67a37243fb..85eafc08ec 100644 --- a/core/core-frontend/src/components/data-visualization/CanvasAttr.vue +++ b/core/core-frontend/src/components/data-visualization/CanvasAttr.vue @@ -22,8 +22,7 @@ const canvasAttrActiveNames = ref(['size', 'background', 'color']) const screenAdaptorList = [ { label: '宽度优先', value: 'widthFirst' }, { label: '高度优先', value: 'heightFirst' }, - { label: '铺满全屏', value: 'full' }, - { label: '不缩放', value: 'keepSize' } + { label: '铺满全屏', value: 'full' } ] const init = () => { nextTick(() => { @@ -35,6 +34,10 @@ const onColorChange = val => { themeAttrChange('customAttr', 'color', val) } +const onStyleChange = () => { + snapshotStore.recordSnapshotCache('renderChart') +} + const onBaseChange = () => { snapshotStore.recordSnapshotCache('renderChart') useEmitt().emitter.emit('initScroll') @@ -128,6 +131,7 @@ onMounted(() => { style="margin: 0 0 0 8px; flex: 1" effect="dark" v-model="canvasStyleData.screenAdaptor" + @change="onStyleChange" size="small" > { return dvInfo.value.type === 'dashboard' }) + +// 大屏是否保持宽高比例 非全屏 full 都需要保持宽高比例 +const dataVKeepRadio = computed(() => { + return canvasStyleData.value.screenAdaptor !== 'full' +}) const isReport = computed(() => { return !!router.currentRoute.value.query?.report }) @@ -117,8 +122,15 @@ const canvasStyle = computed(() => { ? downloadStatus.value ? getDownloadStatusMainHeight() : '100%' - : changeStyleWithScale(canvasStyleData.value?.height, scaleMin.value) + 'px' + : !canvasStyleData.value?.screenAdaptor || + canvasStyleData.value?.screenAdaptor === 'widthFirst' + ? changeStyleWithScale(canvasStyleData.value?.height, scaleMin.value) + 'px' + : '100%' } + style['width'] = + !dashboardActive.value && canvasStyleData.value?.screenAdaptor === 'heightFirst' + ? changeStyleWithScale(canvasStyleData.value?.width, scaleHeightPoint.value) + 'px' + : '100%' } if (!dashboardActive.value) { style['overflow-y'] = 'hidden' @@ -179,11 +191,11 @@ const resetLayout = () => { //div容器获取tableBox.value.clientWidth let canvasWidth = previewCanvas.value.clientWidth let canvasHeight = previewCanvas.value.clientHeight - scaleWidth.value = Math.floor((canvasWidth * 100) / canvasStyleData.value.width) - scaleHeight.value = Math.floor((canvasHeight * 100) / canvasStyleData.value.height) + scaleWidthPoint.value = (canvasWidth * 100) / canvasStyleData.value.width + scaleHeightPoint.value = (canvasHeight * 100) / canvasStyleData.value.height scaleMin.value = isDashboard() - ? Math.min(scaleWidth.value, scaleHeight.value) - : (canvasWidth * 100) / canvasStyleData.value.width + ? Math.floor(Math.min(scaleWidthPoint.value, scaleHeightPoint.value)) + : scaleWidthPoint.value if (dashboardActive.value) { cellWidth.value = canvasWidth / pcMatrixCount.value.x cellHeight.value = canvasHeight / pcMatrixCount.value.y @@ -191,10 +203,13 @@ const resetLayout = () => { ? scaleMin.value * 1.2 : outerScale.value * 100 } else { - changeRefComponentsSizeWithScale( + // 需要保持宽高比例时 高度伸缩和宽度伸缩保持一致 否则 高度伸缩单独计算 + const scaleMinHeight = dataVKeepRadio.value ? scaleMin.value : scaleHeightPoint.value + changeRefComponentsSizeWithScalePoint( baseComponentData.value, canvasStyleData.value, - scaleMin.value + scaleMin.value, + scaleMinHeight ) } } diff --git a/core/core-frontend/src/style/index.less b/core/core-frontend/src/style/index.less index f625e010ba..c631a5b12d 100644 --- a/core/core-frontend/src/style/index.less +++ b/core/core-frontend/src/style/index.less @@ -516,3 +516,25 @@ strong { overflow: hidden; } } + + +.preview-content-inner-full { + width: 100%; + height: 100%; + overflow-x: hidden; + overflow-y: hidden; +} + +.preview-content-inner-width-first { + width: 100%; + height: auto; + overflow-x: hidden; + overflow-y: auto; +} + +.preview-content-inner-height-first { + width: auto; + height: 100%; + overflow-x: auto; + overflow-y: hidden; +} diff --git a/core/core-frontend/src/utils/canvasUtils.ts b/core/core-frontend/src/utils/canvasUtils.ts index 385ecbf3be..0b3add4141 100644 --- a/core/core-frontend/src/utils/canvasUtils.ts +++ b/core/core-frontend/src/utils/canvasUtils.ts @@ -131,6 +131,9 @@ export function historyAdaptor( canvasStyleResult.component['seniorStyleSetting'] = canvasStyleResult.component['seniorStyleSetting'] || deepCopy(SENIOR_STYLE_SETTING_LIGHT) canvasStyleResult['screenAdaptor'] = canvasStyleResult['screenAdaptor'] || 'widthFirst' + // 同步宽高比例(大屏使用) + canvasStyleResult['scaleWidth'] = canvasStyleResult['scale'] + canvasStyleResult['scaleHeight'] = canvasStyleResult['scale'] canvasStyleResult['popupAvailable'] = canvasStyleResult['popupAvailable'] === undefined ? true : canvasStyleResult['popupAvailable'] //兼容弹框区域开关 const reportFilterInfo = canvasInfo.reportFilterInfo diff --git a/core/core-frontend/src/utils/changeComponentsSizeWithScale.ts b/core/core-frontend/src/utils/changeComponentsSizeWithScale.ts index a575253c67..72f166f212 100644 --- a/core/core-frontend/src/utils/changeComponentsSizeWithScale.ts +++ b/core/core-frontend/src/utils/changeComponentsSizeWithScale.ts @@ -54,8 +54,11 @@ export function changeComponentsSizeWithScale(scale, changeAttrs = needToChangeA index: curComponentIndex.value }) + // 分开保存初始化宽高比例 dvMainStore.setCanvasStyle({ ...canvasStyleData.value, + scaleWidth: scale, + scaleHeight: scale, scale }) } @@ -96,7 +99,7 @@ export function changeRefComponentsSizeWithScalePoint( // 根据原来的比例获取样式原来的尺寸 // 再用原来的尺寸 * 现在的比例得出新的尺寸 component.style[key] = format( - getOriginStyle(component.style[key], canvasStyleDataRef.scale), + getOriginStyle(component.style[key], canvasStyleDataRef.scaleHeight), scaleHeight ) } diff --git a/core/core-frontend/src/views/data-visualization/DvPreview.vue b/core/core-frontend/src/views/data-visualization/DvPreview.vue index f750a3911e..fd15220189 100644 --- a/core/core-frontend/src/views/data-visualization/DvPreview.vue +++ b/core/core-frontend/src/views/data-visualization/DvPreview.vue @@ -1,6 +1,6 @@