From 9b6f1d0995c6aadb2870907e699ba8c06ac982f9 Mon Sep 17 00:00:00 2001 From: shijing Date: Mon, 20 Mar 2023 10:45:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=81=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scOpl/scFire.vue | 30 +++++++++--------- src/utils/html2pdf.js | 54 +++------------------------------ src/utils/preventReClick.js | 2 +- 3 files changed, 21 insertions(+), 65 deletions(-) diff --git a/src/components/scOpl/scFire.vue b/src/components/scOpl/scFire.vue index 76939e7b..f6e1a686 100644 --- a/src/components/scOpl/scFire.vue +++ b/src/components/scOpl/scFire.vue @@ -128,7 +128,7 @@ 检测部位 O₂(%) CO - 可燃气体(V%LEL) + 可燃气体(V%LEL) 检验结论 检测人 检测时间 @@ -171,7 +171,6 @@ {{item.participant_.name}} {{item.participant_str}} - {{ item.update_time }} @@ -259,7 +258,6 @@ }, mounted() { let that = this; - console.log(1, that.id, 2, that.wfId) that.oplId = that.id; //许可证ID that.operationId = that.wfId; //zuoyeID this.$nextTick(()=>{ @@ -268,19 +266,21 @@ that.getgasList(); that.getOperation(); }) - let exportDiv = document.getElementById('exportDiv') // 需要导出部分页面的id名 - this.pdfDownLoader = new PdfLoader(exportDiv, '许可证', 'exportDiv') // fileName -->导出文件名, question-table -->防止被截断的class名 }, methods: { - // handleExport() { - // this.pdfDownLoader.outPutPdfFn('许可证') - // }, - handleExport(){ - let bdHtml = window.document.body.innerHTML; - document.body.innerHTML = document.getElementById('exportDiv').innerHTML; - window.print(); - location.reload(); + handleExport() { + let exportDiv = document.getElementById('exportDiv') // 需要导出部分页面的id名 + this.pdfDownLoader = new PdfLoader(exportDiv, '作业许可证', 'exportDiv') // fileName -->导出文件名, question-table -->防止被截断的class名 + this.pdfDownLoader.outPutPdfFn('许可证'); + exportDiv.style.width = "100%" + }, + // handleExport(){ + // let bdHtml = window.document.body.innerHTML; + // document.body.innerHTML = document.getElementById('exportDiv').innerHTML; + // window.print(); + // location.reload(); + // }, //根据oplId,查许可证 getOplData() { let that = this; @@ -374,7 +374,7 @@ } .tableTh>td:first-child{ flex-shrink:0; - width: 50px; + width: 70px; } .tableTr>td{ min-height: 30px; @@ -383,7 +383,7 @@ } .tableTr>td:first-child{ flex-shrink:0; - width: 50px; + width: 70px; } td{ width: 25%; diff --git a/src/utils/html2pdf.js b/src/utils/html2pdf.js index 25d62649..b11bdb7f 100644 --- a/src/utils/html2pdf.js +++ b/src/utils/html2pdf.js @@ -19,7 +19,9 @@ class PdfLoader { } async getPDF(resolve) { - const ele = this.ele + const ele = this.ele; + let eleme = this.ele; + eleme.style.width="750px"; const pdfFileName = this.pdfFileName const eleW = ele.offsetWidth// 获得该容器的宽 const eleH = ele.scrollHeight// 获得该容器的高 @@ -35,9 +37,9 @@ class PdfLoader { canvas.width = eleW * 2// 将画布宽&&高放大两倍 canvas.height = eleH * 2 const context = canvas.getContext('2d') - context.scale(3, 3) // 增强图片清晰度 + context.scale(2,2) // 增强图片清晰度 context.translate(-eleOffsetLeft , -eleOffsetTop) - html2canvas(ele, { + html2canvas(eleme, { useCORS: true// 允许canvas画布内可以跨域请求外部链接图片, 允许跨域请求。 }).then(async canvas => { const contentWidth = canvas.width @@ -114,51 +116,5 @@ class PdfLoader { }) } } -// export default { -// install(Vue, options) { -// Vue.prototype.getPdf = function(title) { -// var element = document.getElementById("pdfContent") -// var title = title; //PDF文件标题 -// var c = document.createElement("canvas");//创建照片 -// var opts = { -// scale: 2, -// canvas: c, -// logging: true, -// width: element.clientWidth, -// height: element.clientHeight -// }; -// //照片高度和宽度是页面元素的两倍 -// c.width = element.clientWidth * 2 -// c.height = element.clientHeight * 2 -// c.getContext("2d").scale(2, 2); -// html2Canvas(element, opts) -// .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(‘‘, ‘pt‘, ‘a4‘) -// if (leftHeight < pageHeight) { -// //第一个20是img和pdf页面的左边距,第二个20是img与pdf页面的上边距 -// PDF.addImage(pageData, ‘JPEG‘, 20, 20, imgWidth, imgHeight) -// } else { -// while (leftHeight > 0) { -// PDF.addImage(pageData, ‘JPEG‘, 20, position, imgWidth, imgHeight) -// leftHeight -= pageHeight -// position -= 841.89 -// if (leftHeight > 0) { -// PDF.addPage() -// } -// } -// } -// PDF.save(title + ‘.pdf‘) -// }) -// } -// } -// } export default PdfLoader diff --git a/src/utils/preventReClick.js b/src/utils/preventReClick.js index a07e22c4..97aa1e52 100644 --- a/src/utils/preventReClick.js +++ b/src/utils/preventReClick.js @@ -6,7 +6,7 @@ export default (app) => { el.disabled = true setTimeout(() => { el.disabled = false - }, binding.value || 2000) + }, binding.value || 3000) } }) }