From 78925fba6f73628f8c7bc1871a06ad70d54bcfcc Mon Sep 17 00:00:00 2001 From: xzt <1113240624@qq.com> Date: Fri, 15 Sep 2023 17:57:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E9=A2=98=E7=AE=A1=E7=90=86=E6=9D=BF?= =?UTF-8?q?=E5=9D=97=E6=96=87=E4=BB=B6=E7=9A=84=E4=B8=8A=E4=BC=A0=E4=B8=8E?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/special/options/ContractPage.vue | 17 ++++++++++ .../project/special/options/documentPage.vue | 19 ++++++++++- .../project/special/options/resultsPage.vue | 19 ++++++++++- .../project/special/options/taskPage.vue | 34 +++++++++++++++++-- 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/jwtech-admin-page/src/views/project/special/options/ContractPage.vue b/jwtech-admin-page/src/views/project/special/options/ContractPage.vue index 68e37b1d..eaf54ab3 100644 --- a/jwtech-admin-page/src/views/project/special/options/ContractPage.vue +++ b/jwtech-admin-page/src/views/project/special/options/ContractPage.vue @@ -232,6 +232,7 @@ import { } from "@/api/earlyStage/contract"; import { getToken } from "@/utils/auth"; import { v4 as uuidv4 } from "uuid"; +import { getFileStream } from "@/api/system/upload"; export default { props: ["proNo"], @@ -470,6 +471,7 @@ export default { console.log("fileList", fileList); this.contractFileList.push({ name: fileList.name, + fileName: fileList.response.fileName, url: fileList.response.url, uid: fileList.uid, // fileList: fileList, @@ -483,8 +485,23 @@ export default { // 删除文件 this.contractFileList.splice(index, 1); }, + // 点击预览的文件进行下载 handlePreview(file) { console.log(file); + getFileStream({ fileName: file.fileName }).then((res) => { + const blob = new Blob([res], { + // type类型后端返回来的数据中会有,根据自己实际进行修改 + // 表格下载为 application/xlsx,压缩包为 application/zip等, + type: "application/xlsx", + }); //excel,pdf等 + const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象 + const a = document.createElement("a"); //创建a标签 + a.style.display = "none"; + a.href = href; // 指定下载链接 + a.download = file.name; //指定下载文件名 + a.click(); //触发下载 + URL.revokeObjectURL(a.href); //释放URL对象 + }); }, handleExceed(files, fileList) { this.$message.warning( diff --git a/jwtech-admin-page/src/views/project/special/options/documentPage.vue b/jwtech-admin-page/src/views/project/special/options/documentPage.vue index c1591e3f..bb0db653 100644 --- a/jwtech-admin-page/src/views/project/special/options/documentPage.vue +++ b/jwtech-admin-page/src/views/project/special/options/documentPage.vue @@ -241,6 +241,7 @@ import { updateDocument, exportDocument, } from "@/api/earlyStage/document"; +import { getFileStream } from "@/api/system/upload"; export default { props: ["proNo"], data() { @@ -479,6 +480,7 @@ export default { console.log("fileList", fileList); this.acceptDocumentFileList.push({ name: fileList.name, + fileName: fileList.response.fileName, url: fileList.response.url, uid: fileList.uid, }); @@ -500,8 +502,23 @@ export default { // 删除文件 this.acceptDocumentFileList.splice(index, 1); }, + // 点击预览的文件进行下载 handlePreview(file) { - console.log(file); + // console.log(file); + getFileStream({ fileName: file.fileName }).then((res) => { + const blob = new Blob([res], { + // type类型后端返回来的数据中会有,根据自己实际进行修改 + // 表格下载为 application/xlsx,压缩包为 application/zip等, + type: "application/xlsx", + }); //excel,pdf等 + const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象 + const a = document.createElement("a"); //创建a标签 + a.style.display = "none"; + a.href = href; // 指定下载链接 + a.download = file.name; //指定下载文件名 + a.click(); //触发下载 + URL.revokeObjectURL(a.href); //释放URL对象 + }); }, handleExceed(files, fileList) { this.$message.warning( diff --git a/jwtech-admin-page/src/views/project/special/options/resultsPage.vue b/jwtech-admin-page/src/views/project/special/options/resultsPage.vue index 1ae3b2d2..50294fac 100644 --- a/jwtech-admin-page/src/views/project/special/options/resultsPage.vue +++ b/jwtech-admin-page/src/views/project/special/options/resultsPage.vue @@ -326,6 +326,7 @@ import { exportGain, } from "@/api/earlyStage/gain"; import { getToken } from "@/utils/auth"; +import { getFileStream } from "@/api/system/upload"; export default { props: ["proNo"], data() { @@ -564,6 +565,7 @@ export default { console.log("fileList", fileList); this.resultsFileList.push({ name: fileList.name, + fileName: fileList.response.fileName, url: fileList.response.url, uid: fileList.uid, // fileList: fileList, @@ -578,8 +580,23 @@ export default { // 删除文件 this.resultsFileList.splice(index, 1); }, + // 点击预览的文件进行下载 handlePreview(file) { - console.log(file); + // console.log(file); + getFileStream({ fileName: file.fileName }).then((res) => { + const blob = new Blob([res], { + // type类型后端返回来的数据中会有,根据自己实际进行修改 + // 表格下载为 application/xlsx,压缩包为 application/zip等, + type: "application/xlsx", + }); //excel,pdf等 + const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象 + const a = document.createElement("a"); //创建a标签 + a.style.display = "none"; + a.href = href; // 指定下载链接 + a.download = file.name; //指定下载文件名 + a.click(); //触发下载 + URL.revokeObjectURL(a.href); //释放URL对象 + }); }, handleExceed(files, fileList) { this.$message.warning( diff --git a/jwtech-admin-page/src/views/project/special/options/taskPage.vue b/jwtech-admin-page/src/views/project/special/options/taskPage.vue index 82451064..99084959 100644 --- a/jwtech-admin-page/src/views/project/special/options/taskPage.vue +++ b/jwtech-admin-page/src/views/project/special/options/taskPage.vue @@ -637,9 +637,23 @@ export default { // 删除文件 this.projectFileList.splice(index, 1); }, + // 点击预览下载文件 handleProjectPreview(file) { - console.log(file.fileName); - getFileStream({ fileName: file.fileName }); + // console.log(file); + getFileStream({ fileName: file.fileName }).then((res) => { + const blob = new Blob([res], { + // type类型后端返回来的数据中会有,根据自己实际进行修改 + // 表格下载为 application/xlsx,压缩包为 application/zip等, + type: "application/xlsx", + }); //excel,pdf等 + const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象 + const a = document.createElement("a"); //创建a标签 + a.style.display = "none"; + a.href = href; // 指定下载链接 + a.download = file.name; //指定下载文件名 + a.click(); //触发下载 + URL.revokeObjectURL(a.href); //释放URL对象 + }); }, handleProjectExceed(files, fileList) { this.$message.warning( @@ -671,7 +685,21 @@ export default { this.opinionFileList.splice(index, 1); }, handleOpinionPreview(file) { - console.log(file); + // console.log(file); + getFileStream({ fileName: file.fileName }).then((res) => { + const blob = new Blob([res], { + // type类型后端返回来的数据中会有,根据自己实际进行修改 + // 表格下载为 application/xlsx,压缩包为 application/zip等, + type: "application/xlsx", + }); //excel,pdf等 + const href = URL.createObjectURL(blob); //创建新的URL表示指定的blob对象 + const a = document.createElement("a"); //创建a标签 + a.style.display = "none"; + a.href = href; // 指定下载链接 + a.download = file.name; //指定下载文件名 + a.click(); //触发下载 + URL.revokeObjectURL(a.href); //释放URL对象 + }); }, handleOpinionExceed(files, fileList) { this.$message.warning(