|
|
@@ -11,6 +11,12 @@ |
|
|
|
<span class="left-label"> 生成时间: </span> |
|
|
|
<span>{{ objPagesData.createTime }}</span> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div style="display: flex; justify-content: flex-end"> |
|
|
|
<el-button type="primary" style="width: 300px" @click="exportData" |
|
|
|
>导出</el-button |
|
|
|
> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="boxs"> |
|
|
@@ -25,6 +31,7 @@ |
|
|
|
import html2canvas from "html2canvas"; |
|
|
|
import jsPDF from "jspdf"; |
|
|
|
import * as echarts from "echarts"; |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
@@ -162,26 +169,50 @@ export default { |
|
|
|
methods: { |
|
|
|
// 导出 |
|
|
|
exportData() { |
|
|
|
html2canvas(document.getElementById("pdfHtml"), { |
|
|
|
allowTaint: true, |
|
|
|
scale: 1, |
|
|
|
dpi: 300, |
|
|
|
//加上白色背景 |
|
|
|
backgroundColor: "#FFF", |
|
|
|
}).then((canvas) => { |
|
|
|
let contentWidth = canvas.width; |
|
|
|
let contentHeight = canvas.height; |
|
|
|
let pdfX = ((contentWidth + 10) / 1) * 0.75; |
|
|
|
let pdfY = ((contentHeight + 300) / 1) * 0.75; // 500为底部留白 |
|
|
|
let imgWidth = pdfX; |
|
|
|
let imgHeight = (contentHeight / 1) * 0.75; |
|
|
|
let pageData = canvas.toDataURL("image/jpeg", 1.0); |
|
|
|
let PDF = new jsPDF("", "pt", [pdfX, pdfY]); |
|
|
|
PDF.addImage(pageData, "JPEG", 0, 0, imgWidth, imgHeight); |
|
|
|
|
|
|
|
PDF.save(this.objPagesData.name + ".pdf"); |
|
|
|
this.exportMethodPost("autoSR/openApiData/wordText", "AI报告详情", { |
|
|
|
id: this.id, |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 导出.Excel公用方法 |
|
|
|
exportMethodPost(url, name, data = {}) { |
|
|
|
axios({ |
|
|
|
method: "get", |
|
|
|
url: url, |
|
|
|
params: data, |
|
|
|
responseType: "blob", |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
if (!res) { |
|
|
|
this.$message.error("获取数据失败,请稍候再试"); |
|
|
|
return; |
|
|
|
} |
|
|
|
let blob = new Blob([res], { type: "application/vnd.ms-excel" }); |
|
|
|
let date = new Date(); |
|
|
|
let time = date.toLocaleDateString(); |
|
|
|
// console.log(time, "时间"); |
|
|
|
if ("download" in document.createElement("a")) { |
|
|
|
const link = document.createElement("a"); |
|
|
|
link.style.display = "none"; |
|
|
|
link.href = URL.createObjectURL(blob); |
|
|
|
// link.download = res.headers['content-disposition'] //下载后文件名 |
|
|
|
link.download = (name || "导出文件") + time + ".docx"; //下载的文件名 |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
document.body.removeChild(link); |
|
|
|
} else { |
|
|
|
// console.log("--------------------jingla") |
|
|
|
let fileName = (name || "导出文件") + time + ".docx"; //下载的文件名 |
|
|
|
navigator.msSaveBlob(blob, fileName); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch((error) => { |
|
|
|
// Message.error({ |
|
|
|
// message: '网络连接错误' |
|
|
|
// }) |
|
|
|
console.log(error); |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 获取该公司下的项目 |
|
|
|
getProjectList() { |
|
|
|
this.$api.http |
|
|
|