1
0
tangning 16 часов назад
Родитель
Сommit
142e1a3e37

+ 11 - 5
src/view/case/photos/canvas-photo-editor.js

@@ -1460,7 +1460,7 @@ export class CanvasPhotoEditor {
 
 
 
-  async exportPagesToPDF(paperType = "a4", name) {
+  exportPagesToPDF(paperType = "a4", name) {
     const loading = ElLoading.service({
       lock: true,
       text: "正在导出超清PDF,请稍候...",
@@ -1653,7 +1653,7 @@ export class CanvasPhotoEditor {
     }
   }
 
-async exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
+exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
   const loading = ElLoading.service({
     lock: true,
     text: "正在生成图片...",
@@ -1828,9 +1828,15 @@ async exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
 
     // 下载
     const filename = name || "照片卷";
-    const blob = await zip.generateAsync({ type: "blob" });
-    saveAs(blob, `${filename}.zip`);
-    ElMessage.success("导出成功!");
+    zip.generateAsync({ type: "blob" }).then(blob => {
+      saveAs(blob, `${filename}.zip`);
+      ElMessage.success("导出成功!");
+    }).catch(() => {
+      ElMessage.error("导出失败");
+    });
+    // const blob = await zip.generateAsync({ type: "blob" });
+    // saveAs(blob, `${filename}.zip`);
+    // ElMessage.success("导出成功!");
     return true
   } catch (err) {
     console.error(err);

+ 20 - 6
src/view/material/exportPhotos.vue

@@ -24,7 +24,7 @@
 <script setup lang="ts">
 import { maxFileSize } from "@/constant/caseFile";
 import { useUpload } from "@/hook/upload";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElLoading } from "element-plus";
 import { computed, ref, watchEffect, onMounted } from "vue";
 import { addCaseScenes } from "./quisk";
 import { QuiskExpose } from "@/helper/mount";
@@ -40,16 +40,30 @@ const exportInfo = ref({
 })
 onMounted(async () => {
 });
-
-defineExpose<QuiskExpose>({
-  async submit() {
+const submit = () => {
     if (!props.showPagesRef) {
       ElMessage.error("加载异常,请刷新浏览器");
       throw "加载异常,请刷新浏览器";
     }else{
-      await props.showPagesRef.exportToPDF(exportInfo.value.paperType,props.title, exportInfo.value.fileType)
+       const loading = ElLoading.service({ lock: true, text: "正在导出" });
+        // 延迟执行,让 loading 先显示出来
+      setTimeout(async () => {
+        try {
+          await props.showPagesRef.exportToPDF(
+            exportInfo.value.paperType, props.title, exportInfo.value.fileType
+          );
+          return true;
+        } finally {
+          loading.close();
+        }
+      }, 40);
+      // props.showPagesRef.exportToPDF(exportInfo.value.paperType,props.title, exportInfo.value.fileType)
+      // console.log('正在导出2');
+      // loading.close();
     }
-  },
+  };
+defineExpose<QuiskExpose>({
+  submit,
 });
 </script>
 

+ 2 - 1
src/view/material/sceneImg.vue

@@ -230,6 +230,7 @@
                 <el-button
                   class="newbut"
                   @click="exportToPDF(true)"
+                  :disabled="!casePhotoList.length"
                   :icon="Download"
                   >下载</el-button
                 >
@@ -1193,7 +1194,7 @@ const exportToPDF = async (isAll, item) => {
 };
 const handleOpen = (val) => {
   if (!val) {
-    handleClick({ paneName: "照片卷" });
+    // handleClick({ paneName: "照片卷" });
   } else {
     console.log("handleOpen");
     let Alllist = {