refactor: 仪表板适配后端长屏截图

This commit is contained in:
wangjiahao 2021-12-21 16:05:14 +08:00
parent b191c845a4
commit cda6b7513f
4 changed files with 59 additions and 10 deletions

View File

@ -1,6 +1,6 @@
<template>
<div class="bg" :style="customStyle">
<div id="canvasInfoMain" ref="canvasInfoMain" style="width: 100%;height: 100%">
<div id="canvasInfoMain" ref="canvasInfoMain" :style="canvasInfoMainStyle">
<div
id="canvasInfoTemp"
ref="canvasInfoTemp"
@ -73,6 +73,11 @@ export default {
event: 'change'
},
props: {
//
backScreenShot: {
type: Boolean,
default: false
},
screenShot: {
type: Boolean,
default: false
@ -125,6 +130,19 @@ export default {
created() {
},
computed: {
canvasInfoMainStyle() {
if (this.backScreenShot) {
return {
width: '100%',
height: this.mainHeight
}
} else {
return {
width: '100%',
height: '100%'
}
}
},
customStyle() {
let style = {
width: '100%'
@ -142,6 +160,11 @@ export default {
}
}
}
if (this.backScreenShot) {
style.height = this.mainHeight
} else {
style.padding = '5px'
}
return style
},
screenShotStyle() {
@ -189,6 +212,7 @@ export default {
_this.$nextTick(() => {
// mainHeight px html2canvas
_this.mainHeight = tempCanvas.scrollHeight + 'px!important'
this.$emit('mainHeightChange', _this.mainHeight)
})
})
eventBus.$on('openChartDetailsDialog', this.openChartDetailsDialog)
@ -231,7 +255,12 @@ export default {
const canvasHeight = document.getElementById('canvasInfoMain').offsetHeight
const canvasWidth = document.getElementById('canvasInfoMain').offsetWidth
this.scaleWidth = (canvasWidth) * 100 / this.canvasStyleData.width //
this.scaleHeight = canvasHeight * 100 / this.canvasStyleData.height//
// 使
if (this.backScreenShot) {
this.scaleHeight = this.scaleWidth
} else {
this.scaleHeight = canvasHeight * 100 / this.canvasStyleData.height//
}
this.$store.commit('setPreviewCanvasScale', { scaleWidth: (this.scaleWidth / 100), scaleHeight: (this.scaleHeight / 100) })
this.handleScaleChange()
},
@ -281,7 +310,7 @@ export default {
}
},
handleMouseDown() {
this.$store.commit('setClickComponentStatus', false)
this.$store.commit('setClickComponentStatus', fals)
},
initMobileCanvas() {
this.$store.commit('openMobileLayout')
@ -292,7 +321,6 @@ export default {
<style lang="scss" scoped>
.bg {
padding: 5px;
min-width: 200px;
min-height: 300px;
width: 100%;

View File

@ -1,6 +1,6 @@
<template>
<div v-loading="dataLoading" class="bg">
<Preview v-if="!dataLoading" />
<div v-loading="dataLoading" class="bg" :style="bgStyle">
<Preview v-if="!dataLoading" :back-screen-shot="backScreenShot" @mainHeightChange="mainHeightChange" />
</div>
</template>
<script>
@ -14,16 +14,33 @@ export default {
components: { Preview },
data() {
return {
dataLoading: false
dataLoading: false,
backScreenShot: false,
mainHeight: '100vh!important'
}
},
computed: {
bgStyle() {
if (this.backScreenShot) {
return { height: this.mainHeight }
} else {
return { height: '100vh!important' }
}
}
},
mounted() {
this.restore()
},
methods: {
mainHeightChange(mainHeight) {
this.mainHeight = mainHeight
},
restore() {
this.dataLoading = true
this.panelId = this.$route.path.split('/')[2]
this.panelId = this.$route.params.reportId
if (this.$route.params.backScreenShot !== undefined) {
this.backScreenShot = this.$route.params.backScreenShot
}
//
findOne(this.panelId).then(response => {
this.dataLoading = false

View File

@ -29,7 +29,7 @@ router.beforeEach(async(to, from, next) => {
NProgress.done()
} else {
const hasGetUserInfo = store.getters.name
if (hasGetUserInfo || to.path.indexOf('/preview/') > -1 || to.path.indexOf('/delink') > -1 || to.path.indexOf('/nolic') > -1) {
if (hasGetUserInfo || to.path.indexOf('/previewScreenShot/') > -1 || to.path.indexOf('/preview/') > -1 || to.path.indexOf('/delink') > -1 || to.path.indexOf('/nolic') > -1) {
next()
store.dispatch('permission/setCurrentPath', to.path)
} else {

View File

@ -82,7 +82,11 @@ export const constantRoutes = [
component: () => import('@/components/canvas/components/Editor/PreviewEject'),
hidden: true
},
{
path: '/previewScreenShot/:reportId/:backScreenShot',
component: () => import('@/components/canvas/components/Editor/PreviewEject'),
hidden: true
},
{
path: '/previewFullScreen',
component: () => import('@/components/canvas/components/Editor/PreviewFullScreen'),