From 89380e6260a75d1d3b94de687ebcc2f50d50659d Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 03 Feb 2026 15:44:33 +0800
Subject: [PATCH] feat:环境变量配置调整

---
 applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue |  117 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 74 insertions(+), 43 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 b4b865e..d5a1d40 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
@@ -22,7 +22,7 @@
 					@change="handleSearch"
 				>
 					<el-option
-						v-for="item in dictObj.patrolTaskType"
+						v-for="item in dictObj.workOrderType"
 						:key="item.dictKey"
 						:label="item.dictValue"
 						:value="item.dictKey"
@@ -47,12 +47,16 @@
 					<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="文档类型">
 						<template v-slot="{ row }">
-							{{ getDictLabel(row.resultType, dictObj.patrolTaskType) }}
+							{{ getDictLabel(row.resultType, dictObj.workOrderType) }}
 						</template>
 					</el-table-column>
 					<el-table-column label="操作" class-name="operation-btns">
@@ -78,10 +82,9 @@
 		</div>
 		<el-dialog
 			class="gd-dialog"
-			append-to-body
 			v-model="isShowEditView"
 			:title="titleTxt"
-			:width="pxToRem(800)"
+			:width="pxToRem(500)"
 			:close-on-click-modal="false"
 			:destroy-on-close="true"
 			@close="handleClose"
@@ -99,7 +102,7 @@
 						clearable
 					>
 						<el-option
-							v-for="item in dictObj.patrolTaskType"
+							v-for="item in dictObj.workOrderType"
 							:key="item.dictKey"
 							:label="item.dictValue"
 							:value="item.dictKey"
@@ -107,10 +110,12 @@
 					</el-select>
 				</el-form-item>
 				<el-form-item label="上传文件" prop="link" v-if="titleTxt === '上传巡查报告'">
-					{{ uploadName }}
 					<el-upload class="avatar-uploader" action="" :show-file-list="false" :before-upload="onUploadFileBefore">
 						<el-button size="small" type="primary">点击上传</el-button>
 					</el-upload>
+					<div class="upload-tip">
+						{{ uploadName }}
+					</div>
 				</el-form-item>
 			</el-form>
 			<!-- </div> -->
@@ -169,7 +174,7 @@
 const uploadName = ref('')
 
 const dictObj = ref({
-	patrolTaskType: [], // 巡查任务类型
+	workOrderType: [], // 巡查任务类型
 })
 
 const searchParams = ref(initSearchParams()) // 查询参数
@@ -198,9 +203,18 @@
 
 // 获取字典
 function getDictList() {
-	getDictionaryByCode('patrolTaskType').then(res => {
+	getDictionaryByCode('workOrderType').then(res => {
 		dictObj.value = res.data.data
 	})
+}
+
+// 将字节大小转换为可读格式的函数
+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]
 }
 
 // 获取列表
@@ -298,43 +312,53 @@
 		ElMessage.warning('请选择要下载的文件')
 		return
 	}
-	if (selectedFiles.value.length === 1) {
-		selectedFiles.value.forEach((file, index) => {
-			// setTimeout(() => {
-			if (file.link) {
-				const a = document.createElement('a')
-				a.href = file.link
-				a.download = file.originalName || `attachment_${index + 1}`
-				document.body.appendChild(a)
-				a.click()
-				document.body.removeChild(a)
-			}
-			// }, 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')
+	// if (selectedFiles.value.length === 1) {
+	// 	selectedFiles.value.forEach(async (file, index) => {
+	// 		if (file.link) {
+	// 			try {
+	// 				// 使用 fetch 获取 blob 数据来强制下载,避免浏览器打开文件
+	// 				const response = await fetch(file.link)
+	// 				if (!response.ok) {
+	// 					throw new Error(`Failed to fetch file: ${response.status}`)
+	// 				}
+	// 				const blob = await response.blob()
+	// 				const url = URL.createObjectURL(blob)
+	// 				const a = document.createElement('a')
+	// 				a.href = url
+	// 				a.download = file.originalName || `attachment_${index + 1}`
+	// 				document.body.appendChild(a)
+	// 				a.click()
+	// 				document.body.removeChild(a)
+	// 				// 释放 URL 对象
+	// 				setTimeout(() => URL.revokeObjectURL(url), 100)
+	// 				ElMessage.success('下载成功')
+	// 			} catch (error) {
+	// 				console.error('Download error:', error)
+	// 				ElMessage.error(`下载文件 ${file.originalName} 失败: ${error.message}`)
+	// 			}
+	// 		}
+	// 	})
+	// } else {
+			try {
+			const fileIds = selectedFiles.value.map(i => i.id).join(',')
 			await fjDownloadByByteApi({ attachIds: fileIds }).then(res => {
-				if (res.data.code === 200) {
+			const blob = res.data
+			const url = URL.createObjectURL(blob)
+			const a = document.createElement('a')
+			a.href = url
+			a.download = `巡查报告.zip`
+			document.body.appendChild(a)
+			a.click()
+			document.body.removeChild(a)
+			URL.revokeObjectURL(url)
 					ElMessage.success('下载成功')
-				} else {
-					ElMessage.error(res.msg || '下载失败')
-				}
-			})
-		} catch (e) {
-		} finally {
-			loadingData.close()
-		}
+				})
+			} catch (e) {
+			} finally {
+				// loadingData.close()
+			}
 
-	}
+	// }
 }
 
 // 文档上传
@@ -347,6 +371,8 @@
 function onUploadFileBefore(file) {
 	// 执行文件上传
 	let data = new FormData()
+	// 获取文件扩展名
+  const fileExtension = file.name.split('.').pop().toLowerCase();
 	data.append('file', file)
 
 	fjUploadApi(data).then(res => {
@@ -355,6 +381,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 || '上传失败')
 		}

--
Gitblit v1.9.3