Kaynağa Gözat

wx打印 - template展示api返回值

zhangxiaomu 1 yıl önce
ebeveyn
işleme
4ad5aa0d2a
1 değiştirilmiş dosya ile 22 ekleme ve 17 silme
  1. 22 17
      src/view/wx-print/index.vue

+ 22 - 17
src/view/wx-print/index.vue

@@ -120,21 +120,9 @@ export default {
             template: layout,
           })
           this.hiprintTemplate=hiprintTemplate
-          // hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:'datauristring'}).then(dataURL=>{
-          //   let pdf = this.dataURLtoFile(dataURL, "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 => {
-          //     if (res.code === this.$config.SUCCESS_CODE) {
-          //       console.log('upload-res',res)
-          //     }
-          //   })
-          // })
-
-          //Blob
-          hiprintTemplate.toPdf(printData,'单据打印',{isDownload:false,type:''}).then(blob=>{
-            this.blob=blob
-            let pdf =this.blobToFile(blob, 'blob.pdf')
+          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);
@@ -144,9 +132,26 @@ export default {
                 console.log('upload-res',res)
               }
             })
-          }).catch(err => {
-            this.err=err
           })
+          // 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'))
         }