<template>
  <div>
    <object classid="clsid:0671FEBB-ADE5-4250-B539-BF5DFEB0EAB2" width="0" height="0" ref="TzPrintTool" id="TzPrintTool"></object>
  </div>
</template>

<script>
  import isIe from '@/libs/isIe'
  export default {
    data() {
      return {}
    },
    components: {},
    mounted() {
    },
    methods: {
      getDom () {
        return this.$refs['TzPrintTool'] // document.getElementById('TzPrintTool')
      },
      print (url, copies) {
        let tmp = copies ? copies : 1
        if (/ie/.test(isIe)) {
          let TzPrintTool = this.getDom()
          if(document.all.TzPrintTool.object) {
            TzPrintTool.Print(url, '', tmp)
            return true
          } else {
            this.downloadShow('防伪打印,需要下载安装【防伪打印组件】')
            return false
          }
          /* if ('Print' in this.$refs['TzPrintTool']) {
            TzPrintTool.Print(url, '', tmp)
            return true
          } else {
            this.downloadShow('防伪打印,需要下载安装【防伪打印组件】')
            return false
          } */
        } else {
          this.publicUtil.alertWarn('请使用IE11浏览器')
          return false
        }
      },
      downloadShowNotice(content) {
        this.$Modal.open({
          title: '升级下载提示',
          duration: 0,
          render: h => {
            return h('span', [
              '防伪打印组件需要升级,请下载安装',
              h('a', {
                on: {
                  click: () => {
                    window.open('/防伪打印组件.exe')
                  }
                }
              }, '防伪打印组件')
            ])
          }
        })
      },
      downloadShow(content) {
        this.$Modal.confirm({
          title: '下载提示',
          content: content,
          okText: '下载',
          onOk: () => {
            window.open('/防伪打印组件.exe')
          },
          onCancel: () => {
          }
        })
      }
    }
  }
</script>
Logo

前往低代码交流专区

更多推荐