From 8a9530d8136aa467dc4bfa3844290b282ca1edd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E7=BB=A7=E7=BB=AD=E5=90=B9?= <17611323298@163.com> Date: Fri, 8 Dec 2023 15:31:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Statistics/Insightintothedetails.vue | 3 +- src/views/Statistics/ai/createReport.vue | 19 ++++-- src/views/Statistics/ai/reportDetail.vue | 67 ++++++++++++++----- 3 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/views/Statistics/Insightintothedetails.vue b/src/views/Statistics/Insightintothedetails.vue index 866b7fd..44853b5 100644 --- a/src/views/Statistics/Insightintothedetails.vue +++ b/src/views/Statistics/Insightintothedetails.vue @@ -167,8 +167,7 @@ export default { let minTime = this.pickerMinDate - day1; return ( time.getTime() >= maxTime || - time.getTime() <= minTime || - time.getTime() >= Date.now() - 1 * 24 * 3600 * 1000 + time.getTime() <= minTime ); } else { return time.getTime() > Date.now() - 1 * 24 * 3600 * 1000; diff --git a/src/views/Statistics/ai/createReport.vue b/src/views/Statistics/ai/createReport.vue index cc469ee..3c98d1c 100644 --- a/src/views/Statistics/ai/createReport.vue +++ b/src/views/Statistics/ai/createReport.vue @@ -46,7 +46,7 @@ " :on-remove=" (file, fileList) => { - handleChange(file, fileList, 'system'); + handleChanges(file, fileList, 'system'); } " :file-list="system" @@ -75,7 +75,7 @@ " :on-remove=" (file, fileList) => { - handleChange(file, fileList, 'user'); + handleChanges(file, fileList, 'user'); } " :accept="acceptList" @@ -104,7 +104,7 @@ " :on-remove=" (file, fileList) => { - handleChange(file, fileList, 'assistant'); + handleChanges(file, fileList, 'assistant'); } " :accept="acceptList" @@ -590,6 +590,11 @@ export default { }, methods: { + // 文件上传成功 + handleChanges(file, filelist, name) { + console.log(file, filelist, name); + this[name] = filelist; + }, // 文件上传成功 handleChange(file, filelist, name) { console.log(file, filelist, name); @@ -749,10 +754,10 @@ export default { // 生成报告规则 creatMonthRule() { - if (this.assistant.length == 0) { - this.$message.error("请上传期望的回应"); - return; - } + // if (this.assistant.length == 0) { + // this.$message.error("请上传期望的回应"); + // return; + // } let obj = { system: this.system, user: this.user, diff --git a/src/views/Statistics/ai/reportDetail.vue b/src/views/Statistics/ai/reportDetail.vue index c817ba6..afaa810 100644 --- a/src/views/Statistics/ai/reportDetail.vue +++ b/src/views/Statistics/ai/reportDetail.vue @@ -11,6 +11,12 @@ 生成时间: {{ objPagesData.createTime }} + +
+ 导出 +
@@ -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