浏览代码

fix: 优化获取报告交互

周玉环 5 天之前
父节点
当前提交
58467c6bb9

+ 6 - 0
xinkeaboard-promotion-portal/src/components/LoginDialog.vue

@@ -218,6 +218,12 @@ const submitForm = (formEl: FormInstance | undefined) => {
             path: `/record`
           });
         })
+        .catch(err => {
+          showMessage({
+            type: 'warning',
+            message: err
+          })
+        })
         .finally(() => {
           sumbitLoading.value = false;
         });

+ 4 - 7
xinkeaboard-promotion-portal/src/utils/pdf.ts

@@ -17,20 +17,17 @@ const isLoadOver = computed(() => mainStore.getIsLoadOver);
 /**
  * 生成 PDF Blob
  */
-async function generatePDFBlob(pdfContent?: HTMLElement, mask?: boolean): Promise<Blob | null> {
+async function generatePDFBlob(pdfContent?: HTMLElement, isDownload?: boolean): Promise<Blob | null> {
   if (!isLoadOver.value) {
     showMessage({ type: 'warning', message: '数据加载中,请稍后再试' });
     return null;
   }
 
-  let loading: any = null;
-  if (mask) {
-    loading = ElLoading.service({
+  const loading = ElLoading.service({
       lock: true,
-      text: '生成中...',
+      text: isDownload ? '生成报告中...' : '上传报告中...',
       background: 'rgba(0,0,0,0.7)'
     });
-  }
 
   try {
     if (!pdfContent) pdfContent = document.querySelector('.record') as HTMLElement;
@@ -80,7 +77,7 @@ async function generatePDFBlob(pdfContent?: HTMLElement, mask?: boolean): Promis
     return null;
   } finally {
     mainStore.setExpanded(false);
-    setTimeout(() => loading && loading.close(), 500);
+    setTimeout(() => loading.close(), 500);
   }
 }
 

+ 1 - 1
xinkeaboard-promotion-portal/src/views/Record.vue

@@ -98,7 +98,7 @@ onMounted(() => {
 
 watch(isLoadOver, (val) => {
   if (val) {
-    setTimeout(() => uploadPDF(), 2000)
+    setTimeout(() => uploadPDF(), 800)
   }
 });
 </script>