前端导出下载方法
exporttable () {
const apiUrl = "http://localhost:9999/export/telDetails";
let param = new URLSearchParams();
param.append('startTime', this.addForm.startTime);
param.append('endTime', this.addForm.endTime);
this.$http.post(apiUrl, param, {
responseType: 'blob' }).then((res) => {
const link = document.createElement('a')
let blob = new Blob([res.data], {
type: 'application/vnd.ms-excel' })
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
let num = ''
for (let i = 0; i < 10; i++) {
num += Math.ceil(Math.random() * 10)
}
link.setAttribute('download', '话务详情表_' + num + '.xlsx')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
})
},
- data数据定义
data () {
return {
addForm: {
endTime: '',
landingNumber: '',
startTime: '',
trunkNumber: '',
called: '1',
extension: '',
direction: '',
callResult: '',
batchNumber: '',
userData: '',
seatNumber: '',
calling: '',
groupId: '',
ringingTime: ''
},
dialogAddgsVisible: false,
title: ''
}
},
后端导出下载代码