Pārlūkot izejas kodu

wx打印 - template展示api返回值

zhangxiaomu 1 gadu atpakaļ
vecāks
revīzija
fdfe157647
1 mainītis faili ar 30 papildinājumiem un 30 dzēšanām
  1. 30 30
      src/view/wx-print/index.vue

+ 30 - 30
src/view/wx-print/index.vue

@@ -120,37 +120,37 @@ export default {
             template: layout,
           })
           this.hiprintTemplate=hiprintTemplate
-          hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:'datauristring'}).then(dataURL=>{
-            this.blob=dataURL
-            let pdf = this.dataURLtoFile(dataURL, "pdf");
-            this.pdf=pdf
-            let formData = new FormData();
-            formData.append('file', pdf);
-            this.excute(this.$service.fileService, `upload?folder=pdf&uuid=${this.$route.query.uuid}`,formData).then(res => {
-              this.uploadRes=res
-              if (res.code === this.$config.SUCCESS_CODE) {
-                console.log('upload-res',res)
-              }
-            })
-          })
-          // setTimeout(function () {
-          //   //Blob
-          //   hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:''}).then(blob=>{
-          //     this.blob=blob
-          //     let pdf =this.blobToFile(blob, 'blob.pdf')
-          //     this.pdf=pdf
-          //     let formData = new FormData();
-          //     formData.append('file', pdf);
-          //     this.excute(this.$service.fileService, `upload?folder=pdf&uuid=${this.$route.query.uuid}`,formData).then(res => {
-          //       this.uploadRes=res
-          //       if (res.code === this.$config.SUCCESS_CODE) {
-          //         console.log('upload-res',res)
-          //       }
-          //     })
-          //   }).catch(err => {
-          //     this.err=err
+          // hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:'datauristring'}).then(dataURL=>{
+          //   this.blob=dataURL
+          //   let pdf = this.dataURLtoFile(dataURL, "pdf");
+          //   this.pdf=pdf
+          //   let formData = new FormData();
+          //   formData.append('file', pdf);
+          //   this.excute(this.$service.fileService, `upload?folder=pdf&uuid=${this.$route.query.uuid}`,formData).then(res => {
+          //     this.uploadRes=res
+          //     if (res.code === this.$config.SUCCESS_CODE) {
+          //       console.log('upload-res',res)
+          //     }
           //   })
-          // }, 1000)
+          // })
+          setTimeout(function () {
+            //Blob
+            hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:''}).then(blob=>{
+              this.blob=blob
+              let pdf =this.blobToFile(blob, 'blob.pdf')
+              this.pdf=pdf
+              let formData = new FormData();
+              formData.append('file', pdf);
+              this.excute(this.$service.fileService, `upload?folder=pdf&uuid=${this.$route.query.uuid}`,formData).then(res => {
+                this.uploadRes=res
+                if (res.code === this.$config.SUCCESS_CODE) {
+                  console.log('upload-res',res)
+                }
+              })
+            }).catch(err => {
+              this.err=err
+            })
+          }, 1000)
 
         }else {
           this.$Message.warning(this.$t('W_006'))