|
@@ -792,17 +792,29 @@ export default {
|
|
|
try {
|
|
|
this.loading = true
|
|
|
const response = await download(row.fileId)
|
|
|
- if (response.status === 200) {
|
|
|
- const blob = new Blob([response.data], {type: 'application/octet-stream'})
|
|
|
- saveAs(blob, row.fileName)
|
|
|
- this.$message.success('文件下载成功')
|
|
|
- } else {
|
|
|
- this.$message.error('文件下载失败,响应状态码异常')
|
|
|
- }
|
|
|
+ this.parseBlob(response, row.fileName)
|
|
|
+ // if (response.status === 200) {
|
|
|
+ // this.parseBlob(response, '文件名.pdf')
|
|
|
+ // // const blob = new Blob([response.data], {type: 'application/octet-stream'})
|
|
|
+ // // saveAs(blob, row.fileName)
|
|
|
+ // this.$message.success('文件下载成功')
|
|
|
+ // } else {
|
|
|
+ // this.$message.error('文件下载失败,响应状态码异常')
|
|
|
+ // }
|
|
|
} catch (error) {
|
|
|
console.error('文件下载出错:', error)
|
|
|
this.$message.error('文件下载失败,请重试')
|
|
|
}
|
|
|
+ },
|
|
|
+ parseBlob(blob, fileName) {
|
|
|
+ const url = window.URL.createObjectURL(new Blob([blob]))
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.href = url
|
|
|
+ link.setAttribute('download', fileName) // 设置下载文件名
|
|
|
+ document.body.appendChild(link)
|
|
|
+ link.click()
|
|
|
+ document.body.removeChild(link)
|
|
|
+ window.URL.revokeObjectURL(url) // 释放内存
|
|
|
}
|
|
|
}
|
|
|
};
|