吉安感知网项目-前端
chenyao
2026-01-28 733aa2ee33557f85367e8e392e9a0137ae00eaad
applications/task-work-order/src/views/orderView/orderManage/inspectionReport/index.vue
@@ -138,10 +138,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'
@@ -261,9 +261,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 +289,7 @@
   selectedFiles.value = rows
   selectedIds.value = rows.map(item => item.id)
}
let loadingData
// 文档下载
async function handleDownload() {
   // 如果是勾选一个可以直接下载,超过一个打包下载
@@ -298,8 +298,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 +309,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()
      }
   }
}
// 文档上传