Showing
1 changed file
with
45 additions
and
5 deletions
@@ -233,11 +233,51 @@ export default { | @@ -233,11 +233,51 @@ export default { | ||
233 | // 下载文件 | 233 | // 下载文件 |
234 | const handleDownload = (row)=>{ | 234 | const handleDownload = (row)=>{ |
235 | if(row.filePath){ | 235 | if(row.filePath){ |
236 | - proxy.$http.get('/api-web/vulnerabilities/download',{ | ||
237 | - path: row.filePath,name:row.fileName | ||
238 | - }, function (res) { | ||
239 | - handleForm.value.manufacturerName = res.str; | ||
240 | - }) | 236 | + |
237 | + let docMime = row.fileName.slice(row.fileName.lastIndexOf('.') + 1); // 获取文件的后缀 | ||
238 | + console.log(docMime,"-------"); | ||
239 | + // 判断下载的文件类型 | ||
240 | + let mineType = ""; | ||
241 | + switch (docMime) { | ||
242 | + case "xls": | ||
243 | + mineType = "application/vnd.ms-excel"; | ||
244 | + break; | ||
245 | + case "xlsx": | ||
246 | + mineType = "application/vnd.ms-excel"; | ||
247 | + break; | ||
248 | + case "docx": | ||
249 | + mineType = "application/msword"; | ||
250 | + break; | ||
251 | + case "doc": | ||
252 | + mineType = "application/msword"; | ||
253 | + break; | ||
254 | + case "zip": | ||
255 | + mineType = "application/zip"; | ||
256 | + break; | ||
257 | + case "html": | ||
258 | + mineType = "text/html"; | ||
259 | + break; | ||
260 | + case "markdown": | ||
261 | + mineType = "text/markdown"; | ||
262 | + break; | ||
263 | + default: | ||
264 | + break; | ||
265 | + } | ||
266 | + let url = window.URL.createObjectURL(new Blob([row.filePath], { type: "application/msword" })); | ||
267 | + let link = document.createElement("a"); | ||
268 | + link.style.display = "none"; | ||
269 | + link.href = url; | ||
270 | + link.setAttribute("download", row.fileName); | ||
271 | + document.body.appendChild(link); | ||
272 | + link.click(); | ||
273 | + // 销毁超连接 | ||
274 | + window.URL.revokeObjectURL(url); | ||
275 | + | ||
276 | + // proxy.$http.get('/api-web/vulnerabilities/download',{ | ||
277 | + // path: row.filePath,name:row.fileName | ||
278 | + // }, function (res) { | ||
279 | + // handleForm.value.manufacturerName = res.str; | ||
280 | + // }) | ||
241 | }else{ | 281 | }else{ |
242 | proxy.$global.showMsg("无附件信息", 'warning'); | 282 | proxy.$global.showMsg("无附件信息", 'warning'); |
243 | } | 283 | } |
-
Please register or login to post a comment