Browse Source

调整loading的时机

cxmo 1 year ago
parent
commit
af0a4b7c85
1 changed files with 13 additions and 10 deletions
  1. 13 10
      src/views/hzyb/report/PreviewPDF.vue

+ 13 - 10
src/views/hzyb/report/PreviewPDF.vue

@@ -12,6 +12,7 @@ let LOADING = null
 let showHint = ref(false)
 let hasRight = ref(false)
 let userInfo = ref({})
+let hintText = ref('')
 
 
 const loadingFailed = ()=>{
@@ -22,6 +23,7 @@ const loadingFailed = ()=>{
 const loadedPDF = ()=>{
     LOADING.clear()
     showHint.value = false
+    hintText.value = ''
 }
 
 const checkRight = async()=>{
@@ -30,6 +32,15 @@ const checkRight = async()=>{
     userInfo.value = res.data
     if(['试用','正式','永续'].includes(res.data.status)){
         hasRight.value = true
+        LOADING = Toast.loading({
+            message: "正在加载PDF",
+            duration: 0,
+            forbidClick: true,
+        });
+        pdfSrc.value = route.query.pdfSrc ||''
+        if(!pdfSrc.value.length){
+            hintText.value = '获取PDF失败'
+        }
     }else{
         LOADING&&LOADING.clear()
         hasRight.value = false
@@ -55,15 +66,7 @@ const handleGoApply = ()=>{
 }
 
 onMounted(()=>{
-    if(route.query.pdfSrc.length){
-        LOADING = Toast.loading({
-            message: "正在加载PDF",
-            duration: 0,
-            forbidClick: true,
-        });
-        pdfSrc.value = route.query.pdfSrc ||''
-        checkRight()
-    }
+    checkRight()
 })
 </script>
 
@@ -82,7 +85,7 @@ onMounted(()=>{
             <p v-if="showHint" class="hint">加载pdf失败</p>
         </template>
         <template v-else>
-            <div>获取pdf失败</div>
+            <p class="hint">{{hintText}}</p>
         </template>
     </div>
 </template>