//获取当前时间
getNowFormatDate() {
var date = new Date();
var seperator1 = “-”;
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = “0” + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = “0” + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
},
//导出Excel
exportExcel(){
var time=this.getNowFormatDate()
this.http({
url: this.$http.adornUrl(/user/withdraw/money/excel
),//封装的请求
method: “POST”,
responseType: ‘blob’//重要的responseType 类型动态设置
}).then((response) => {
// console.log(response)
var blob = new Blob([response.data], {type: ‘application/ms-excel’})
var downloadElement = document.createElement(‘a’)
var href = window.URL.createObjectURL(blob) // 创建下载的链接
downloadElement.href = href
downloadElement.download = time + ‘.xls’ // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click() // 点击下载
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
this.dataListLoading = false
})
},