修改测试bug
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
>
|
||||
<template #select>
|
||||
<el-form-item label="关键字筛选">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
<el-input maxlength="32" show-word-limit
|
||||
|
||||
|
||||
style="width: 240px"
|
||||
v-model.trim="tableStore.table.params.searchValue"
|
||||
clearable
|
||||
@@ -342,10 +342,11 @@ const cellClickEvent = ({ row, column }: any) => {
|
||||
// 下载报告
|
||||
const downloadTheReport = (lineId: string, name: string) => {
|
||||
getReportUrl({ lineId: lineId }).then((res: any) => {
|
||||
ElMessage.info('下载中......')
|
||||
forceDownloadPdf(res.data, name.split('/').pop() || '')
|
||||
})
|
||||
}
|
||||
const forceDownloadPdf = async (pdfUrl, fileName = '文件.pdf') => {
|
||||
const forceDownloadPdf = async (pdfUrl:any, fileName = '文件.pdf') => {
|
||||
try {
|
||||
// 1. 请求 PDF 并转为 Blob(关键:绕开浏览器直接解析)
|
||||
const response = await fetch(pdfUrl, {
|
||||
@@ -372,8 +373,9 @@ const forceDownloadPdf = async (pdfUrl, fileName = '文件.pdf') => {
|
||||
// 4. 清理资源(避免内存泄漏)
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(blobUrl)
|
||||
ElMessage.success('下载成功')
|
||||
} catch (error) {
|
||||
console.error('PDF 下载失败:', error)
|
||||
console.error('下载失败:', error)
|
||||
// ElMessage.error('文件下载失败,请检查网络或文件地址') // 适配 Element Plus
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user