|
|
@@ -1,75 +1,51 @@
|
|
|
<script setup lang="ts">
|
|
|
-const attachmentData = ref([
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- isSelect: false,
|
|
|
- no: 'Shipment No. S0000002841',
|
|
|
- typeList: [
|
|
|
- {
|
|
|
- label: 'Customs Documents',
|
|
|
- attachmentList: [
|
|
|
- { name: 'Commercial Invoice1.pdf', isSelect: false },
|
|
|
- { name: 'Packing List1.pdf', isSelect: false },
|
|
|
- { name: 'Certificate of Origin1.pdf', isSelect: false }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'House Bill of Lading',
|
|
|
- attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'Master Bill of Lading',
|
|
|
- attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- id: 2,
|
|
|
- isSelect: false,
|
|
|
- no: 'Shipment No. S0000002841',
|
|
|
- typeList: [
|
|
|
- {
|
|
|
- label: 'Customs Documents',
|
|
|
- attachmentList: [
|
|
|
- { name: 'Commercial Invoice.pdf', isSelect: false },
|
|
|
- { name: 'Packing List.pdf', isSelect: false },
|
|
|
- { name: 'Certificate of Origin.pdf', isSelect: false }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'House Bill of Lading',
|
|
|
- attachmentList: [{ name: 'Commercial Invoice.pdf', isSelect: false }]
|
|
|
- },
|
|
|
- {
|
|
|
- label: 'Master Bill of Lading',
|
|
|
- attachmentList: [{ name: 'Commercial Invoice.pdf', isSelect: false }]
|
|
|
- }
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- id: 3,
|
|
|
- isSelect: false,
|
|
|
- no: 'Shipment No. S0000002841',
|
|
|
- typeList: []
|
|
|
- },
|
|
|
- {
|
|
|
- id: 2,
|
|
|
- no: 'Shipment No. S0000002841',
|
|
|
- isSelect: false,
|
|
|
- typeList: [
|
|
|
- {
|
|
|
- label: 'Customs Documents',
|
|
|
- attachmentList: [
|
|
|
- { name: 'Commercial Invoice2.pdf', isSelect: false },
|
|
|
- { name: 'Packing List2.pdf', isSelect: false },
|
|
|
- { name: 'Certificate of Origin2.pdf', isSelect: false }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-])
|
|
|
+import { useTrackingDownloadData } from '@/stores/modules/trackingDownloadData'
|
|
|
+
|
|
|
+const trackingDownloadData = useTrackingDownloadData()
|
|
|
+const attachmentData = ref([])
|
|
|
+
|
|
|
+// {
|
|
|
+// id: 1,
|
|
|
+// isSelect: false,
|
|
|
+// no: 'Shipment No. S0000002841',
|
|
|
+// typeList: [
|
|
|
+// {
|
|
|
+// label: 'Customs Documents',
|
|
|
+// attachmentList: [
|
|
|
+// { name: 'Commercial Invoice1.pdf', isSelect: false },
|
|
|
+// { name: 'Packing List1.pdf', isSelect: false },
|
|
|
+// { name: 'Certificate of Origin1.pdf', isSelect: false }
|
|
|
+// ]
|
|
|
+// },
|
|
|
+// {
|
|
|
+// label: 'House Bill of Lading',
|
|
|
+// attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
|
|
|
+// },
|
|
|
+// {
|
|
|
+// label: 'Master Bill of Lading',
|
|
|
+// attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
|
|
|
+// }
|
|
|
+// ]
|
|
|
+// },
|
|
|
|
|
|
// const shipments = ref(attachmentData)
|
|
|
+const getAttachmentData = () => {
|
|
|
+ console.log('trackingDownloadData', trackingDownloadData)
|
|
|
+ $api
|
|
|
+ .getDownloadAttachmentData({
|
|
|
+ serial_no_arr: trackingDownloadData.serialNoArr,
|
|
|
+ schemas_arr: trackingDownloadData.schemasArr
|
|
|
+ })
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ attachmentData.value = res.data
|
|
|
+ console.log('res.data', res.data)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+onMounted(() => {
|
|
|
+ getAttachmentData()
|
|
|
+})
|
|
|
|
|
|
// === 1. 全选状态计算 ===
|
|
|
const isAllSelected = computed({
|
|
|
@@ -191,25 +167,51 @@ watch(
|
|
|
{ deep: true }
|
|
|
)
|
|
|
|
|
|
-const handleDownload = (row: any) => {
|
|
|
+const handleFileDownload = (row: any) => {
|
|
|
+ console.log('row', row)
|
|
|
// 如果from_system的值是TOPOCEAN_KSMART,不需要拼接url
|
|
|
- const url =
|
|
|
- row.from_system === 'TOPOCEAN_KSMART'
|
|
|
- ? row.file?.url
|
|
|
- : import.meta.env.VITE_API_HOST + '/' + row.file?.url
|
|
|
+ const url = row?.url
|
|
|
// const url = row.file?.url
|
|
|
// 创建一个隐藏的 <a> 标签
|
|
|
const link = document.createElement('a')
|
|
|
link.href = url
|
|
|
+ link.target = '_blank'
|
|
|
|
|
|
// 指定下载文件名(可选)
|
|
|
- link.download = row.file?.file_name || 'file'
|
|
|
+ // link.download = row?.file_name || 'file'
|
|
|
|
|
|
// 添加到 DOM 中,触发点击事件,然后移除
|
|
|
document.body.appendChild(link)
|
|
|
link.click()
|
|
|
document.body.removeChild(link)
|
|
|
}
|
|
|
+
|
|
|
+const handleDownloadAllSelectedFiles = () => {
|
|
|
+ const selectedFiles = []
|
|
|
+ attachmentData.value.forEach((item) => {
|
|
|
+ item?.typeList?.forEach((type) => {
|
|
|
+ type?.attachmentList?.forEach((attach) => {
|
|
|
+ if (attach.isSelect) {
|
|
|
+ selectedFiles.push(attach)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ if (selectedFiles.length === 0) {
|
|
|
+ ElMessage.warning('Please select at least one file to download.')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ $api
|
|
|
+ .downloadAttachment({
|
|
|
+ data: selectedFiles
|
|
|
+ })
|
|
|
+ .then((res: any) => {
|
|
|
+ console.log(res, 'res')
|
|
|
+ })
|
|
|
+ // 这里可以根据需要处理 selectedFiles,比如打包下载等
|
|
|
+ console.log('Selected Files for Download:', selectedFiles)
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -248,7 +250,10 @@ const handleDownload = (row: any) => {
|
|
|
<el-checkbox v-model="fileItem.isSelect" @change="handleChildToggle(attItem)">
|
|
|
<span>{{ fileItem.name }}</span></el-checkbox
|
|
|
>
|
|
|
- <span class="font_family icon-icon_download_b"></span>
|
|
|
+ <span
|
|
|
+ @click="handleFileDownload(fileItem)"
|
|
|
+ class="font_family icon-icon_download_b"
|
|
|
+ ></span>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -263,6 +268,7 @@ const handleDownload = (row: any) => {
|
|
|
<el-button
|
|
|
class="el-button--main el-button--pain-theme"
|
|
|
style="width: 100%; margin-bottom: 8px"
|
|
|
+ @click="handleDownloadAllSelectedFiles"
|
|
|
>
|
|
|
<span class="font_family icon-icon_download_b"></span>
|
|
|
<span>Download Selected ({{ allChooseFiles }})</span>
|