tradeDownloadExcel(data).then(async res => {
if (res.data.type === 'application/json') {
// const text = await res.data.text()
// const jsonText = await JSON.parse(text)
// this.downloadExcelShow = true
// this.$message.error(jsonText.msg)
const that = this
this.downloadExcelShow = true
let reader = new FileReader();
reader.readAsText(res.data);
reader.onload = function(e){
const {msg} = JSON.parse(reader.result)
that.$message.error(msg)
}
} else {
let url = window.URL.createObjectURL(new Blob([res.data], {type: "application/vnd.ms-excel"}))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', `交易订单管理.xls`)
document.body.appendChild(link)
link.click()
link.remove()
}
})