diff --git a/src/utils/zipdownload.js b/src/utils/zipdownload.js new file mode 100644 index 00000000..d42e85c2 --- /dev/null +++ b/src/utils/zipdownload.js @@ -0,0 +1,36 @@ +import axios from 'axios' +import {getCookieForName} from "@/api/method"; + +const mimeMap = { + xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + zip: 'application/zip' +} + +const baseUrl = process.env.VUE_APP_ACT_API +export function downLoadZip(str, filename) { + var url = baseUrl + str + axios({ + method: 'get', + url: url, + responseType: 'blob', + headers: { 'Authorization': 'Bearer ' + getCookieForName("token") } + }).then(res => { + resolveBlob(res, mimeMap.zip,filename) + }) +} +/** + * 解析blob响应内容并下载 + * @param {*} res blob响应内容 + * @param {String} mimeType MIME类型 + */ +export function resolveBlob(res, mimeType,filename) { + const link = document.createElement('a');// 创建a标签 + let blob = new Blob([res.data], { type: mimeType }); // 设置文件类型 + link.style.display = "none"; + link.href = URL.createObjectURL(blob); // 创建URL + link.setAttribute("download", `${filename}`); + document.body.appendChild(link); + link.click(); + URL.revokeObjectURL(link.href); + document.body.removeChild(link); +} diff --git a/src/views/evaluation/EvaDown.vue b/src/views/evaluation/EvaDown.vue index cda8484d..a502f703 100644 --- a/src/views/evaluation/EvaDown.vue +++ b/src/views/evaluation/EvaDown.vue @@ -69,6 +69,7 @@ import { useRoute } from "vue-router"; import { message } from "ant-design-vue"; import { useStore } from "vuex"; import {boeRequest} from "@/api/request"; +import {downLoadZip} from "@/utils/zipdownload"; export default { name: "evadown", components: {}, @@ -165,7 +166,8 @@ import {boeRequest} from "@/api/request"; message.info('请先上传报告') return } - window.open(`/activityApi/evaluation/download?id=${route.query.id}`); + // window.open(`/activityApi/evaluation/download?id=${route.query.id}`); + downLoadZip(`/evaluation/download?id=${route.query.id}`,route.query.name) } const listData = async () => { state.tableLoading = true diff --git a/src/views/evaluation/evaluationUpload.vue b/src/views/evaluation/evaluationUpload.vue index 153daf2b..5fd58aca 100644 --- a/src/views/evaluation/evaluationUpload.vue +++ b/src/views/evaluation/evaluationUpload.vue @@ -161,7 +161,7 @@
+ :before-upload="beforeUpload" @change="handleChangeImg"> avatar
@@ -177,15 +177,13 @@
-
-
上传说明
+
+
备注
- - 1、仅支持1个zip压缩包和pdf报告上传;
- 2、单个附件命名规则:测评名称+姓名+工号(名称中间用英文输入法-连接)例如:大五职业性格测评-李玉冰-00004409.pdf -
+
+
@@ -235,9 +233,12 @@ :class="`${{uploading: 'updatacolor3', done: 'updatacolor' ,error: 'updatacolor2'}[item.status] || 'updatacolor'}`" :style="{width:`${item.status==='uploading'?parseInt(item.percent):100}%`}">
- {{ {uploading: '正在上传', done: '上传完成', error: '上传失败'}[item.status] || '' }} + {{ {uploading: '正在上传', done: '上传完成', error: '报告错误'}[item.status] || '' }} + + 下载 +
@@ -245,16 +246,19 @@
-
- 删除 +
+
-
-
备注
+
+
上传说明
- + + 1、仅支持1个zip压缩包和pdf报告上传;
+ 2、单个附件命名规则:测评名称+姓名+工号(名称中间用英文输入法-连接)例如:大五职业性格测评-李玉冰-00004409.pdf +
上传结果
-
上传的测评报告总文件数{{totalNumber.totalEntries}}个,成功{{totalNumber.successfulEntries}}个,失败{{totalNumber.failedEntries}}个;
上传结果请下载查看!
+
上传的测评报告总文件数{{totalNumber.totalEntries}}个,成功{{totalNumber.successfulEntries}}个,失败{{totalNumber.failedEntries}}个;
上传结果请下载查看!
@@ -518,8 +524,10 @@ :loading="tableLoadingAdd" :scroll="{ x: 1000,y: 500 }" :pagination="paginationAdd" + :customRow="customRow" + :row-class-name="getRowClassName" > -