2025-10-20 13:25:30 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
<!-- 监测点列表 -->
|
2025-12-04 20:08:37 +08:00
|
|
|
|
<TableHeader
|
|
|
|
|
|
ref="TableHeaderRef"
|
|
|
|
|
|
:showReset="false"
|
|
|
|
|
|
@selectChange="selectChange"
|
2026-01-06 11:35:11 +08:00
|
|
|
|
v-if="fullscreen"
|
|
|
|
|
|
:timeKeyList="prop.timeKey"
|
2026-02-04 09:35:24 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template #select>
|
|
|
|
|
|
<el-form-item label="关键字筛选">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
maxlength="32"
|
|
|
|
|
|
show-word-limit
|
|
|
|
|
|
style="width: 240px"
|
|
|
|
|
|
v-model.trim="tableStore.table.params.searchValue"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder="请输入监测点名称"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</TableHeader>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
<Table
|
|
|
|
|
|
ref="tableRef"
|
|
|
|
|
|
@cell-click="cellClickEvent"
|
|
|
|
|
|
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
|
|
|
|
|
|
></Table>
|
2025-10-20 13:25:30 +08:00
|
|
|
|
<!-- 指标越限详情 -->
|
|
|
|
|
|
<OverLimitDetails ref="OverLimitDetailsRef" />
|
2025-11-21 10:42:20 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 上传对话框 -->
|
2026-01-07 13:14:26 +08:00
|
|
|
|
<el-dialog
|
|
|
|
|
|
v-model="uploadDialogVisible"
|
|
|
|
|
|
title="上传报告"
|
|
|
|
|
|
append-to-body
|
|
|
|
|
|
width="500px"
|
|
|
|
|
|
@closed="handleDialogClosed"
|
|
|
|
|
|
>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
<el-upload
|
|
|
|
|
|
ref="uploadRef"
|
|
|
|
|
|
class="upload-demo"
|
2026-01-06 11:35:11 +08:00
|
|
|
|
action=""
|
|
|
|
|
|
accept=".doc,.docx,.PDF"
|
2025-11-21 10:42:20 +08:00
|
|
|
|
:on-change="handleChange"
|
|
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
|
|
:limit="1"
|
2026-01-06 11:35:11 +08:00
|
|
|
|
:auto-upload="false"
|
2025-11-21 10:42:20 +08:00
|
|
|
|
:on-exceed="handleExceed"
|
2026-01-06 11:35:11 +08:00
|
|
|
|
:on-remove="handleRemove"
|
2025-11-21 10:42:20 +08:00
|
|
|
|
:file-list="fileList"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button type="primary">点击上传</el-button>
|
|
|
|
|
|
<template #tip>
|
2026-01-06 11:35:11 +08:00
|
|
|
|
<div class="el-upload__tip">请上传Word或PDF文件</div>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click="uploadDialogVisible = false">取消</el-button>
|
2026-01-06 11:35:11 +08:00
|
|
|
|
<el-button type="primary" @click="handleUpload">确定</el-button>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2025-10-20 13:25:30 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-11-21 10:42:20 +08:00
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
|
|
|
|
|
import TableStore from '@/utils/tableStore'
|
|
|
|
|
|
import Table from '@/components/table/index.vue'
|
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2025-11-13 14:11:26 +08:00
|
|
|
|
import OverLimitDetails from '@/components/cockpit/monitoringPointList/components/overLimitDetails.vue'
|
2025-11-07 10:32:55 +08:00
|
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
2025-11-21 10:42:20 +08:00
|
|
|
|
import { uploadReport, getReportUrl } from '@/api/harmonic-boot/cockpit/cockpit'
|
2025-12-04 20:08:37 +08:00
|
|
|
|
import { getTime } from '@/utils/formatTime'
|
2026-01-08 14:09:43 +08:00
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
|
const prop = defineProps({
|
2025-11-21 10:42:20 +08:00
|
|
|
|
w: { type: [String, Number] },
|
|
|
|
|
|
h: { type: [String, Number] },
|
|
|
|
|
|
width: { type: [String, Number] },
|
|
|
|
|
|
height: { type: [String, Number] },
|
2026-01-06 11:35:11 +08:00
|
|
|
|
timeKey: { type: Array as () => string[] },
|
2025-12-04 20:08:37 +08:00
|
|
|
|
timeValue: { type: Object },
|
|
|
|
|
|
interval: { type: Number }
|
2025-10-20 13:25:30 +08:00
|
|
|
|
})
|
2026-01-08 14:09:43 +08:00
|
|
|
|
|
2025-11-07 10:32:55 +08:00
|
|
|
|
const headerHeight = ref(57)
|
|
|
|
|
|
|
2025-12-04 20:08:37 +08:00
|
|
|
|
const TableHeaderRef = ref()
|
|
|
|
|
|
|
2025-11-21 10:42:20 +08:00
|
|
|
|
// 上传相关
|
|
|
|
|
|
const uploadDialogVisible = ref(false)
|
|
|
|
|
|
const currentUploadRow = ref<any>(null)
|
|
|
|
|
|
const uploadRef = ref()
|
|
|
|
|
|
const fileList = ref([])
|
2025-11-07 10:32:55 +08:00
|
|
|
|
|
|
|
|
|
|
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
|
|
|
|
|
headerHeight.value = height
|
|
|
|
|
|
|
2026-01-27 16:32:33 +08:00
|
|
|
|
// if (datePickerValue && datePickerValue.timeValue) {
|
|
|
|
|
|
// // 更新时间参数
|
|
|
|
|
|
// tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
|
|
|
|
|
// tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
|
|
|
|
|
// }
|
2025-11-07 10:32:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算是否全屏展示
|
|
|
|
|
|
const fullscreen = computed(() => {
|
|
|
|
|
|
const w = Number(prop.w)
|
|
|
|
|
|
const h = Number(prop.h)
|
|
|
|
|
|
if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) {
|
|
|
|
|
|
// 执行相应逻辑
|
|
|
|
|
|
return true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
|
const OverLimitDetailsRef = ref()
|
|
|
|
|
|
const tableStore: any = new TableStore({
|
2025-11-21 10:42:20 +08:00
|
|
|
|
url: '/cs-device-boot/csline/getSensitiveUserLineList',
|
2025-10-20 13:25:30 +08:00
|
|
|
|
method: 'POST',
|
2025-11-21 10:42:20 +08:00
|
|
|
|
showPage: fullscreen.value ? true : false,
|
|
|
|
|
|
exportName: '监测点列表',
|
2025-10-20 13:25:30 +08:00
|
|
|
|
column: [
|
|
|
|
|
|
{
|
|
|
|
|
|
field: 'index',
|
|
|
|
|
|
title: '序号',
|
2025-10-21 16:11:00 +08:00
|
|
|
|
width: '80',
|
2025-10-20 13:25:30 +08:00
|
|
|
|
formatter: (row: any) => {
|
|
|
|
|
|
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-21 10:42:20 +08:00
|
|
|
|
title: '监测点名称',
|
2026-01-08 14:09:43 +08:00
|
|
|
|
field: 'lineName',
|
2025-12-05 16:06:39 +08:00
|
|
|
|
minWidth: '120',
|
2025-10-20 13:25:30 +08:00
|
|
|
|
render: 'customTemplate',
|
|
|
|
|
|
customTemplate: (row: any) => {
|
2026-01-08 14:09:43 +08:00
|
|
|
|
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
|
2025-11-07 10:32:55 +08:00
|
|
|
|
}
|
2025-10-20 13:25:30 +08:00
|
|
|
|
},
|
2026-01-07 21:01:28 +08:00
|
|
|
|
{
|
2026-01-08 14:09:43 +08:00
|
|
|
|
title: '监测类型',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
field: 'position',
|
|
|
|
|
|
minWidth: '80',
|
|
|
|
|
|
formatter: (row: any) => {
|
2026-01-08 14:09:43 +08:00
|
|
|
|
return row.cellValue || '/'
|
2026-01-07 21:01:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// {
|
|
|
|
|
|
// title: '监测点状态',
|
|
|
|
|
|
// field: 'runStatus',
|
|
|
|
|
|
// minWidth: '90',
|
|
|
|
|
|
// render: 'customTemplate',
|
|
|
|
|
|
// customTemplate: (row: any) => {
|
|
|
|
|
|
// return `<span style='color: ${row.runStatus === '中断' ? '#FF0000' : ''}'>${row.runStatus==null?'/':row.runStatus}</span>`
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
2025-10-20 13:25:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '监测点状态',
|
2025-11-21 10:42:20 +08:00
|
|
|
|
field: 'runStatus',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
render: 'tag',
|
|
|
|
|
|
|
|
|
|
|
|
width: 100,
|
|
|
|
|
|
custom: {
|
2026-01-08 14:09:43 +08:00
|
|
|
|
停运: 'danger',
|
|
|
|
|
|
退运: 'danger',
|
|
|
|
|
|
运行: 'success',
|
2026-01-16 15:54:16 +08:00
|
|
|
|
在线: 'success',
|
2026-01-08 14:09:43 +08:00
|
|
|
|
中断: 'warning',
|
2026-01-16 15:54:16 +08:00
|
|
|
|
离线: 'danger',
|
2026-01-08 14:09:43 +08:00
|
|
|
|
检修: 'warning',
|
|
|
|
|
|
调试: 'warning',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
null: 'info'
|
|
|
|
|
|
},
|
|
|
|
|
|
replaceValue: {
|
2026-01-08 14:09:43 +08:00
|
|
|
|
运行: '运行',
|
2026-01-16 15:54:16 +08:00
|
|
|
|
在线: '在线',
|
2026-01-08 14:09:43 +08:00
|
|
|
|
退运: '退运',
|
|
|
|
|
|
停运: '停运',
|
|
|
|
|
|
中断: '中断',
|
|
|
|
|
|
检修: '检修',
|
2026-01-16 15:54:16 +08:00
|
|
|
|
离线: '离线',
|
2026-01-08 14:09:43 +08:00
|
|
|
|
调试: '调试',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
null: '/'
|
2025-11-21 10:42:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-12-08 13:30:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '治理对象',
|
|
|
|
|
|
field: 'sensitiveUser',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
minWidth: '90',
|
|
|
|
|
|
formatter: (row: any) => {
|
|
|
|
|
|
return row.cellValue || '/'
|
|
|
|
|
|
}
|
2025-12-08 13:30:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '电压等级',
|
|
|
|
|
|
field: 'volGrade',
|
2026-01-16 15:54:16 +08:00
|
|
|
|
minWidth: '80',
|
|
|
|
|
|
formatter: (row: any) => {
|
2026-02-04 09:35:24 +08:00
|
|
|
|
return row.cellValue == 0 ? '/' : row.cellValue + 'kV' || '/'
|
2026-01-16 15:54:16 +08:00
|
|
|
|
}
|
2025-12-08 13:30:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '是否治理',
|
|
|
|
|
|
field: 'govern',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
minWidth: '80',
|
|
|
|
|
|
formatter: (row: any) => {
|
|
|
|
|
|
return row.cellValue || '/'
|
|
|
|
|
|
}
|
2025-12-08 13:30:46 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-21 10:42:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '最新数据时间',
|
|
|
|
|
|
field: 'latestTime',
|
|
|
|
|
|
minWidth: '140',
|
|
|
|
|
|
render: 'customTemplate',
|
|
|
|
|
|
customTemplate: (row: any) => {
|
|
|
|
|
|
if (row.latestTime) {
|
|
|
|
|
|
return `<span>${row.latestTime}</span>`
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return `<span>/</span>`
|
|
|
|
|
|
}
|
2025-10-20 13:25:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-01-07 21:01:28 +08:00
|
|
|
|
// {
|
|
|
|
|
|
// 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>`
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
2026-01-07 13:14:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '报告',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
field: 'reportFilePath',
|
2026-01-07 13:14:26 +08:00
|
|
|
|
minWidth: '120',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
formatter: (row: any) => {
|
|
|
|
|
|
return row.cellValue == null ? '/' : row.cellValue.split('/').pop()
|
2026-01-07 13:14:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-21 10:42:20 +08:00
|
|
|
|
{
|
2026-02-04 09:35:24 +08:00
|
|
|
|
title: '操作',
|
|
|
|
|
|
fixed: 'right',
|
2026-01-07 21:01:28 +08:00
|
|
|
|
width: 150,
|
2025-11-21 10:42:20 +08:00
|
|
|
|
render: 'buttons',
|
|
|
|
|
|
buttons: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'productSetting',
|
|
|
|
|
|
title: '上传报告',
|
|
|
|
|
|
type: 'primary',
|
|
|
|
|
|
icon: 'el-icon-upload',
|
|
|
|
|
|
render: 'basicButton',
|
|
|
|
|
|
click: row => {
|
|
|
|
|
|
uploadReportRow(row)
|
|
|
|
|
|
},
|
|
|
|
|
|
disabled: row => {
|
|
|
|
|
|
return row.reportFilePath
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-07 21:01:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-21 10:42:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
name: 'productSetting',
|
|
|
|
|
|
title: '重新上传',
|
|
|
|
|
|
type: 'primary',
|
|
|
|
|
|
icon: 'el-icon-upload',
|
|
|
|
|
|
render: 'basicButton',
|
|
|
|
|
|
click: row => {
|
|
|
|
|
|
uploadReportRow(row)
|
|
|
|
|
|
},
|
|
|
|
|
|
disabled: row => {
|
|
|
|
|
|
return row.reportFilePath == null || row.reportFilePath.length == 0
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2025-10-20 13:25:30 +08:00
|
|
|
|
],
|
|
|
|
|
|
beforeSearchFun: () => {
|
2025-12-04 20:08:37 +08:00
|
|
|
|
setTime()
|
2025-10-20 13:25:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
loadCallback: () => {
|
|
|
|
|
|
tableStore.table.height = `calc(${prop.height} - 80px)`
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
|
|
|
|
provide('tableRef', tableRef)
|
2025-11-21 10:42:20 +08:00
|
|
|
|
tableStore.table.params.keywords = ''
|
2026-02-04 09:35:24 +08:00
|
|
|
|
tableStore.table.params.searchValue = ''
|
2025-10-20 13:25:30 +08:00
|
|
|
|
provide('tableStore', tableStore)
|
|
|
|
|
|
|
2025-12-04 20:08:37 +08:00
|
|
|
|
const setTime = () => {
|
2026-01-27 16:32:33 +08:00
|
|
|
|
// const time = getTime(
|
|
|
|
|
|
// (TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
|
|
|
|
|
|
// prop.timeKey,
|
|
|
|
|
|
// fullscreen.value
|
|
|
|
|
|
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
|
|
|
|
|
|
// : prop.timeValue
|
|
|
|
|
|
// )
|
|
|
|
|
|
// if (Array.isArray(time)) {
|
|
|
|
|
|
// tableStore.table.params.searchBeginTime = time[0]
|
|
|
|
|
|
// tableStore.table.params.searchEndTime = time[1]
|
|
|
|
|
|
// TableHeaderRef.value?.setInterval(time[2] - 0)
|
|
|
|
|
|
// TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// console.warn('获取时间失败,time 不是一个有效数组')
|
|
|
|
|
|
// }
|
2025-12-04 20:08:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
|
// 点击行
|
|
|
|
|
|
const cellClickEvent = ({ row, column }: any) => {
|
2026-01-08 14:09:43 +08:00
|
|
|
|
if (column.field == 'lineName') {
|
2025-11-21 10:42:20 +08:00
|
|
|
|
OverLimitDetailsRef.value.open(
|
|
|
|
|
|
row,
|
|
|
|
|
|
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
|
|
|
|
|
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 下载报告
|
2026-01-07 21:01:28 +08:00
|
|
|
|
const downloadTheReport = (lineId: string, name: string) => {
|
2025-11-21 10:42:20 +08:00
|
|
|
|
getReportUrl({ lineId: lineId }).then((res: any) => {
|
2026-01-07 21:01:28 +08:00
|
|
|
|
forceDownloadPdf(res.data, name.split('/').pop() || '')
|
2025-11-21 10:42:20 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-01-07 21:01:28 +08:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-21 10:42:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 上传报告
|
|
|
|
|
|
const uploadReportRow = (row: any) => {
|
|
|
|
|
|
currentUploadRow.value = row
|
|
|
|
|
|
// 打开弹窗前清空文件列表
|
|
|
|
|
|
fileList.value = []
|
|
|
|
|
|
uploadDialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理弹窗关闭事件
|
|
|
|
|
|
const handleDialogClosed = () => {
|
|
|
|
|
|
// 清空文件列表
|
|
|
|
|
|
fileList.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理文件超出限制
|
2026-01-06 11:35:11 +08:00
|
|
|
|
const handleExceed = (files: any) => {
|
2025-11-21 10:42:20 +08:00
|
|
|
|
ElMessage.warning('只能上传一个文件,请先删除已选择的文件')
|
|
|
|
|
|
}
|
2026-01-06 11:35:11 +08:00
|
|
|
|
const handleRemove = (files: any) => {
|
|
|
|
|
|
fileList.value = []
|
|
|
|
|
|
}
|
2025-11-21 10:42:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 文件变更处理函数
|
2026-01-06 11:35:11 +08:00
|
|
|
|
const handleChange = (file: any) => {
|
2025-11-21 10:42:20 +08:00
|
|
|
|
// 在这里直接处理文件上传逻辑
|
2026-01-06 11:35:11 +08:00
|
|
|
|
// beforeUpload(file.raw) // 注意使用 file.raw 获取原始文件对象
|
|
|
|
|
|
fileList.value = [file] // 只保留最新选择的文件
|
2025-11-21 10:42:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理上传前检查
|
|
|
|
|
|
const beforeUpload = (file: any) => {
|
|
|
|
|
|
const isWord =
|
|
|
|
|
|
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
|
|
|
|
|
file.type === 'application/msword' ||
|
|
|
|
|
|
file.name.endsWith('.doc') ||
|
|
|
|
|
|
file.name.endsWith('.docx')
|
|
|
|
|
|
|
|
|
|
|
|
const isPDF = file.type === 'application/pdf' || file.name.endsWith('.pdf')
|
|
|
|
|
|
|
|
|
|
|
|
const isValidType = isWord || isPDF
|
|
|
|
|
|
const isLt10M = file.size / 1024 / 1024 < 10
|
|
|
|
|
|
|
|
|
|
|
|
if (!isValidType) {
|
2026-01-06 11:35:11 +08:00
|
|
|
|
ElMessage.error('请上传(.doc/.docx/.pdf)格式文件!')
|
2025-11-21 10:42:20 +08:00
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 校验通过后允许上传,交由 http-request 处理
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-06 11:35:11 +08:00
|
|
|
|
const handleUpload = async () => {
|
|
|
|
|
|
// return
|
|
|
|
|
|
|
2025-11-21 10:42:20 +08:00
|
|
|
|
const formData = new FormData()
|
2026-01-06 11:35:11 +08:00
|
|
|
|
formData.append('file', fileList.value[0]?.raw)
|
2025-11-21 10:42:20 +08:00
|
|
|
|
formData.append('lineId', currentUploadRow.value?.lineId || currentUploadRow.value?.id || '')
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const result = await uploadReport(formData)
|
|
|
|
|
|
ElMessage.success('上传成功')
|
|
|
|
|
|
uploadDialogVisible.value = false
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
return Promise.resolve(result)
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
ElMessage.error('上传失败: ' + (error.message || '未知错误'))
|
|
|
|
|
|
return Promise.reject(error)
|
2025-10-20 13:25:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
})
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => prop.timeKey,
|
|
|
|
|
|
val => {
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
watch(
|
2025-11-14 14:09:34 +08:00
|
|
|
|
() => prop.timeValue,
|
2025-10-20 13:25:30 +08:00
|
|
|
|
(newVal, oldVal) => {
|
2025-12-04 20:08:37 +08:00
|
|
|
|
tableStore.index()
|
2025-10-20 13:25:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-14 14:09:34 +08:00
|
|
|
|
deep: true
|
2025-10-20 13:25:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|