@@ -16,6 +16,7 @@
< el-button v -auth .device = " ' import ' " type = 'primary' : icon = 'Download' plain @click ="importFile('比对式')"
< el-button v -auth .device = " ' import ' " type = 'primary' : icon = 'Download' plain @click ="importFile('比对式')"
v -if = ' modeStore.currentMode = = = " 比对式 " ' > 导入
v -if = ' modeStore.currentMode = = = " 比对式 " ' > 导入
< / el-button >
< / el-button >
< el-button type = 'primary' : icon = 'Upload' plain @ click = 'uploadFile()' v -if = ' appSceneStore.currentScene = = = " 1 " ' > 报告上传 < / el-button >
< el-button v -auth .device = " ' delete ' " type = 'danger' : icon = 'Delete' plain : disabled = '!scope.isSelected'
< el-button v -auth .device = " ' delete ' " type = 'danger' : icon = 'Delete' plain : disabled = '!scope.isSelected'
@ click = 'batchDelete(scope.selectedListIds)' >
@ click = 'batchDelete(scope.selectedListIds)' >
删除
删除
@@ -28,6 +29,8 @@
< / el -button >
< / el -button >
< el-button v -auth .device = " ' delete ' " type = 'primary' link : icon = 'Delete' @ click = 'handleDelete(scope.row)' > 删除
< el-button v -auth .device = " ' delete ' " type = 'primary' link : icon = 'Delete' @ click = 'handleDelete(scope.row)' > 删除
< / el-button >
< / el-button >
< / template >
< / template >
< / ProTable >
< / ProTable >
@@ -38,7 +41,7 @@
< script setup lang = 'tsx' name = 'useRole' >
< script setup lang = 'tsx' name = 'useRole' >
import TimeControl from '@/components/TimeControl/index.vue'
import TimeControl from '@/components/TimeControl/index.vue'
import { type Device } from '@/api/device/interface/device.ts '
import { type Device } from '@/api/device/interface/device'
import { useHandleData } from '@/hooks/useHandleData'
import { useHandleData } from '@/hooks/useHandleData'
import { useDownload } from '@/hooks/useDownload'
import { useDownload } from '@/hooks/useDownload'
import ProTable from '@/components/ProTable/index.vue'
import ProTable from '@/components/ProTable/index.vue'
@@ -47,8 +50,9 @@ import {type ColumnProps, type ProTableInstance} from '@/components/ProTable/int
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
import DevicePopup from '@/views/machine/device/components/devicePopup.vue'
import { CirclePlus , Delete , Download , EditPen , Upload } from '@element-plus/icons-vue'
import { CirclePlus , Delete , Download , EditPen , Upload } from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import { useDictStore } from '@/stores/modules/dict'
import { deletePqDev , downloadTemplate , exportPqDev , getPqDev , getPqDevList , importPqDev } from '@/api/device/device/index.ts '
import { deletePqDev , downloadTemplate , exportPqDev , getPqDev , getPqDevList , importPqDev } from '@/api/device/device/index'
import { ElMessageBox } from 'element-plus '
import { uploadReportToCloud } from '@/api/device/report/index '
import { ElMessage , ElMessageBox } from 'element-plus'
import { onBeforeMount , reactive , ref } from 'vue'
import { onBeforeMount , reactive , ref } from 'vue'
import { useAppSceneStore , useModeStore } from '@/stores/modules/mode'
import { useAppSceneStore , useModeStore } from '@/stores/modules/mode'
@@ -263,6 +267,40 @@ const importFile = async (pattern: string) => {
}
}
// 报告上传
const uploadFile = async ( ) => {
const selectedRows = proTable . value ? . selectedList || [ ]
if ( selectedRows . length === 0 ) {
// 没有选择设备,弹出确认框询问是否处理全部
ElMessageBox . confirm ( '未选择被检设备,是否对全部设备进行报告上传?' , '提示' , {
type : 'warning' ,
confirmButtonText : '全部上传' ,
cancelButtonText : '取消'
} ) . then ( ( ) => {
// 用户确认全部上传,传递空数组或特殊标识
handleReportUpload ( [ ] )
} ) . catch ( ( ) => {
// 用户取消
} )
} else {
// 有选择设备, 使用选中的设备ID
const selectedIds = selectedRows . map ( row => row . id )
handleReportUpload ( selectedIds )
}
}
// 处理报告上传
const handleReportUpload = async ( deviceIds : string [ ] ) => {
try {
await uploadReportToCloud ( deviceIds )
ElMessage . success ( '报告上传成功' )
} catch ( error ) {
ElMessage . error ( '报告上传失败' )
console . error ( '报告上传错误:' , error )
}
}
onBeforeMount ( async ( ) => {
onBeforeMount ( async ( ) => {
const response = await getPqDev ( )
const response = await getPqDev ( )
devTypeOptions . value = ( response . data as Device . ResDev [ ] ) . map ( item => ( {
devTypeOptions . value = ( response . data as Device . ResDev [ ] ) . map ( item => ( {