<div class="whole_head_button" @click="download">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-download-1-copy" />
</svg>
导出
</div>
download() {
var query = {
page: this.currentPage,
count: this.pagesize,
admin_order_num: this.admin_order_num,
year: this.year,
month: this.month,
type: 'excel',
};
axios.defaults.baseURL = this.$store.state.baseUrls
this.axios({
method: 'get',
url: this.baseUrls + '/api/pcadmin/report/cost/order?' + this.encode(query),
responseType: 'blob',
}).then(response => {
const content = response.data
const blob = new Blob([content])
const fileName = '发票差异.xlsx'
if ('download' in document.createElement('a')) {
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)
document.body.removeChild(elink)
} else {
navigator.msSaveBlob(blob, fileName)
}
}).catch(error => {})
},