Merge pull request #3968 from dataease/pr@dev@fix_pdf-export

fix(仪表板): 缩小pdf图片尺寸,防止超长仪表板超出pdf最大长度出现截断情况
This commit is contained in:
Junjun 2022-11-30 17:00:34 +08:00 committed by GitHub
commit 51bdf115ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,14 @@
<el-button
size="mini"
@click="cancel()"
>{{ $t('commons.cancel') }}</el-button>
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="primary"
size="mini"
@click="save()"
>{{ $t('panel.export_pdf') }}</el-button>
>{{ $t('panel.export_pdf') }}
</el-button>
</el-row>
</el-row>
</template>
@ -41,7 +43,7 @@ import { pdfTemplateReplaceAll } from '@/utils/StringUtils.js'
export default {
name: 'PDFPreExport',
components: { },
components: {},
props: {
// eslint-disable-next-line vue/require-default-prop
panelName: {
@ -131,16 +133,16 @@ export default {
_this.toExport = true
setTimeout(() => {
html2canvas(document.getElementById('exportPdf')).then(function(canvas) {
_this.exportLoading = false
const contentWidth = canvas.width
const contentHeight = canvas.height
const pageData = canvas.toDataURL('image/jpeg', 1.0)
const lp = contentWidth > contentHeight ? 'l' : 'p'
const PDF = new JsPDF(lp, 'pt', [contentWidth, contentHeight])
PDF.addImage(pageData, 'JPEG', 0, 0, contentWidth, contentHeight)
PDF.save(_this.panelName + '.pdf')
_this.$emit('closePreExport')
}
_this.exportLoading = false
const contentWidth = canvas.width / 4
const contentHeight = canvas.height / 4
const pageData = canvas.toDataURL('image/jpeg', 1.0)
const lp = contentWidth > contentHeight ? 'l' : 'p'
const PDF = new JsPDF(lp, 'pt', [contentWidth, contentHeight])
PDF.addImage(pageData, 'JPEG', 0, 0, contentWidth, contentHeight)
PDF.save(_this.panelName + '.pdf')
_this.$emit('closePreExport')
}
)
}, 1500)
}, 500)
@ -151,17 +153,18 @@ export default {
</script>
<style scoped>
.root_class {
margin: 15px 0px 5px;
text-align: center;
}
.export_body_class{
border: 1px solid #dcdfe6 ;
height: 65vh;
overflow-y: auto;
}
.root_class {
margin: 15px 0px 5px;
text-align: center;
}
.export_body_inner_class{
margin: 10px;
}
.export_body_class {
border: 1px solid #dcdfe6;
height: 65vh;
overflow-y: auto;
}
.export_body_inner_class {
margin: 10px;
}
</style>