forked from github/dataease
Merge pull request #3879 from dataease/pr@dev@fix_pdf-export
fix(仪表板): 修复仪表板导出PDF水印不全或者没有水印的问题
This commit is contained in:
commit
fb34ee2c2e
@ -189,7 +189,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
canvasInfoTemp: 'preview-temp-canvas-main',
|
mainHeightCount: null,
|
||||||
|
userInfo: null,
|
||||||
previewMainDomId: 'preview-main-' + this.canvasId,
|
previewMainDomId: 'preview-main-' + this.canvasId,
|
||||||
previewDomId: 'preview-' + this.canvasId,
|
previewDomId: 'preview-' + this.canvasId,
|
||||||
previewRefId: 'preview-ref-' + this.canvasId,
|
previewRefId: 'preview-ref-' + this.canvasId,
|
||||||
@ -230,6 +231,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
screenShotStatues() {
|
||||||
|
return this.exporting || this.screenShot || this.backScreenShot
|
||||||
|
},
|
||||||
mainActiveName() {
|
mainActiveName() {
|
||||||
return this.$store.state.panel.mainActiveName
|
return this.$store.state.panel.mainActiveName
|
||||||
},
|
},
|
||||||
@ -345,6 +349,18 @@ export default {
|
|||||||
this.canvasStyleDataInit()
|
this.canvasStyleDataInit()
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
},
|
||||||
|
mainHeight: {
|
||||||
|
handler(newVal, oldVla) {
|
||||||
|
const _this = this
|
||||||
|
_this.$nextTick(() => {
|
||||||
|
if (_this.screenShotStatues) {
|
||||||
|
_this.initWatermark('preview-temp-canvas-main')
|
||||||
|
} else {
|
||||||
|
_this.initWatermark()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -377,13 +393,17 @@ export default {
|
|||||||
bus.$off('trigger-reset-button', this.triggerResetButton)
|
bus.$off('trigger-reset-button', this.triggerResetButton)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initWatermark() {
|
initWatermark(waterDomId = 'preview-main-canvas-main') {
|
||||||
if (this.panelInfo.watermarkInfo && this.canvasId === 'canvas-main') {
|
if (this.panelInfo.watermarkInfo && this.canvasId === 'canvas-main') {
|
||||||
|
if (this.userInfo) {
|
||||||
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen)
|
||||||
|
} else {
|
||||||
userLoginInfo().then(res => {
|
userLoginInfo().then(res => {
|
||||||
const userInfo = res.data
|
this.userInfo = res.data
|
||||||
activeWatermark(this.panelInfo.watermarkInfo.settingContent, userInfo, 'preview-main-canvas-main', this.canvasId, this.panelInfo.watermarkOpen)
|
activeWatermark(this.panelInfo.watermarkInfo.settingContent, this.userInfo, waterDomId, this.canvasId, this.panelInfo.watermarkOpen)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isMainCanvas() {
|
isMainCanvas() {
|
||||||
return this.canvasId === 'canvas-main'
|
return this.canvasId === 'canvas-main'
|
||||||
@ -606,6 +626,7 @@ export default {
|
|||||||
_this.$nextTick(() => {
|
_this.$nextTick(() => {
|
||||||
// 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题
|
// 将mainHeight 修改为px 临时解决html2canvas 截图不全的问题
|
||||||
_this.mainHeight = tempCanvas.scrollHeight + 'px!important'
|
_this.mainHeight = tempCanvas.scrollHeight + 'px!important'
|
||||||
|
_this.mainHeightCount = tempCanvas.scrollHeight
|
||||||
this.$emit('mainHeightChange', _this.mainHeight)
|
this.$emit('mainHeightChange', _this.mainHeight)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -623,14 +644,7 @@ export default {
|
|||||||
|
|
||||||
document.getElementById('preview-canvas-main').style.height = (scrollHeight + 'px')
|
document.getElementById('preview-canvas-main').style.height = (scrollHeight + 'px')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const timer = setInterval(() => {
|
html2canvas(document.getElementById(domId)).then(canvas => {
|
||||||
const containerDom = document.getElementById(domId)
|
|
||||||
const masks = containerDom.getElementsByClassName('el-loading-mask')
|
|
||||||
const mapLoadingArr = containerDom.getElementsByClassName('.symbol-map-loading')
|
|
||||||
if (masks?.length) {
|
|
||||||
const hideMasks = [...masks].filter(item => item.style?.display === 'none')
|
|
||||||
if (masks.length === hideMasks.length && !mapLoadingArr?.length) {
|
|
||||||
html2canvas(containerDom).then(canvas => {
|
|
||||||
const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量
|
const snapshot = canvas.toDataURL('image/jpeg', 1) // 是图片质量
|
||||||
this.dataLoading = false
|
this.dataLoading = false
|
||||||
this.$emit('change-load-status', false)
|
this.$emit('change-load-status', false)
|
||||||
@ -641,10 +655,6 @@ export default {
|
|||||||
this.pdfExportShow = true
|
this.pdfExportShow = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
clearInterval(timer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
}, 2500)
|
}, 2500)
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user