Explorar o código

fix: 增加检验接口异常处理

zh %!s(int64=2) %!d(string=hai) anos
pai
achega
9e6f579044
Modificáronse 1 ficheiros con 48 adicións e 42 borrados
  1. 48 42
      src/views/supply/pickup/components/design/preview.vue

+ 48 - 42
src/views/supply/pickup/components/design/preview.vue

@@ -58,7 +58,7 @@ export default {
       // 数据
       printData: {},
       loading: true,
-      flag:false
+      flag: false
     }
   },
   computed: {},
@@ -73,6 +73,8 @@ export default {
       this.visible = false
       this.waitShowPrinter = false
       this.$emit('initPrint')
+      this.$emit('refreshTableSelection')
+      this.$emit('refreshList')
       // console.log(this.$parent);
     },
     show(hiprintTemplate, printData, width = '210') {
@@ -89,51 +91,55 @@ export default {
     },
     async print() {
       if (this.getNewDetailPrintDisString) {
-        const { data } = await this.getNewDetailPrintDisString()
+        try {
+          const { data } = await this.getNewDetailPrintDisString()
 
-        if (!data || this.flag) {
-          try {
-            if (typeof this.addPrint === 'function') {
-              this.addPrint('getDtailPrintDis')
-                .then(res => {
-                  this.hiprintTemplate.print(
-                    this.printData,
-                    {},
-                    {
-                      callback: async() => {
-                        this.hiprintTemplate = {}
-                        setTimeout(() => {
-                          this.flag = false
-                          this.hideModal()
-                          this.$emit('refreshTableSelection')
-                          this.$emit('refreshList')
-                        }, 1000)
+          if (!data || this.flag) {
+            try {
+              if (typeof this.addPrint === 'function') {
+                this.addPrint('getDtailPrintDis')
+                  .then(res => {
+                    this.hiprintTemplate.print(
+                      this.printData,
+                      {},
+                      {
+                        callback: async() => {
+                          this.hiprintTemplate = {}
+                          setTimeout(() => {
+                            this.flag = false
+                            this.hideModal()
+                            this.$emit('refreshTableSelection')
+                            this.$emit('refreshList')
+                          }, 1000)
+                        }
                       }
-                    }
-                  )
-                })
-                .catch(err => {
-                  this.myConfirm(err)
-                })
-            } else {
-              console.log(333)
-            // throw new Error('加载失败,刷新重试')
+                    )
+                  })
+                  .catch(err => {
+                    this.myConfirm(err)
+                  })
+              } else {
+                console.log(333)
+                // throw new Error('加载失败,刷新重试')
+              }
+            } catch (e) {
+              this.$errorMsg(e)
+              // '调用打印次数接口失败'
             }
-          } catch (e) {
-            this.$errorMsg(e)
-          // '调用打印次数接口失败'
+          } else {
+            this.$confirm(data, '提示', {
+              showClose: false,
+              confirmButtonText: '确定',
+              showCancelButton: false,
+              type: 'warning',
+              center: true
+            }).then(() => {
+              this.getOvalDateil()
+              this.flag = true
+            })
           }
-        } else {
-          this.$confirm(data, '提示', {
-            showClose: false,
-            confirmButtonText: '确定',
-            showCancelButton: false,
-            type: 'warning',
-            center: true
-          }).then(() => {
-            this.getOvalDateil()
-            this.flag = true
-          })
+        } catch (error) {
+          this.myConfirm()
         }
       }
     },