|
|
|
@ -4749,27 +4749,47 @@ export default {
|
|
|
|
|
|
|
|
|
|
/* 打印 */
|
|
|
|
|
printOutpdf() {
|
|
|
|
|
let name = `${this.templateInfo.templateName}_${this.baseInfo.enterpriseName}`;
|
|
|
|
|
let domName = this.$refs.pdf;
|
|
|
|
|
let _this = this;
|
|
|
|
|
|
|
|
|
|
let targetDom = domName; //原本需要截图的div
|
|
|
|
|
let clonedNode = targetDom.cloneNode(true); //复制一个
|
|
|
|
|
clonedNode.setAttribute(
|
|
|
|
|
"style",
|
|
|
|
|
`width: ${targetDom.clientHeight};height: ${targetDom.clientWidth};`
|
|
|
|
|
);
|
|
|
|
|
document.body.appendChild(clonedNode); //放到body后面
|
|
|
|
|
|
|
|
|
|
html2canvas(clonedNode, {
|
|
|
|
|
allowTaint: true,
|
|
|
|
|
taintTest: false,
|
|
|
|
|
}).then((canvas) => {
|
|
|
|
|
let canvasImg = canvas.toDataURL("image/png");
|
|
|
|
|
_this.downLoadFile(name, canvasImg);
|
|
|
|
|
document.body.removeChild(clonedNode);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
let name = ''
|
|
|
|
|
name = `${this.templateInfo.templateName}_${this.baseInfo.enterpriseName}`
|
|
|
|
|
let modalDiv = this.$refs.pdf
|
|
|
|
|
let newDiv = modalDiv.cloneNode(true)
|
|
|
|
|
newDiv.classList.remove('detail_content');
|
|
|
|
|
newDiv.id = 'reportId'
|
|
|
|
|
let newTwoDiv = document.createElement('div');
|
|
|
|
|
newTwoDiv.id = 'detail_content_two'
|
|
|
|
|
document.body.appendChild(newTwoDiv)
|
|
|
|
|
newTwoDiv.appendChild(newDiv)
|
|
|
|
|
let obj = document.getElementById('reportId')
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
html2canvas(obj).then(function(canvas) {
|
|
|
|
|
let contentWidth = canvas.width
|
|
|
|
|
let contentHeight = canvas.height
|
|
|
|
|
let pageHeight = contentWidth / 592.28 * 841.89
|
|
|
|
|
let leftHeight = contentHeight
|
|
|
|
|
let position = 0
|
|
|
|
|
let imgWidth = 595.28
|
|
|
|
|
let imgHeight = 592.28 / contentWidth * contentHeight
|
|
|
|
|
let pageData = canvas.toDataURL('image/jpeg', 1.0)
|
|
|
|
|
let PDF = new JsPDF('p', 'pt', 'a4') // [592.28 * 841.89]
|
|
|
|
|
console.log(pageData);
|
|
|
|
|
if (leftHeight < pageHeight) {
|
|
|
|
|
PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)
|
|
|
|
|
} else {
|
|
|
|
|
// 5 为误差值
|
|
|
|
|
while (leftHeight > 5) {
|
|
|
|
|
PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)
|
|
|
|
|
leftHeight -= pageHeight
|
|
|
|
|
position -= 841.89
|
|
|
|
|
if (leftHeight > 5) {
|
|
|
|
|
PDF.addPage()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PDF.save(name + '.pdf')
|
|
|
|
|
newTwoDiv.remove()
|
|
|
|
|
})
|
|
|
|
|
},200)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
@ -5067,7 +5087,7 @@ li {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form {
|
|
|
|
|
height: calc(100% - 150px);
|
|
|
|
|
// height: calc(100% - 150px);
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
padding: 15px;
|
|
|
|
|
.table-content {
|
|
|
|
|