//下载导出报表 exportConsumptionChartAndTable(接口名)
exportExcel () {
let _this = this
exportConsumptionChartAndTable(_this.searchForm).then(res => {
let blob = new Blob([res.data],{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
let filename = res.headers['content-disposition'].split(';')[1].split('=')[1];
filename = decodeURI(filename);
if('download' in document.createElement('a')) { // 支持a标签download的浏览器
const link = document.createElement('a')
link.download = filename
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
document.body.appendChild(link)
link.click() // 执行下载
URL.revokeObjectURL(link.href) // 释放url
document.body.removeChild(link) // 释放标签
} else { // 其他浏览器
navigator.msSaveBlob(blob, filename)
}
// let linkurl = URL.createObjectURL(blob);
// window.location.href = linkurl
}).catch(error => {
console.log(error)
})
},