代码:
//前端请求格式
exportLiveRecords: (data, responseType) => request({
url: '/kst-management/record/exportRecords',
method: 'post',
data,
responseType
}),
//导出方法
exportLiveRecords(){
let data = {liveCode:this.liveCode, shareCode: this.shareCode}
let responseType = 'blob'
this.$api.exportLiveRecords(data,responseType).then(res=>{
const blob = new Blob([res],{type: 'application/vnd.ms-excel;charset=utf-8'})
const fileName = `观看记录导出${this.$dayjs().format('YYYY年MM月DD日 HH时mm分ss秒')}.xlsx`
let a = document.createElement('a')
a.download = fileName
a.href = URL.createObjectURL(blob)
a.click()
URL.revokeObjectURL(a.href) // 释放URL 对象
document.body.removeChild(a)
}).catch(err=>{
})
},