From 2d5a6e8254bbea1014fc824561944f4b1e5907eb Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Fri, 26 Dec 2025 11:15:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device/image-recognition.js | 22 +- src/router/index.js | 5 + .../image-recognition/ExportProgress.vue | 414 ++++++++++++++++++ src/views/device/image-recognition/index.vue | 58 +-- 4 files changed, 463 insertions(+), 36 deletions(-) create mode 100644 src/views/device/image-recognition/ExportProgress.vue diff --git a/src/api/device/image-recognition.js b/src/api/device/image-recognition.js index b6b21cd..f42a135 100644 --- a/src/api/device/image-recognition.js +++ b/src/api/device/image-recognition.js @@ -9,10 +9,28 @@ export function imageRecognitionListAPI(params) { }) } -// 设备管理->图像识别->导出图像识别数据 +// 设备管理->图像识别->导出图像识别数据(启动导出任务) export function exportImageRecognitionAPI(params) { return request({ - url: '/smartCar/device/imageRecognition/exportImageRecognition', + url: '/smartCar/device/imageRecognition/export', + method: 'GET', + params + }) +} + +// 设备管理->图像识别->查询导出进度 +export function getExportProgressAPI(params) { + return request({ + url: '/smartCar/device/imageRecognition/progress', + method: 'GET', + params + }) +} + +// 设备管理->图像识别->下载导出文件 +export function downloadExportFileAPI(params) { + return request({ + url: '/smartCar/device/imageRecognition/download', method: 'GET', params, responseType: 'blob' diff --git a/src/router/index.js b/src/router/index.js index ff857a1..05549ec 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -87,6 +87,11 @@ export const constantRoutes = [ meta: { title: '个人中心', icon: 'user' } } ] + }, + { + path: '/device/image-recognition/export-progress', + component: () => import('@/views/device/image-recognition/ExportProgress'), + hidden: true } ] diff --git a/src/views/device/image-recognition/ExportProgress.vue b/src/views/device/image-recognition/ExportProgress.vue new file mode 100644 index 0000000..ccb9946 --- /dev/null +++ b/src/views/device/image-recognition/ExportProgress.vue @@ -0,0 +1,414 @@ + + + + + 导出进度 + + + + + + + {{ progressText }} + + + + + 正在生成压缩包,请稍候... + + + + + + + + + 压缩包生成完成! + + + 下载文件 + + + + + + + + + {{ errorMessage || '导出失败,请稍后重试' }} + + 关闭窗口 + + + + + + + + + + + diff --git a/src/views/device/image-recognition/index.vue b/src/views/device/image-recognition/index.vue index 9f597fa..fd8c77a 100644 --- a/src/views/device/image-recognition/index.vue +++ b/src/views/device/image-recognition/index.vue @@ -184,13 +184,13 @@ export default { const list = (res.rows || []).map(item => { // 处理图片路径,默认使用 test_image let imageUrl = this.test_image - if (item.filePath) { + /* if (item.filePath) { if (isExternal(item.filePath)) { imageUrl = item.filePath } else { imageUrl = process.env.VUE_APP_BASE_API + item.filePath } - } + } */ return { id: item.identificationDataId, @@ -236,39 +236,29 @@ export default { }, /** 导出操作 */ - async handleExport() { - try { - this.loading = true - const params = { ...this.queryParams } - - // 导出时给开始时间添加 :00 秒,结束时间添加 :59 秒 - if (params.startTime && params.startTime.length === 16) { - params.startTime = params.startTime + ':00' - } - if (params.endTime && params.endTime.length === 16) { - params.endTime = params.endTime + ':59' - } - - const res = await exportImageRecognitionAPI(params) - if (res.code === 200) { - // 处理文件下载 - const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) - const url = window.URL.createObjectURL(blob) - const link = document.createElement('a') - link.href = url - link.download = `图像识别数据_${new Date().getTime()}.xlsx` - link.click() - window.URL.revokeObjectURL(url) - this.$message.success('导出成功') - } else { - this.$message.error(res.msg || '导出失败') - } - } catch (error) { - console.error('导出失败:', error) - this.$message.error('导出失败') - } finally { - this.loading = false + handleExport() { + const params = { ...this.queryParams } + + // 导出时给开始时间添加 :00 秒,结束时间添加 :59 秒 + if (params.startTime && params.startTime.length === 16) { + params.startTime = params.startTime + ':00' } + if (params.endTime && params.endTime.length === 16) { + params.endTime = params.endTime + ':59' + } + + // 将参数编码后作为URL参数传递 + const paramsStr = encodeURIComponent(JSON.stringify(params)) + const url = `${window.location.origin}${process.env.VUE_APP_ENV === 'production' ? '/smart-car' : ''}/device/image-recognition/export-progress?params=${paramsStr}` + + // 计算窗口居中位置 + const width = 750 + const height = 500 + const left = (window.screen.width - width) / 2 + const top = (window.screen.height - height) / 2 + + // 打开新窗口(居中显示) + window.open(url, '_blank', `width=${width},height=${height},left=${left},top=${top},scrollbars=yes,resizable=yes`) }, /** 时间范围变化 */