NEZ-1788 fix: panel页面整页导出

This commit is contained in:
zhangyu
2022-04-08 13:48:49 +08:00
parent 71d2a0a43f
commit 6fd326949f
5 changed files with 24 additions and 10 deletions

View File

@@ -168,6 +168,7 @@ export default {
obj[column.title + 'mapping'] = '' obj[column.title + 'mapping'] = ''
if (this.chartInfo.param.enable && this.chartInfo.param.enable.valueMapping) { if (this.chartInfo.param.enable && this.chartInfo.param.enable.valueMapping) {
valueMapping[column.title].forEach(item => { valueMapping[column.title].forEach(item => {
// const rowValue = row.display[column.title + 'display']
const rowValue = row.display[column.title + 'display'] const rowValue = row.display[column.title + 'display']
if (item.type === 'value') { if (item.type === 'value') {
if (rowValue == item.value) { if (rowValue == item.value) {

View File

@@ -3,6 +3,7 @@
<grid-layout <grid-layout
ref="layout" ref="layout"
v-if="gridLayoutShow" v-if="gridLayoutShow"
class="pdfDom"
:class="firstInit ? 'no-animation' : ''" :class="firstInit ? 'no-animation' : ''"
:col-num="12" :col-num="12"
:is-draggable="!panelLock" :is-draggable="!panelLock"

View File

@@ -16,7 +16,7 @@ export default {
// height: 240, //canvas高度 // height: 240, //canvas高度
x: x || 0, // x坐标 需要计算 x: x || 0, // x坐标 需要计算
y: y || 0, // y坐标 需要计算 y: y || 0, // y坐标 需要计算
async: true, // 是否异步解析和呈现元素 async: false, // 是否异步解析和呈现元素
foreignObjectRendering: true // 是否在浏览器支持的情况下使用ForeignObject渲染 foreignObjectRendering: true // 是否在浏览器支持的情况下使用ForeignObject渲染
}).then(function (canvas) { }).then(function (canvas) {
loading.close() loading.close()
@@ -38,7 +38,7 @@ export default {
PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight) PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
} else { } else {
while (leftHeight > 0) { while (leftHeight > 0) {
PDF.addImage(pageData, 'JPEG', 20, position, imgWidth, imgHeight) PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
leftHeight -= pageHeight leftHeight -= pageHeight
position -= 841.89 position -= 841.89
if (leftHeight > 0) { if (leftHeight > 0) {

View File

@@ -1,3 +1,13 @@
export default { export default {
methods: {
htmlToPdf () {
const dom = document.getElementsByClassName(this.pdfId)[0]
if (dom) {
this.showScreenLoading(true)
this.getPdf(dom)
} else {
this.showScreenLoading(false)
}
}
}
} }

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="panel list-page" v-my-loading="panelTabLoading"> <div class="panel list-page" v-loading="panelTabLoading">
<div class="main-list"> <div class="main-list">
<div> <div>
<transition name="el-zoom-in-center"> <transition name="el-zoom-in-center">
@@ -75,7 +75,7 @@
<div id="chart-temp-sync" @click="chartBySync"><i class="nz-icon nz-icon-sync"></i>{{ $t('overall.syncChart') }}</div> <div id="chart-temp-sync" @click="chartBySync"><i class="nz-icon nz-icon-sync"></i>{{ $t('overall.syncChart') }}</div>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item v-has="'main_add'"> <el-dropdown-item v-has="'main_add'">
<div id="chart-htmltopdf" @click="htmlToPdf"><i class="nz-icon nz-icon-sync"></i>{{ $t('overall.syncChart') }}</div> <div id="chart-htmltopdf" @click="htmlToPdf"><i class="nz-icon nz-icon-download1"></i>{{ $t('overall.downloadToPdf') }}</div>
</el-dropdown-item> </el-dropdown-item>
</template> </template>
</top-tool-more-options> </top-tool-more-options>
@@ -84,7 +84,7 @@
</div> </div>
<div id="tableList" class="table-list" style='overflow-y: unset'> <div id="tableList" class="table-list" style='overflow-y: unset'>
<div class="table-list-box"> <div class="table-list-box">
<div id="dashboardScrollbar" class="box-content" v-my-loading="chartListLoading" ref="dashboardScrollbar" style='overflow-y: auto'> <div id="dashboardScrollbar" class="box-content" v-loading="chartListLoading" ref="dashboardScrollbar" style='overflow-y: auto'>
<chart-list <chart-list
ref="chartList" ref="chartList"
name="panel" name="panel"
@@ -126,7 +126,7 @@
<!-- ></chart-box>--> <!-- ></chart-box>-->
<chart-right-box <chart-right-box
v-if="chartRightBoxShow" v-if="chartRightBoxShow"
v-my-loading="rightBox.loading" v-loading="rightBox.loading"
ref="addChartModal" ref="addChartModal"
:chart="chart" :chart="chart"
:from="fromRoute.panel" :from="fromRoute.panel"
@@ -834,7 +834,7 @@ export default {
htmlToPdf () { htmlToPdf () {
let dom = document.getElementsByClassName(this.pdfId)[0] let dom = document.getElementsByClassName(this.pdfId)[0]
if (dom) { if (dom) {
dom = dom.getElementsByClassName('vue-grid-layout')[0] // dom = dom.getElementsByClassName('vue-grid-layout')[0]
this.scrollbarWrap.scrollTop = this.scrollbarWrap.scrollHeight this.scrollbarWrap.scrollTop = this.scrollbarWrap.scrollHeight
this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop) this.$refs.chartList.onScroll(this.scrollbarWrap.scrollTop)
let flag = true let flag = true
@@ -855,10 +855,12 @@ export default {
timer = null timer = null
setTimeout(() => { setTimeout(() => {
document.body.style.height = 'auto' document.body.style.height = 'auto'
document.getElementsByTagName('html')[0].style.overflow = 'visible' // document.getElementsByTagName('html')[0].style.overflow = 'visible'
const position = dom.getBoundingClientRect() const position = dom.getBoundingClientRect()
console.log(position)
this.getPdf(dom, -1 * position.left, -1 * position.top) this.getPdf(dom, -1 * position.left, -1 * position.top)
}, 500) // this.getPdf(dom, 0, 0)
}, 2000)
} }
}, 200) }, 200)
} else { } else {