forked from github/dataease
feat(数据大屏): 数据大屏缩放模式优化
This commit is contained in:
parent
354861cf1f
commit
0b22746575
@ -22,8 +22,7 @@ const canvasAttrActiveNames = ref(['size', 'background', 'color'])
|
|||||||
const screenAdaptorList = [
|
const screenAdaptorList = [
|
||||||
{ label: '宽度优先', value: 'widthFirst' },
|
{ label: '宽度优先', value: 'widthFirst' },
|
||||||
{ label: '高度优先', value: 'heightFirst' },
|
{ label: '高度优先', value: 'heightFirst' },
|
||||||
{ label: '铺满全屏', value: 'full' },
|
{ label: '铺满全屏', value: 'full' }
|
||||||
{ label: '不缩放', value: 'keepSize' }
|
|
||||||
]
|
]
|
||||||
const init = () => {
|
const init = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -35,6 +34,10 @@ const onColorChange = val => {
|
|||||||
themeAttrChange('customAttr', 'color', val)
|
themeAttrChange('customAttr', 'color', val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onStyleChange = () => {
|
||||||
|
snapshotStore.recordSnapshotCache('renderChart')
|
||||||
|
}
|
||||||
|
|
||||||
const onBaseChange = () => {
|
const onBaseChange = () => {
|
||||||
snapshotStore.recordSnapshotCache('renderChart')
|
snapshotStore.recordSnapshotCache('renderChart')
|
||||||
useEmitt().emitter.emit('initScroll')
|
useEmitt().emitter.emit('initScroll')
|
||||||
@ -128,6 +131,7 @@ onMounted(() => {
|
|||||||
style="margin: 0 0 0 8px; flex: 1"
|
style="margin: 0 0 0 8px; flex: 1"
|
||||||
effect="dark"
|
effect="dark"
|
||||||
v-model="canvasStyleData.screenAdaptor"
|
v-model="canvasStyleData.screenAdaptor"
|
||||||
|
@change="onStyleChange"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
|
@ -3,7 +3,7 @@ import { getCanvasStyle, getShapeItemStyle } from '@/utils/style'
|
|||||||
import ComponentWrapper from './ComponentWrapper.vue'
|
import ComponentWrapper from './ComponentWrapper.vue'
|
||||||
import { changeStyleWithScale } from '@/utils/translate'
|
import { changeStyleWithScale } from '@/utils/translate'
|
||||||
import { computed, nextTick, ref, toRefs, watch, onBeforeUnmount, onMounted } from 'vue'
|
import { computed, nextTick, ref, toRefs, watch, onBeforeUnmount, onMounted } from 'vue'
|
||||||
import { changeRefComponentsSizeWithScale } from '@/utils/changeComponentsSizeWithScale'
|
import { changeRefComponentsSizeWithScalePoint } from '@/utils/changeComponentsSizeWithScale'
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import elementResizeDetectorMaker from 'element-resize-detector'
|
import elementResizeDetectorMaker from 'element-resize-detector'
|
||||||
@ -83,8 +83,8 @@ const {
|
|||||||
outerScale
|
outerScale
|
||||||
} = toRefs(props)
|
} = toRefs(props)
|
||||||
const domId = 'preview-' + canvasId.value
|
const domId = 'preview-' + canvasId.value
|
||||||
const scaleWidth = ref(100)
|
const scaleWidthPoint = ref(100)
|
||||||
const scaleHeight = ref(100)
|
const scaleHeightPoint = ref(100)
|
||||||
const scaleMin = ref(100)
|
const scaleMin = ref(100)
|
||||||
const previewCanvas = ref(null)
|
const previewCanvas = ref(null)
|
||||||
const cellWidth = ref(10)
|
const cellWidth = ref(10)
|
||||||
@ -97,6 +97,11 @@ const userInfo = ref(null)
|
|||||||
const dashboardActive = computed(() => {
|
const dashboardActive = computed(() => {
|
||||||
return dvInfo.value.type === 'dashboard'
|
return dvInfo.value.type === 'dashboard'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 大屏是否保持宽高比例 非全屏 full 都需要保持宽高比例
|
||||||
|
const dataVKeepRadio = computed(() => {
|
||||||
|
return canvasStyleData.value.screenAdaptor !== 'full'
|
||||||
|
})
|
||||||
const isReport = computed(() => {
|
const isReport = computed(() => {
|
||||||
return !!router.currentRoute.value.query?.report
|
return !!router.currentRoute.value.query?.report
|
||||||
})
|
})
|
||||||
@ -117,8 +122,15 @@ const canvasStyle = computed(() => {
|
|||||||
? downloadStatus.value
|
? downloadStatus.value
|
||||||
? getDownloadStatusMainHeight()
|
? getDownloadStatusMainHeight()
|
||||||
: '100%'
|
: '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) {
|
if (!dashboardActive.value) {
|
||||||
style['overflow-y'] = 'hidden'
|
style['overflow-y'] = 'hidden'
|
||||||
@ -179,11 +191,11 @@ const resetLayout = () => {
|
|||||||
//div容器获取tableBox.value.clientWidth
|
//div容器获取tableBox.value.clientWidth
|
||||||
let canvasWidth = previewCanvas.value.clientWidth
|
let canvasWidth = previewCanvas.value.clientWidth
|
||||||
let canvasHeight = previewCanvas.value.clientHeight
|
let canvasHeight = previewCanvas.value.clientHeight
|
||||||
scaleWidth.value = Math.floor((canvasWidth * 100) / canvasStyleData.value.width)
|
scaleWidthPoint.value = (canvasWidth * 100) / canvasStyleData.value.width
|
||||||
scaleHeight.value = Math.floor((canvasHeight * 100) / canvasStyleData.value.height)
|
scaleHeightPoint.value = (canvasHeight * 100) / canvasStyleData.value.height
|
||||||
scaleMin.value = isDashboard()
|
scaleMin.value = isDashboard()
|
||||||
? Math.min(scaleWidth.value, scaleHeight.value)
|
? Math.floor(Math.min(scaleWidthPoint.value, scaleHeightPoint.value))
|
||||||
: (canvasWidth * 100) / canvasStyleData.value.width
|
: scaleWidthPoint.value
|
||||||
if (dashboardActive.value) {
|
if (dashboardActive.value) {
|
||||||
cellWidth.value = canvasWidth / pcMatrixCount.value.x
|
cellWidth.value = canvasWidth / pcMatrixCount.value.x
|
||||||
cellHeight.value = canvasHeight / pcMatrixCount.value.y
|
cellHeight.value = canvasHeight / pcMatrixCount.value.y
|
||||||
@ -191,10 +203,13 @@ const resetLayout = () => {
|
|||||||
? scaleMin.value * 1.2
|
? scaleMin.value * 1.2
|
||||||
: outerScale.value * 100
|
: outerScale.value * 100
|
||||||
} else {
|
} else {
|
||||||
changeRefComponentsSizeWithScale(
|
// 需要保持宽高比例时 高度伸缩和宽度伸缩保持一致 否则 高度伸缩单独计算
|
||||||
|
const scaleMinHeight = dataVKeepRadio.value ? scaleMin.value : scaleHeightPoint.value
|
||||||
|
changeRefComponentsSizeWithScalePoint(
|
||||||
baseComponentData.value,
|
baseComponentData.value,
|
||||||
canvasStyleData.value,
|
canvasStyleData.value,
|
||||||
scaleMin.value
|
scaleMin.value,
|
||||||
|
scaleMinHeight
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,3 +516,25 @@ strong {
|
|||||||
overflow: hidden;
|
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;
|
||||||
|
}
|
||||||
|
@ -131,6 +131,9 @@ export function historyAdaptor(
|
|||||||
canvasStyleResult.component['seniorStyleSetting'] =
|
canvasStyleResult.component['seniorStyleSetting'] =
|
||||||
canvasStyleResult.component['seniorStyleSetting'] || deepCopy(SENIOR_STYLE_SETTING_LIGHT)
|
canvasStyleResult.component['seniorStyleSetting'] || deepCopy(SENIOR_STYLE_SETTING_LIGHT)
|
||||||
canvasStyleResult['screenAdaptor'] = canvasStyleResult['screenAdaptor'] || 'widthFirst'
|
canvasStyleResult['screenAdaptor'] = canvasStyleResult['screenAdaptor'] || 'widthFirst'
|
||||||
|
// 同步宽高比例(大屏使用)
|
||||||
|
canvasStyleResult['scaleWidth'] = canvasStyleResult['scale']
|
||||||
|
canvasStyleResult['scaleHeight'] = canvasStyleResult['scale']
|
||||||
canvasStyleResult['popupAvailable'] =
|
canvasStyleResult['popupAvailable'] =
|
||||||
canvasStyleResult['popupAvailable'] === undefined ? true : canvasStyleResult['popupAvailable'] //兼容弹框区域开关
|
canvasStyleResult['popupAvailable'] === undefined ? true : canvasStyleResult['popupAvailable'] //兼容弹框区域开关
|
||||||
const reportFilterInfo = canvasInfo.reportFilterInfo
|
const reportFilterInfo = canvasInfo.reportFilterInfo
|
||||||
|
@ -54,8 +54,11 @@ export function changeComponentsSizeWithScale(scale, changeAttrs = needToChangeA
|
|||||||
index: curComponentIndex.value
|
index: curComponentIndex.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 分开保存初始化宽高比例
|
||||||
dvMainStore.setCanvasStyle({
|
dvMainStore.setCanvasStyle({
|
||||||
...canvasStyleData.value,
|
...canvasStyleData.value,
|
||||||
|
scaleWidth: scale,
|
||||||
|
scaleHeight: scale,
|
||||||
scale
|
scale
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -96,7 +99,7 @@ export function changeRefComponentsSizeWithScalePoint(
|
|||||||
// 根据原来的比例获取样式原来的尺寸
|
// 根据原来的比例获取样式原来的尺寸
|
||||||
// 再用原来的尺寸 * 现在的比例得出新的尺寸
|
// 再用原来的尺寸 * 现在的比例得出新的尺寸
|
||||||
component.style[key] = format(
|
component.style[key] = format(
|
||||||
getOriginStyle(component.style[key], canvasStyleDataRef.scale),
|
getOriginStyle(component.style[key], canvasStyleDataRef.scaleHeight),
|
||||||
scaleHeight
|
scaleHeight
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import DePreview from '@/components/data-visualization/canvas/DePreview.vue'
|
import DePreview from '@/components/data-visualization/canvas/DePreview.vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ const dvMainStore = dvMainStoreWithOut()
|
|||||||
const { fullscreenFlag } = storeToRefs(dvMainStore)
|
const { fullscreenFlag } = storeToRefs(dvMainStore)
|
||||||
const dePreviewRef = ref(null)
|
const dePreviewRef = ref(null)
|
||||||
const dataInitState = ref(true)
|
const dataInitState = ref(true)
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
canvasStylePreview: {
|
canvasStylePreview: {
|
||||||
required: true,
|
required: true,
|
||||||
type: Object
|
type: Object
|
||||||
@ -46,6 +46,17 @@ const restore = () => {
|
|||||||
dePreviewRef.value.restore()
|
dePreviewRef.value.restore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contentInnerClass = computed(() => {
|
||||||
|
//屏幕适配方式 widthFirst=宽度优先(默认) heightFirst=高度优先 full=铺满全屏 keepSize=不缩放
|
||||||
|
if (props.canvasStylePreview.screenAdaptor === 'heightFirst') {
|
||||||
|
return 'preview-content-inner-height-first'
|
||||||
|
} else if (props.canvasStylePreview.screenAdaptor === 'full') {
|
||||||
|
return 'preview-content-inner-full'
|
||||||
|
} else {
|
||||||
|
return 'preview-content-inner-width-first'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
restore
|
restore
|
||||||
})
|
})
|
||||||
@ -53,7 +64,7 @@ defineExpose({
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="de-preview-content" :class="{ 'de-screen-full': fullscreenFlag }" class="content-outer">
|
<div id="de-preview-content" :class="{ 'de-screen-full': fullscreenFlag }" class="content-outer">
|
||||||
<div class="content-inner">
|
<div class="content-inner" :class="contentInnerClass">
|
||||||
<de-preview
|
<de-preview
|
||||||
ref="dePreviewRef"
|
ref="dePreviewRef"
|
||||||
v-if="canvasStylePreview && dataInitState"
|
v-if="canvasStylePreview && dataInitState"
|
||||||
@ -79,11 +90,5 @@ defineExpose({
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center; /* 上下居中 */
|
justify-content: center; /* 上下居中 */
|
||||||
.content-inner {
|
|
||||||
width: 100%;
|
|
||||||
height: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -344,22 +344,6 @@ onBeforeMount(() => {
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.content-outer {
|
|
||||||
width: 100%;
|
|
||||||
height: calc(100vh - 112px);
|
|
||||||
background: #f5f6f7;
|
|
||||||
display: flex;
|
|
||||||
overflow-y: auto;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center; /* 上下居中 */
|
|
||||||
.content-inner {
|
|
||||||
width: 100%;
|
|
||||||
height: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user