From 0ef47a49fa6dce546be2d0f23b4949734e6a0cf9 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 29 Jan 2026 18:31:55 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/jagzwxm/ja_web

---
 applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue |   82 ++++++++++++++++++++++++++++++++---------
 1 files changed, 64 insertions(+), 18 deletions(-)

diff --git a/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue b/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
index 6d685f0..e2220ad 100644
--- a/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
+++ b/applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
@@ -292,7 +292,7 @@
 	catalogResourceName: fieldRules(true),
 	objectionDesc: fieldRules(true),
 	objectionBasis: fieldRules(true),
-	// attachId: dialogMode.value === 'add' ? fieldRules(true) : fieldRules(false)
+	attachId: fieldRules(true)
 
 }
 
@@ -375,6 +375,7 @@
 
 // 提交数据的通用函数
 async function submitForm(objectionStatus) {
+formData.value.attachId = uploadedFiles.value.length > 0 ? uploadedFiles.value.length : ''
   const isValid = await formRef.value?.validate().catch(() => false)
   if (!isValid) return
   
@@ -504,24 +505,69 @@
 	attachmentDetailsList.value = results.map(res => res.data.data).filter(Boolean)
 }
 // 处理附件下载
-async function handleDownloadAttach() {
-	if (attachmentDetailsList.value.length === 0) {
-		ElMessage.warning('没有可下载的附件')
-		return
-	}
+const handleDownloadAttach = async () => {
+  if (!attachmentDetailsList.value || attachmentDetailsList.value.length === 0) {
+    ElMessage.warning('没有可下载的附件')
+    return
+  }
 
-	// 遍历所有附件并下载
-	attachmentDetailsList.value.forEach(attach => {
-		if (attach.link) {
-			const link = document.createElement('a')
-			link.href = attach.link
-			link.download = attach.originalName || attach.name
-			link.style.display = 'none'
-			document.body.appendChild(link)
-			link.click()
-			document.body.removeChild(link)
-		}
-	})
+
+  // 顺序下载每个附件
+  for (let i = 0; i < attachmentDetailsList.value.length; i++) {
+    const attach = attachmentDetailsList.value[i]
+    
+    if (!attach.link) {
+      console.warn(`附件 ${attach.originalName || attach.name} 链接无效,跳过`)
+      continue
+    }
+
+    try {
+      // 显示当前下载的文件信息
+      const currentFileName = attach.originalName || attach.name || `附件_${i + 1}`
+   
+      
+      const response = await fetch(attach.link)
+      const blob = await response.blob()
+      const url = window.URL.createObjectURL(blob)
+      const a = document.createElement('a')
+      a.href = url
+      
+      // 设置文件名:优先使用 originalName
+      let fileName = attach.originalName || attach.name || `附件_${i + 1}`
+      
+      // 确保有扩展名
+      if (fileName && !fileName.includes('.')) {
+        const contentType = response.headers.get('content-type')
+        if (contentType && contentType.includes('zip')) {
+          fileName += '.zip'
+        } else if (contentType && contentType.includes('rar')) {
+          fileName += '.rar'
+        } else {
+          fileName += '.zip'
+        }
+      }
+      
+      a.download = fileName
+      a.style.display = 'none'
+      document.body.appendChild(a)
+      a.click()
+      
+      // 清理
+      setTimeout(() => {
+        window.URL.revokeObjectURL(url)
+        document.body.removeChild(a)
+      }, 100)
+      
+      // 文件间延迟(除了最后一个)
+      if (i < attachmentDetailsList.value.length - 1) {
+        await new Promise(resolve => setTimeout(resolve, 1000))
+      }
+      
+    } catch (error) {
+      console.error(`下载失败: ${attach.originalName || attach.name}`, error)
+    }
+  }
+  
 }
 
 

--
Gitblit v1.9.3