Kaynağa Gözat

Merge branch 'develop_lcgz' of http://git.chelingzhu.com/jianguan-web/qpls-md-html into develop_lcgz

chenrui 3 yıl önce
ebeveyn
işleme
6014b94774
1 değiştirilmiş dosya ile 15 ekleme ve 7 silme
  1. 15 7
      src/libs/JGPrint.js

+ 15 - 7
src/libs/JGPrint.js

@@ -10,6 +10,7 @@ export const JGPrint = function (data, type, printerType) {
   // 针式打印
   if (printerType == 'NEEDLE') {
     const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
+    console.log(LODOP,'LODOP')
     if (!LODOP) {
       confirm({
         title: '提示?',
@@ -88,15 +89,22 @@ export const demoDownloadPDF = function (url) {
 // 导出下载excel
 export const downloadExcel = function (data, fileName) {
   if (!data) { return }
-  const url = window.URL.createObjectURL(new Blob([data]))
-  const link = document.createElement('a')
-  link.style.display = 'none'
-  link.href = url
   const a = moment().format('YYYYMMDDHHmmss')
   const fname = fileName + a
-  link.setAttribute('download', fname + '.xlsx')
-  document.body.appendChild(link)
-  link.click()
+  const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
+  if (window.navigator && window.navigator.msSaveOrOpenBlob) {
+    navigator.msSaveBlob(blob, fname + '.xlsx')
+  } else {
+    const link = document.createElement('a')
+    link.style.display = 'none'
+    var href = URL.createObjectURL(blob)
+    link.href = href
+    link.setAttribute('download', fname + '.xlsx')
+    document.body.appendChild(link)
+    link.click()
+    document.body.removeChild(link)
+    window.URL.revokeObjectURL(href) // 释放掉blob对象
+  }
 }
 
 /*