Sfoglia il codice sorgente

Merge branch 'master' of http://git.huihenduo.com.cn:3000/wzh/JiangYunPhotosCargoOwner_WebApp into wuchan

wzh 3 anni fa
parent
commit
beaf659145
2 ha cambiato i file con 32 aggiunte e 18 eliminazioni
  1. 20 14
      src/utils/downloadBlobFile.js
  2. 12 4
      src/views/voyage/voyageList.vue

+ 20 - 14
src/utils/downloadBlobFile.js

@@ -8,20 +8,26 @@ function downloadBlobFile(url, data, name, type, fileType) {
       data,
     })
       .then((res) => {
-        let blob = new Blob([res.data], {
-          type: fileType,
-        });
-        let downloadElement = document.createElement("a");
-        let href = window.URL.createObjectURL(blob); // 创建下载的链接
-        downloadElement.href = href;
-        downloadElement.download = name; // 下载后文件名
-        document.body.appendChild(downloadElement);
-        downloadElement.click(); // 点击下载
-        document.body.removeChild(downloadElement); // 下载完成移除元素
-        window.URL.revokeObjectURL(href); // 释放掉blob对象
-        resolve({
-          status: 0,
-        });
+        if (res.data.size) {
+          let blob = new Blob([res.data], {
+            type: fileType,
+          });
+          let downloadElement = document.createElement("a");
+          let href = window.URL.createObjectURL(blob); // 创建下载的链接
+          downloadElement.href = href;
+          downloadElement.download = name; // 下载后文件名
+          document.body.appendChild(downloadElement);
+          downloadElement.click(); // 点击下载
+          document.body.removeChild(downloadElement); // 下载完成移除元素
+          window.URL.revokeObjectURL(href); // 释放掉blob对象
+          resolve({
+            status: 0,
+          });
+        } else {
+          resolve({
+            status: -1,
+          });
+        }
       })
       .catch((e) => {
         reject({

+ 12 - 4
src/views/voyage/voyageList.vue

@@ -99,6 +99,7 @@
     <el-dialog
       v-model="exportModalVisable"
       :title="exportModalTitle"
+      :close-on-click-modal="false"
       width="200px"
     >
       <div class="df aic jcsb">
@@ -743,10 +744,17 @@ async function exportZip() {
     "post",
     type
   );
-  ElNotification({
-    title: "导出成功!",
-    type: "success",
-  });
+  if (res.status == 0) {
+    ElNotification({
+      title: "导出成功!",
+      type: "success",
+    });
+  } else {
+    ElNotification({
+      title: "暂无数据",
+    });
+  }
+
   isLoadingZip.value = false;
   currentMonth.value = "";
   exportModalVisable.value = false;