|
|
|
|
@ -229,10 +229,43 @@ export default { |
|
|
|
|
cancelButtonText: "取消", |
|
|
|
|
type: "warning" |
|
|
|
|
}).then(() => { |
|
|
|
|
NProgress.start(); |
|
|
|
|
// NProgress.start(); |
|
|
|
|
exportBlob(`/api/weChatUser/export?${this.website.tokenHeader}=${getToken()}${this.query.phone ? '&phone=' + this.query.phone : ''}${this.query.username ? '&username=' + this.query.username : ''}`).then(res => { |
|
|
|
|
downloadXls(res.data, `用户数据${dateNow()}.xlsx`); |
|
|
|
|
NProgress.done(); |
|
|
|
|
// const contentDisposition = res.headers['content-disposition'] |
|
|
|
|
// const fileNameRegexp = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
|
|
|
|
// const matches = fileNameRegexp.exec(contentDisposition); |
|
|
|
|
// const filename = (matches != null && matches[1] ? decodeURIComponent(matches[1].replace(/['"]/g, '')) : '微信用户.xlsx'); |
|
|
|
|
// downloadXls(res.data,filename); |
|
|
|
|
// NProgress.done(); |
|
|
|
|
if (!res || !res.data) { |
|
|
|
|
this.$message({ |
|
|
|
|
type: "error", |
|
|
|
|
message: "导出失败!", |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let blob = new Blob([res.data]); //response.data为后端传的流文件 |
|
|
|
|
const contentDisposition = res.headers['content-disposition'] |
|
|
|
|
const fileNameRegexp = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
|
|
|
|
const matches = fileNameRegexp.exec(contentDisposition); |
|
|
|
|
const filename = (matches != null && matches[1] ? decodeURIComponent(matches[1].replace(/['"]/g, '')) : '微信用户.xlsx'); |
|
|
|
|
let downloadFilename = filename; //设置导出的文件名 |
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|
|
|
|
//兼容ie浏览器 |
|
|
|
|
window.navigator.msSaveOrOpenBlob(blob, downloadFilename); |
|
|
|
|
} else { |
|
|
|
|
//谷歌,火狐等浏览器 |
|
|
|
|
let url = window.URL.createObjectURL(blob); |
|
|
|
|
let downloadElement = document.createElement("a"); |
|
|
|
|
downloadElement.style.display = "none"; |
|
|
|
|
downloadElement.href = url; |
|
|
|
|
downloadElement.download = downloadFilename; |
|
|
|
|
document.body.appendChild(downloadElement); |
|
|
|
|
downloadElement.click(); |
|
|
|
|
document.body.removeChild(downloadElement); |
|
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
|
} |
|
|
|
|
this.$message({ type: "success", message: "导出成功!" }); |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|