Bläddra i källkod

ie11 导出bug修复

lilei 3 år sedan
förälder
incheckning
d4fd8aeff5

+ 15 - 9
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,20 @@ 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, fileName + '.xlsx')
+  } else {
+    const link = document.createElement('a')
+    link.style.display = 'none'
+    var href = URL.createObjectURL(blob)
+    link.href = href
+    link.setAttribute('download', fileName + '.xlsx')
+    document.body.appendChild(link)
+    link.click()
+    document.body.removeChild(link)
+    window.URL.revokeObjectURL(href) // 释放掉blob对象
+  }
 }
 
 /*

+ 3 - 12
src/views/bulkManagement/bulkImport/list.vue

@@ -72,6 +72,7 @@
 import { STable, Upload } from '@/components'
 import { stockImportList, stockImportFinish, stockImportCancel, stockImportExportError } from '@/api/stockImport'
 import moment from 'moment'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, Upload },
   data () {
@@ -197,21 +198,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+		  const fileName = '散件导入错误项' + moment().format('YYYY_MMDD')
+		  downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const fname = '散件导入错误项' + moment('YYYY_MMDD')
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调

+ 3 - 13
src/views/bulkManagement/bulkWarehousingOrder/list.vue

@@ -146,6 +146,7 @@ import getDate from '@/libs/getDate.js'
 import basicInfoModal from './basicInfoModal.vue'
 import { sparePartsPurList, sparePartsPurCount, sparePartsPurDel, sparePartsPurPut, sparePartsPurExport } from '@/api/sparePartsPur'
 import { supplierAllList } from '@/api/supplier'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, VSelect, basicInfoModal, rangeDate },
   data () {
@@ -314,22 +315,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+          const fileName = '散件入库单' + moment().format('YYYYMMDDHHmmss')
+          downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      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 = '散件入库单' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     // 供应商下拉数据
     getSupplierList () {
       supplierAllList().then(res => {

+ 3 - 13
src/views/financialManagement/companyReceivablePayable/detail.vue

@@ -71,6 +71,7 @@
 
 <script>
 import moment from 'moment'
+import { downloadExcel } from '@/libs/JGPrint.js'
 import { STable, VSelect } from '@/components'
 import rangeDate from '@/views/common/rangeDate.vue'
 import { settleInfoList, settleInfoQueryReceiptOrPaySum } from '@/api/settle'
@@ -150,21 +151,10 @@ export default {
       this.exportLoading = true
       // customerBundleExportDelay(params).then(res => {
       //   this.exportLoading = false
-      //   this.download(res)
+	  // const fileName = '单位应收应付' + moment().format('YYYYMMDDHHmmss')
+	  // downloadExcel(res, fileName)
       // })
     },
-    download (data) {
-      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 = '单位应收应付' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    }
   },
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用

+ 3 - 13
src/views/inventoryManagement/inventoryChecking/detailModal.vue

@@ -151,6 +151,7 @@
 
 <script>
 import moment from 'moment'
+import { downloadExcel } from '@/libs/JGPrint.js'
 import { STable } from '@/components'
 import printModal from './printModal.vue'
 import ProductType from '@/views/common/productType.js'
@@ -319,7 +320,8 @@ export default {
           reader.readAsText(res)
         } else {
           if (this.nowType == 'export' || this.nowType == 'typeExport') {
-            this.download(res)
+			const fileName = '库存盘点' + moment().format('YYYYMMDDHHmmss')
+			downloadExcel(res, fileName)
           } else {
             this.print(res, objs.type)
           }
@@ -339,18 +341,6 @@ export default {
         window.frames['printficd'].print()
       }
     },
-    download (data) {
-      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 = '库存盘点' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    }
   },
   watch: {
     //  父页面传过来的弹框状态

+ 3 - 13
src/views/inventoryManagement/inventoryChecking/makeInventory.vue

@@ -172,6 +172,7 @@ import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import ProductType from '@/views/common/productType.js'
 import printModal from './printModal.vue'
+import { downloadExcel } from '@/libs/JGPrint.js'
 import { checkWarehouseDetailList, checkWarehouseDetailCount, checkWarehouseInventory, checkWarehouseDetail, checkWarehouseDetailSave, checkWarehouseCheckZero, checkWarehouseWarehouse, checkWarehouseDetailExport, checkWarehouseDetailPrint } from '@/api/checkWarehouse'
 export default {
   components: { STable, VSelect, ProductType, printModal },
@@ -404,7 +405,8 @@ export default {
           reader.readAsText(res)
         } else {
           if (this.nowType == 'export' || this.nowType == 'typeExport') {
-            this.download(res)
+			const fileName = '库存盘点' + moment().format('YYYYMMDDHHmmss')
+			downloadExcel(res, fileName)
           } else {
             this.print(res, objs.type)
           }
@@ -424,18 +426,6 @@ export default {
         window.frames['printficm'].print()
       }
     },
-    download (data) {
-      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 = '库存盘点' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    }
   },
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用

+ 3 - 12
src/views/inventoryManagement/inventoryImport/list.vue

@@ -73,6 +73,7 @@
 import { STable, Upload } from '@/components'
 import { stockImportList, stockImportFinish, stockImportCancel, stockImportKCExportError } from '@/api/stockImport'
 import moment from 'moment'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, Upload },
   data () {
@@ -191,21 +192,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+		  const fileName = '库存导入错误项' + moment().format('YYYY_MMDD')
+		  downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const fname = '库存导入错误项' + moment('YYYY_MMDD')
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调

+ 3 - 13
src/views/inventoryManagement/inventoryQuery/list.vue

@@ -129,6 +129,7 @@ import { dealerProductTypeList } from '@/api/dealerProductType'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { STable, VSelect } from '@/components'
 import inventoryQueryDetailModal from './detailModal.vue'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, VSelect, inventoryQueryDetailModal },
   data () {
@@ -276,22 +277,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+		  const fileName = '库存查询' + moment().format('YYYYMMDDHHmmss')
+		  downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      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 = '库存查询' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     getProductType () {
       dealerProductTypeList({}).then(res => {
         this.recursionFun(res.data)

+ 3 - 14
src/views/inventoryManagement/inventoryWarning/list.vue

@@ -182,6 +182,7 @@ import { STable, VSelect } from '@/components'
 import { stockWarnList, stockWarnSaveBatch } from '@/api/stockWarn'
 import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { dealerProductTypeList } from '@/api/dealerProductType'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, VSelect },
   data () {
@@ -408,22 +409,10 @@ export default {
       this.exportLoading = true
       // customerBundleExportDelay(params).then(res => {
       //   this.exportLoading = false
-      //   this.download(res)
+	  // const fileName = '库存预警' + moment().format('YYYYMMDDHHmmss')
+	  // downloadExcel(res, fileName)
       // })
     },
-    //  下载
-    download (data) {
-      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 = '库存预警' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调

+ 3 - 13
src/views/productManagement/priceChangeRecord/list.vue

@@ -121,6 +121,7 @@ import rangeDate from '@/views/common/rangeDate.vue'
 import { productBrandQuery } from '@/api/productBrand'
 import { productTypeQuery } from '@/api/productType'
 import { productPriceChangeList, getCurrentDealer } from '@/api/product'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   components: { STable, VSelect, rangeDate },
   data () {
@@ -282,21 +283,10 @@ export default {
       this.exportLoading = true
       // customerBundleExportDelay(params).then(res => {
       //   this.exportLoading = false
-      //   this.download(res)
+      // const fileName = '价格变更记录' + moment().format('YYYYMMDDHHmmss')
+      // downloadExcel(res, fileName)
       // })
     },
-    download (data) {
-      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 = '价格变更记录' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     //  产品品牌  列表
     getProductBrand () {
       productBrandQuery({}).then(res => {

+ 3 - 13
src/views/productManagement/productInfo/list.vue

@@ -138,6 +138,7 @@ import { dealerProductTypeList } from '@/api/dealerProductType'
 import { dealerProductList, dealerProductUpdate, dealerProductExport } from '@/api/dealerProduct'
 import { STable, VSelect } from '@/components'
 import productInfoDetailModal from './detailModal.vue'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   name: 'ProductList',
   components: { STable, VSelect, productInfoDetailModal },
@@ -285,22 +286,11 @@ export default {
       this.spinning = true
       dealerProductExport(this.queryParam).then(res => {
         this.exportLoading = false
-        this.download(res)
         this.spinning = false
+		const fileName = '自建产品列表' + moment().format('YYYYMMDDHHmmss')
+		downloadExcel(res, fileName)
       })
     },
-    download (data) {
-      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 = '自建产品列表' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     //  产品品牌  列表
     getProductBrand () {
       dealerProductBrandQuery({}).then(res => {

+ 3 - 13
src/views/productManagement/productInfoJg/list.vue

@@ -115,6 +115,7 @@ import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
 import { productTypeQuery } from '@/api/productType'
 import { productList, getCurrentDealer } from '@/api/product'
 import { STable, VSelect } from '@/components'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   name: 'ProductJgList',
   components: { STable, VSelect },
@@ -241,21 +242,10 @@ export default {
       this.exportLoading = true
       // dealerProductExport(this.queryParam).then(res => {
       //   this.exportLoading = false
-      //   this.download(res)
+	  // const fileName = '箭冠产品列表' + moment().format('YYYYMMDDHHmmss')
+	  // downloadExcel(res, fileName)
       // })
     },
-    download (data) {
-      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 = '箭冠产品列表' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     //  产品品牌  列表
     getProductBrand () {
       dealerProductBrandQuery({ 'sysFlag': '1' }).then(res => {

+ 3 - 14
src/views/purchasingManagement/purchaseOrder/detail.vue

@@ -143,7 +143,7 @@ import { STable, VSelect } from '@/components'
 import { purchaseDetailBySn, purchaseDetailPrint, purchaseDetailExport, purchaseExportDetail } from '@/api/purchase'
 import { purchaseDetailList } from '@/api/purchaseDetail'
 import Print from '@/views/common/print.vue'
-import { hdPrint } from '@/libs/JGPrint'
+import { hdPrint, downloadExcel } from '@/libs/JGPrint'
 export default {
   components: { STable, VSelect, Print },
   data () {
@@ -229,22 +229,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+			const fileName = '采购产品' + moment().format('YYYYMMDDHHmmss')
+			downloadExcel(res, fileName)
         }
       })
     },
-    download (data, type) {
-      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 = '采购产品' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    }
   },
   mounted () {
     if (!this.$store.state.app.isNewTab) { // 页签刷新时调用

+ 3 - 12
src/views/purchasingManagement/purchaseOrder/importGuideModal.vue

@@ -66,6 +66,7 @@
 import ChooseImportModal from './chooseImportModal.vue'
 import { Upload } from '@/components'
 import { purchaseDetailDownload } from '@/api/purchase'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   name: 'ImportGuideModal',
   components: { ChooseImportModal, Upload },
@@ -134,21 +135,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+		  const fileName = '采购单产品导入模板'
+		  downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      if (!data) { return }
-      const url = window.URL.createObjectURL(new Blob([data]))
-      const link = document.createElement('a')
-      link.style.display = 'none'
-      link.href = url
-      const fname = '采购单产品导入模板'
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    }
   },
   watch: {
     //  父页面传过来的弹框状态

+ 3 - 13
src/views/salesManagement/salesQuery/list.vue

@@ -187,6 +187,7 @@ import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount, s
 import { settleStyleQueryAll } from '@/api/settleStyle'
 import rangeDate from '@/views/common/rangeDate.vue'
 import custList from '@/views/common/custList.vue'
+import { downloadExcel } from '@/libs/JGPrint.js'
 export default {
   name: 'TableList',
   components: { STable, VSelect, chooseCustomModal, rangeDate, auditModal, custList },
@@ -395,22 +396,11 @@ export default {
           })
           reader.readAsText(res)
         } else {
-          this.download(res)
+          const fileName = '销售列表' + moment().format('YYYYMMDDHHmmss')
+          downloadExcel(res, fileName)
         }
       })
     },
-    download (data) {
-      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 = '销售列表' + a
-      link.setAttribute('download', fname + '.xlsx')
-      document.body.appendChild(link)
-      link.click()
-    },
     // 获取收款方式
     getSettleStyle () {
       settleStyleQueryAll().then(res => {