1.原生下載
exportEpExcleData(){
const _this=this
this.init.exportLoading=true
const apiUrl=`${urlObj.exportEpExcleData}?regionCnName=${this.page.echartsParams.regionCnName}&repofficeCnName=${this.page.echartsParams.repofficeCnName}&endCustName=${this.page.echartsParams.endCustName}`
const xmlhttp=new XMLHttpRequest()
xmlhttp.open("GET",apiUrl,true)
xmlhttp.responseType="blob"
xmlhttp.onload=function(){if(this.status==200){const fileName=this.getResponseHeader("content-disposition").split(";")[1].split("=")[1].replace(/\"/g,"")
const blob=this.response
const url=window.URL.createObjectURL(blob)//創建下載鏈接
const el=document.createElement("a")//轉換完成,創建一個a標籤用於下載el.download=decodeURI(fileName)//下載的文件名el.href=url
document.body.appendChild(el)
el.click()
document.body.removeChild(el)//下載完成移除元素window.URL.revokeObjectURL(url)//釋放掉blob對象
_this.init.exportLoading=false}}
xmlhttp.send()},