Pārlūkot izejas kodu

feat: 整理Tracking批量下载数据格式

Jack Zhou 1 mēnesi atpakaļ
vecāks
revīzija
c78859e010

+ 24 - 35
src/views/Tracking/src/components/DownloadAttachment/src/DownloadAttachment.vue

@@ -7,7 +7,6 @@ const attachmentData = ref([
     typeList: [
       {
         label: 'Customs Documents',
-        number: 2,
         attachmentList: [
           { name: 'Commercial Invoice1.pdf', isSelect: false },
           { name: 'Packing List1.pdf', isSelect: false },
@@ -16,12 +15,10 @@ const attachmentData = ref([
       },
       {
         label: 'House Bill of Lading',
-        number: 1,
         attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
       },
       {
         label: 'Master Bill of Lading',
-        number: 1,
         attachmentList: [{ name: 'Commercial Invoice1.pdf', isSelect: false }]
       }
     ]
@@ -33,7 +30,6 @@ const attachmentData = ref([
     typeList: [
       {
         label: 'Customs Documents',
-        number: 2,
         attachmentList: [
           { name: 'Commercial Invoice.pdf', isSelect: false },
           { name: 'Packing List.pdf', isSelect: false },
@@ -42,12 +38,10 @@ const attachmentData = ref([
       },
       {
         label: 'House Bill of Lading',
-        number: 1,
         attachmentList: [{ name: 'Commercial Invoice.pdf', isSelect: false }]
       },
       {
         label: 'Master Bill of Lading',
-        number: 1,
         attachmentList: [{ name: 'Commercial Invoice.pdf', isSelect: false }]
       }
     ]
@@ -65,7 +59,6 @@ const attachmentData = ref([
     typeList: [
       {
         label: 'Customs Documents',
-        number: 2,
         attachmentList: [
           { name: 'Commercial Invoice2.pdf', isSelect: false },
           { name: 'Packing List2.pdf', isSelect: false },
@@ -147,33 +140,7 @@ const initShipments = () => {
 }
 
 initShipments()
-const summaryList = ref([
-  {
-    label: 'Customs Documents',
-    number: 8,
-    attachmentList: [
-      {
-        name: 'Commercial InvoiceCommercial InvoiceCommercial InvoiceCommercial Invoice.pdf'
-      },
-      {
-        name: 'Packing List.pdf'
-      },
-      {
-        name: 'Certificate of Origin.pdf'
-      }
-    ]
-  },
-  {
-    label: 'House Bill of Lading',
-    number: 4,
-    attachmentList: [{ name: 'Commercial Invoice.pdf' }]
-  },
-  {
-    label: 'Master Bill of Lading',
-    number: 4,
-    attachmentList: [{ name: 'Commercial Invoice.pdf' }]
-  }
-])
+const summaryList = ref([])
 const allChooseFiles = computed(() => {
   return summaryList.value.reduce((acc, curr) => {
     acc += curr.attachmentList.length
@@ -223,6 +190,26 @@ watch(
   },
   { deep: true }
 )
+
+const handleDownload = (row: any) => {
+  // 如果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.file?.url
+  // 创建一个隐藏的 <a> 标签
+  const link = document.createElement('a')
+  link.href = url
+
+  // 指定下载文件名(可选)
+  link.download = row.file?.file_name || 'file'
+
+  // 添加到 DOM 中,触发点击事件,然后移除
+  document.body.appendChild(link)
+  link.click()
+  document.body.removeChild(link)
+}
 </script>
 
 <template>
@@ -249,7 +236,9 @@ watch(
               v-for="typeItem in attItem?.typeList"
               :key="typeItem.label"
             >
-              <div class="type-label">{{ typeItem.label }} ({{ typeItem.number }})</div>
+              <div class="type-label">
+                {{ typeItem.label }} ({{ typeItem.attachmentList.length }})
+              </div>
               <div class="type-attachment-list">
                 <div
                   class="attachment-file"

+ 1 - 1
src/views/Tracking/src/components/TrackingDetail/src/components/AttachmentView.vue

@@ -97,7 +97,7 @@ const handleDownload = (row: any) => {
   link.click()
   document.body.removeChild(link)
 }
-const handleDelete = (row: any) => {}
+
 const uploadFilesRef = ref<InstanceType<typeof UploadFilesDialog> | null>(null)
 
 const openUploadFilesDialog = () => {