From 44d7a737dc0d63ad1dd7c52d45fc2233d1950173 Mon Sep 17 00:00:00 2001 From: lyfO_o <764716047@qq.com> Date: 星期四, 09 六月 2022 09:56:08 +0800 Subject: [PATCH] Merge remote-tracking branch 'remotes/origin/shf' into master --- src/views/hiddenDangerRectification/sendHiddenDangerList.vue | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/views/hiddenDangerRectification/sendHiddenDangerList.vue b/src/views/hiddenDangerRectification/sendHiddenDangerList.vue index bd318b2..2b75bb3 100644 --- a/src/views/hiddenDangerRectification/sendHiddenDangerList.vue +++ b/src/views/hiddenDangerRectification/sendHiddenDangerList.vue @@ -292,10 +292,11 @@ width="260"> <template slot-scope="scope"> <span size="medium">{{ scope.row.content }}</span> - <a v-for="item in scope.row.realFileName" - :href="scope.row.url+'/'+item"> - {{ item.split("fileName=")[1] }} - </a> + <span v-for="item in scope.row.realFileName"> + <el-link type="primary" @click="downloadFile(subFile(item))"> + {{subFile(item)}} + </el-link> + </span> </template> </el-table-column> <el-table-column @@ -391,6 +392,7 @@ <script> import Titlename from "../../components/Titlename/index.vue"; import {sendDangerNext, getDangerDetails, getWfRecordList} from "@/api/sgyhpczl/recheckCancellationNumber"; + import {downloadFile} from "@/api/sgyhpczl/fileUtils"; export default { components: {Titlename}, @@ -518,7 +520,40 @@ this.$router.push({ path:"/hiddenDangerRectification" }) - } + }, + subFile(fileName){ + return fileName.substring(fileName.indexOf("fileName=")+9) + }, + downloadFile(path){ + let params = { + type: 0, + fileName: path, + }; + downloadFile(params).then((res) => { + if(res.data.type=='text/json'){ + const reader = new FileReader(); + reader.readAsText(res.data, 'utf-8'); + reader.onload = e => { + this.$message({ + type: "error", + message: JSON.parse(reader.result).msg, + duration: 3000, + }); + } + } else { + let blob = new Blob([res.data], {type: 'application/octet-stream'}) + console.log(blob) + let blobUrl = window.URL.createObjectURL(blob) + let downloadElement = document.createElement('a') + downloadElement.href = blobUrl + downloadElement.download = path + document.body.appendChild(downloadElement) + downloadElement.click() + document.body.removeChild(downloadElement) + window.URL.revokeObjectURL(blobUrl) + } + }); + }, } } </script> -- Gitblit v1.9.2