vue打印表格

308 阅读1分钟

1.00000

 <el-button @click="exportTemplate">打印</el-button>
    exportTemplate() {
      exportMoveReport(this.businessKey).then(res => {
        const blob = new Blob([res.data])
        const fileName = '借调单.docx'
        if ('download' in document.createElement('a')) { // 非IE下载
          const elink = document.createElement('a')
          elink.download = fileName
          elink.style.display = 'none'
          elink.href = URL.createObjectURL(blob)
          document.body.appendChild(elink)
          elink.click()
          URL.revokeObjectURL(elink.href) // 释放URL 对象
          document.body.removeChild(elink)
        } else { // IE10+下载
          navigator.msSaveBlob(blob, fileName)
        }
      })
    }

2.00000

     <el-button @click="exportTemplate">打印</el-button>
    exportTemplate() {
      exportMoveReport(this.businessKey).then(res => {
        const blob = new Blob([res.data])
        const fileName = '归还单.docx'
        if ('download' in document.createElement('a')) { // 非IE下载
          const elink = document.createElement('a')
          elink.download = fileName
          elink.style.display = 'none'
          elink.href = URL.createObjectURL(blob)
          document.body.appendChild(elink)
          elink.click()
          URL.revokeObjectURL(elink.href) // 释放URL 对象
          document.body.removeChild(elink)
        } else { // IE10+下载
          navigator.msSaveBlob(blob, fileName)
        }
      })
    },