……

二维码生成及打印

Posted on 2022-08-22 13:36  WALL*E  阅读(56)  评论(0编辑  收藏  举报
creatQrCode(hospitalId,ref,qrcodeWid) {//生成二维码
      var qrcode =''
      qrcode = new QRCode(ref, {
          text: hospitalId, // 需要转换为二维码的内容
          width: qrcodeWid,
          height: qrcodeWid,
          colorDark: '#000000',
          colorLight: '#ffffff',
          correctLevel: QRCode.CorrectLevel.H
      });
    }

async printBottle(row) {
 this.printData =row
      let prints = document.getElementsByClassName('prints')[0]
      let printBottl = document.getElementsByClassName('printBottl')[0]
      printBottl.classList.remove('printF')
      prints.classList.add('printF')
      let qrcodeWid=100
      //二维码
      this.$nextTick(()=>{
        this.printData.forEach((item,index)=>{
          this.creatQrCode(row.hospitalId,'qrCodeUrl'+index,qrcodeWid) 
        }) ;
        setTimeout(function(){
          window.print();
        },1000)
      })
    },