From 6b4d23b2f62d5685b7909a301db6f4c7ecf52a30 Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Wed, 28 Jan 2026 17:39:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue               |   65 +++++++++++++++++++++++++++-----
 applications/task-work-order/src/views/orderView/orderManage/inspectionReport/inspectionRequestApi.js |   11 +++++
 applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue               |    2 
 3 files changed, 66 insertions(+), 12 deletions(-)

diff --git a/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue b/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue
index 206b08d..4c99877 100644
--- a/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue
+++ b/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue
@@ -47,7 +47,11 @@
 					<el-table-column type="selection" width="46" />
 					<el-table-column type="index" width="64" label="序号" />
 					<el-table-column prop="nickName" show-overflow-tooltip label="文档名称" />
-					<el-table-column prop="attachSize" show-overflow-tooltip label="文档大小" />
+					<el-table-column prop="attachSize" show-overflow-tooltip label="文档大小">
+						<template v-slot="{ row }">
+						{{ formatFileSize(row.attachSize) }}
+						</template>
+					</el-table-column>
 					<el-table-column prop="deptName" show-overflow-tooltip label="文档归属" />
 					<!-- <el-table-column prop="resultType" show-overflow-tooltip label="文档类型" /> -->
 					<el-table-column prop="resultType" show-overflow-tooltip label="文档类型">
@@ -138,10 +142,10 @@
 </template>
 <script setup>
 import { Search, RefreshRight, Download, Upload, Delete } from '@element-plus/icons-vue'
-import { fjPageApi, fjSubmitApi, fjRemoveApi, fjDetailApi, fjUploadApi } from './inspectionRequestApi'
+import { fjPageApi, fjSubmitApi, fjRemoveApi, fjDetailApi, fjUploadApi,fjDownloadByByteApi } from './inspectionRequestApi'
 import { useStore } from 'vuex'
 import { ref, computed, inject, onMounted } from 'vue'
-import { ElMessage, ElMessageBox } from 'element-plus'
+import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
 import { getDictLabel } from '@ztzf/utils'
 import PreviewFiles from '@/components/PreviewFiles/PreviewFiles.vue'
 import { getDictionaryByCode } from '@/api/system/dictbiz'
@@ -203,6 +207,15 @@
 	})
 }
 
+// 将字节大小转换为可读格式的函数
+const formatFileSize = (bytes) => {
+  if (bytes === 0 || bytes === null) return '0 B'
+  const k = 1024
+  const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
+  const i = Math.floor(Math.log(bytes) / Math.log(k))
+  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
+}
+
 // 获取列表
 async function getList() {
 	loading.value = true
@@ -261,9 +274,9 @@
 	const fileType = row?.link?.split('.').pop() || ''
 	if (!row.link) {
 		ElMessage.warning('文件链接不存在')
-	}else if (allSupportedExtensions.includes(fileType)){
+	} else if (allSupportedExtensions.includes(fileType)){
 		window.open(`${VITE_APP_PREVIEW_URL}/onlinePreview?url=`+encodeURIComponent(Base64.encode(row.link)));
-	}else {
+	} else {
 		ElMessage.warning(`${fileType}文件格式,可以下载再查看`)
 	}
 }
@@ -289,7 +302,7 @@
 	selectedFiles.value = rows
 	selectedIds.value = rows.map(item => item.id)
 }
-
+let loadingData
 // 文档下载
 async function handleDownload() {
 	// 如果是勾选一个可以直接下载,超过一个打包下载
@@ -298,8 +311,9 @@
 		ElMessage.warning('请选择要下载的文件')
 		return
 	}
-	selectedFiles.value.forEach((file, index) => {
-		setTimeout(() => {
+	if (selectedFiles.value.length === 1) {
+		selectedFiles.value.forEach((file, index) => {
+			// setTimeout(() => {
 			if (file.link) {
 				const a = document.createElement('a')
 				a.href = file.link
@@ -308,8 +322,32 @@
 				a.click()
 				document.body.removeChild(a)
 			}
-		}, index * 300) // 300ms delay between downloads
-	})
+			// }, index * 300) // 300ms delay between downloads
+		})
+	} else {
+		// 批量下载
+		try {
+			console.log(selectedFiles.value, '9999')
+			loadingData = ElLoading.service({ background: 'rgba(0, 0, 0, 0.5)', text: '打包中,请稍等...' })
+			const fileIds = selectedFiles.value.map(i => i.id)
+			// const res = await getDownloadStatusApi({ type: 'dpsjzx' })
+			// if (!['CANCELLED', 'COMPLETED'].includes(res.data.data?.status || 'COMPLETED')) {
+			// 	return ElMessage.warning('还有正在处理的')
+			// }
+			console.log(fileIds, '7777')
+			await fjDownloadByByteApi({ attachIds: fileIds }).then(res => {
+				if (res.data.code === 200) {
+					ElMessage.success('下载成功')
+				} else {
+					ElMessage.error(res.msg || '下载失败')
+				}
+			})
+		} catch (e) {
+		} finally {
+			loadingData.close()
+		}
+
+	}
 }
 
 // 文档上传
@@ -322,6 +360,8 @@
 function onUploadFileBefore(file) {
 	// 执行文件上传
 	let data = new FormData()
+	// 获取文件扩展名
+  const fileExtension = file.name.split('.').pop().toLowerCase();
 	data.append('file', file)
 
 	fjUploadApi(data).then(res => {
@@ -330,6 +370,11 @@
 			// 保存文件URL到表单
 			uploadName.value = res.data.data.originalName
 			editParams.value.link = res.data.data.link
+			editParams.value.name = res.data.data.name
+			editParams.value.originalName = res.data.data.originalName
+			editParams.value.attachSize = file.size;
+			editParams.value.extension = fileExtension
+			editParams.value.domainUrl = res.data.data.link.replace(res.data.data.name, '')
 		} else {
 			ElMessage.error(res.msg || '上传失败')
 		}
diff --git a/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/inspectionRequestApi.js b/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/inspectionRequestApi.js
index 034c138..cbca14f 100644
--- a/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/inspectionRequestApi.js
+++ b/applications/task-work-order/src/views/orderView/orderManage/inspectionReport/inspectionRequestApi.js
@@ -43,4 +43,13 @@
 		method: 'post',
 		data,
 	})
-}
\ No newline at end of file
+}
+
+// 批量打包下载
+export const fjDownloadByByteApi = data => {
+	return request({
+		url: `/blade-resource/attach/downloadByByte`,
+		method: 'post',
+		data,
+	})
+}
diff --git a/applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue b/applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue
index a844f9f..94c76cd 100644
--- a/applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue
+++ b/applications/task-work-order/src/views/orderView/orderManage/orderManage/FormDiaLog.vue
@@ -63,7 +63,7 @@
 					</el-table>
 					<template v-if="hasPatrolTaskList">
 						<div class="detail-title" :style="{ marginTop: pxToRem(20) }">巡查任务名称</div>
-						<el-table class="setHeight" :data="patrolTaskList" row-key="id">
+						<el-table class="setHeight gd-dialog-table" :data="patrolTaskList" row-key="id">
 							<el-table-column prop="patrolTaskName" show-overflow-tooltip label="巡查任务名称" />
 							<el-table-column prop="patrolTaskType" show-overflow-tooltip label="巡查任务类型">
 								<template v-slot="{ row }">

--
Gitblit v1.9.3