修改测试问题

This commit is contained in:
guanj
2026-01-07 21:01:28 +08:00
parent 02a95c1dcd
commit 545e3836d1
24 changed files with 969 additions and 568 deletions

View File

@@ -129,20 +129,55 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
}
},
{ title: '监测类型', field: 'position', minWidth: '80' },
{
title: '监测类型',
field: 'position',
minWidth: '80',
formatter: (row: any) => {
return row.cellValue || '/'
}
},
// {
// title: '监测点状态',
// field: 'runStatus',
// minWidth: '90',
// render: 'customTemplate',
// customTemplate: (row: any) => {
// return `<span style='color: ${row.runStatus === '中断' ? '#FF0000' : ''}'>${row.runStatus==null?'/':row.runStatus}</span>`
// }
// },
{
title: '监测点状态',
field: 'runStatus',
minWidth: '90',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='color: ${row.runStatus === '中断' ? '#FF0000' : ''}'>${row.runStatus}</span>`
render: 'tag',
width: 100,
custom: {
停运: 'danger',
退运: 'danger',
运行: 'success',
中断: 'warning',
检修: 'warning',
调试: 'warning',
null: 'info'
},
replaceValue: {
运行: '运行',
退运: '退运',
停运: '停运',
中断: '中断',
检修: '检修',
调试: '调试',
null: '/'
}
},
{
title: '治理对象',
field: 'sensitiveUser',
minWidth: '90'
minWidth: '90',
formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
@@ -153,7 +188,10 @@ const tableStore: any = new TableStore({
{
title: '是否治理',
field: 'govern',
minWidth: '80'
minWidth: '80',
formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
@@ -169,18 +207,30 @@ const tableStore: any = new TableStore({
}
}
},
// {
// title: '报告',
// field: 'reportFilePath',
// minWidth: '120',
// render: 'customTemplate',
// customTemplate: (row: any) => {
// return row.reportFilePath == null
// ? '/'
// : `<span style='cursor: pointer;text-decoration: underline;'>${row.reportFilePath
// .split('/')
// .pop()}</span>`
// }
// },
{
title: '报告',
field: 'lineId',
field: 'reportFilePath',
minWidth: '120',
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineId}</span>`
formatter: (row: any) => {
return row.cellValue == null ? '/' : row.cellValue.split('/').pop()
}
},
{
title: '操作',
minWidth: 80,
width: 150,
// fixed: 'right',
render: 'buttons',
buttons: [
@@ -198,19 +248,19 @@ const tableStore: any = new TableStore({
}
},
// {
// name: 'productSetting',
// title: '下载报告',
// type: 'primary',
// icon: 'el-icon-EditPen',
// render: 'basicButton',
// click: row => {
// downloadTheReport(row.lineId)
// },
// disabled: row => {
// return row.reportFilePath == null || row.reportFilePath.length == 0
// }
// },
{
name: 'productSetting',
title: '下载报告',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'basicButton',
click: row => {
downloadTheReport(row.lineId, row.reportFilePath)
},
disabled: row => {
return row.reportFilePath == null || row.reportFilePath.length == 0
}
},
{
name: 'productSetting',
title: '重新上传',
@@ -267,22 +317,47 @@ const cellClickEvent = ({ row, column }: any) => {
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
)
}else if (column.field == 'lineId') {
downloadTheReport(row.lineId)
}
}
// 下载报告
const downloadTheReport = (lineId: string) => {
const downloadTheReport = (lineId: string, name: string) => {
getReportUrl({ lineId: lineId }).then((res: any) => {
const link = document.createElement('a')
link.href = res.data
link.download = '治理报告'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
forceDownloadPdf(res.data, name.split('/').pop() || '')
})
}
const forceDownloadPdf = async (pdfUrl, fileName = '文件.pdf') => {
try {
// 1. 请求 PDF 并转为 Blob关键绕开浏览器直接解析
const response = await fetch(pdfUrl, {
method: 'GET'
// 若需要鉴权,添加请求头(如 token
})
// 校验响应是否成功
if (!response.ok) throw new Error(`请求失败:${response.status}`)
// 2. 将响应转为 Blob指定类型为 PDF确保兼容性
const blob = await response.blob()
const pdfBlob = new Blob([blob], { type: 'application/pdf' })
// 3. 创建临时 URL 并触发下载
const blobUrl = URL.createObjectURL(pdfBlob)
const a = document.createElement('a')
a.href = blobUrl
a.download = fileName // 此时 Blob URL 是同源的download 必生效
a.style.display = 'none'
document.body.appendChild(a)
a.click() // 触发下载
// 4. 清理资源(避免内存泄漏)
document.body.removeChild(a)
URL.revokeObjectURL(blobUrl)
} catch (error) {
console.error('PDF 下载失败:', error)
// ElMessage.error('文件下载失败,请检查网络或文件地址') // 适配 Element Plus
}
}
// 上传报告
const uploadReportRow = (row: any) => {
@@ -336,7 +411,6 @@ const beforeUpload = (file: any) => {
}
const handleUpload = async () => {
console.log(123, fileList.value)
// return
const formData = new FormData()