| | |
| | | </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' |
| | |
| | | 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}文件格式,可以下载再查看`) |
| | | } |
| | | } |
| | |
| | | selectedFiles.value = rows |
| | | selectedIds.value = rows.map(item => item.id) |
| | | } |
| | | |
| | | let loadingData |
| | | // 文档下载 |
| | | async function handleDownload() { |
| | | // 如果是勾选一个可以直接下载,超过一个打包下载 |
| | |
| | | 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 |
| | |
| | | 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() |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | // 文档上传 |