forked from github/dataease
Merge pull request #4123 from dataease/pr@dev@refactor_panel-pdf
refactor(仪表板): 超长仪表板导出PDF、图片优化
This commit is contained in:
commit
be5ced54f5
@ -444,6 +444,9 @@ export default {
|
|||||||
bus.$off('trigger-reset-button', this.triggerResetButton)
|
bus.$off('trigger-reset-button', this.triggerResetButton)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getCanvasHeight() {
|
||||||
|
return this.mainHeightCount
|
||||||
|
},
|
||||||
openChartDetailsDialog(paramInfo) {
|
openChartDetailsDialog(paramInfo) {
|
||||||
if (this.canvasId === 'canvas-main') {
|
if (this.canvasId === 'canvas-main') {
|
||||||
this.showChartInfo = paramInfo.showChartInfo
|
this.showChartInfo = paramInfo.showChartInfo
|
||||||
|
@ -82,7 +82,7 @@ export default {
|
|||||||
mainCanvasStyle() {
|
mainCanvasStyle() {
|
||||||
if (this.toExport) {
|
if (this.toExport) {
|
||||||
return {
|
return {
|
||||||
width: '4096px'
|
width: '1280px'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@ -93,7 +93,7 @@ export default {
|
|||||||
templateHtmlStyle() {
|
templateHtmlStyle() {
|
||||||
if (this.toExport) {
|
if (this.toExport) {
|
||||||
return {
|
return {
|
||||||
fontSize: '48px!important'
|
fontSize: '14px!important'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {}
|
return {}
|
||||||
@ -134,8 +134,8 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
html2canvas(document.getElementById('exportPdf')).then(function(canvas) {
|
html2canvas(document.getElementById('exportPdf')).then(function(canvas) {
|
||||||
_this.exportLoading = false
|
_this.exportLoading = false
|
||||||
const contentWidth = canvas.width / 4
|
const contentWidth = canvas.width / 2
|
||||||
const contentHeight = canvas.height / 4
|
const contentHeight = canvas.height / 2
|
||||||
const pageData = canvas.toDataURL('image/jpeg', 1.0)
|
const pageData = canvas.toDataURL('image/jpeg', 1.0)
|
||||||
const lp = contentWidth > contentHeight ? 'l' : 'p'
|
const lp = contentWidth > contentHeight ? 'l' : 'p'
|
||||||
const PDF = new JsPDF(lp, 'pt', [contentWidth, contentHeight])
|
const PDF = new JsPDF(lp, 'pt', [contentWidth, contentHeight])
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
style="border-bottom: 1px solid;border-bottom-color:#E6E6E6;"
|
style="border-bottom: 1px solid;border-bottom-color:#E6E6E6;"
|
||||||
>
|
>
|
||||||
<div style="height: 100%;">
|
<div style="height: 100%;">
|
||||||
<share-head />
|
<share-head/>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row
|
<el-row
|
||||||
@ -76,7 +76,7 @@
|
|||||||
width="400"
|
width="400"
|
||||||
trigger="click"
|
trigger="click"
|
||||||
>
|
>
|
||||||
<panel-detail-info />
|
<panel-detail-info/>
|
||||||
<i
|
<i
|
||||||
slot="reference"
|
slot="reference"
|
||||||
class="el-icon-warning-outline icon-class"
|
class="el-icon-warning-outline icon-class"
|
||||||
@ -240,6 +240,7 @@
|
|||||||
>
|
>
|
||||||
<Preview
|
<Preview
|
||||||
v-if="showMainFlag"
|
v-if="showMainFlag"
|
||||||
|
ref="paneViewPreviewRef"
|
||||||
:component-data="mainCanvasComponentData"
|
:component-data="mainCanvasComponentData"
|
||||||
:canvas-style-data="canvasStyleData"
|
:canvas-style-data="canvasStyleData"
|
||||||
:active-tab="activeTab"
|
:active-tab="activeTab"
|
||||||
@ -429,8 +430,8 @@ export default {
|
|||||||
imageWrapperStyle() {
|
imageWrapperStyle() {
|
||||||
if (this.exporting) {
|
if (this.exporting) {
|
||||||
return {
|
return {
|
||||||
width: '2560px',
|
width: '1280px',
|
||||||
height: '1440px'
|
height: '720px'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
@ -480,6 +481,16 @@ export default {
|
|||||||
bus.$off('set-panel-share-user', this.setPanelShareUser)
|
bus.$off('set-panel-share-user', this.setPanelShareUser)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 画布高度大于6000px 自动使用原尺寸导出 减小浏览器再渲染压力
|
||||||
|
changeExportingState() {
|
||||||
|
const canvasHeight = this.$refs.paneViewPreviewRef.getCanvasHeight()
|
||||||
|
if (canvasHeight && canvasHeight > 6000) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
downLoadApp(appAttachInfo) {
|
downLoadApp(appAttachInfo) {
|
||||||
this.downLoadToApp(appAttachInfo)
|
this.downLoadToApp(appAttachInfo)
|
||||||
},
|
},
|
||||||
@ -660,7 +671,7 @@ export default {
|
|||||||
downloadAsImage() {
|
downloadAsImage() {
|
||||||
this.dataLoading = true
|
this.dataLoading = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.exporting = true
|
this.exporting = this.changeExportingState()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const canvasID = document.getElementById(this.canvasInfoTemp)
|
const canvasID = document.getElementById(this.canvasInfoTemp)
|
||||||
const a = document.createElement('a')
|
const a = document.createElement('a')
|
||||||
@ -691,7 +702,7 @@ export default {
|
|||||||
this.dataLoading = true
|
this.dataLoading = true
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.exporting = true
|
this.exporting = this.changeExportingState()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
html2canvas(document.getElementById(this.canvasInfoTemp)).then(canvas => {
|
html2canvas(document.getElementById(this.canvasInfoTemp)).then(canvas => {
|
||||||
const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量
|
const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量
|
||||||
|
Loading…
Reference in New Issue
Block a user