吉安感知网项目-前端
chenyao
2026-01-22 6ed0045e0f379dbd7fdd065a65f8898c482a7cab
applications/task-work-order/src/views/orderView/orderDataManage/dataObjection/FormDiaLog.vue
@@ -425,19 +425,38 @@
   if (!formData.value.id) return
   const res = await gdDataObjectionDetailApi({ id: formData.value.id })
   formData.value = res?.data?.data ?? {}
   if (formData.value.attachIds) {
      getAttachDetail(formData.value.attachIds)
   }
}
// 获取附件详情
async function getAttachDetail() {
   if (!formData.value.id) return
   const res = await getAttachDetailApi({ id: formData.value.id })
   console.log('附件详情',res.data.data)
   attachmentDetailsList.value=res.data.data
async function getAttachDetail(attachIds) {
   // 如果 attachIds 是字符串,尝试分割成数组
   const ids = typeof attachIds === 'string' ? attachIds.split(',') : Array.isArray(attachIds) ? attachIds : [attachIds]
   const detailPromises = ids.map(id => getAttachDetailApi({ id }))
   const results = await Promise.all(detailPromises)
   attachmentDetailsList.value = results.map(res => res.data.data).filter(Boolean)
   console.log('附件详情', attachmentDetailsList.value)
}
// 处理附件下载
async function handleDownloadAttach() {
console.log('附件');
   if (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)
      }
   })
}
@@ -453,7 +472,6 @@
   feedbackFormData.value = initFeedbackForm()
   if (dialogMode.value !== 'add') {
      await loadDetail()
      await getAttachDetail()
   }
}