<div class="upload-button" @click="handleExportList()">批量导出</div>
//批量导出
handleExportList() {
const params = {
areaId: this.staffLsitForm.area_id,
isSalesman: this.staffLsitForm.is_salesman,
mobile: this.staffLsitForm.mobile,
name: this.staffLsitForm.name,
shopId: this.staffLsitForm.shop_id,
staffStatus: this.staffLsitForm.staff_status,
}
const token = getCookie(`PHPSESSID`) || '';
var xhr = new XMLHttpRequest();
//GET请求,请求路径url,async(是否异步)
xhr.open('GET', `${getJavaUserbase()}/manage/shopStaff/batchExport?${paramsStr(params)}`, true);
//设置请求头参数的方式,如果没有可忽略此行代码
xhr.setRequestHeader("phpsessid", token);
//设置响应类型为 blob
xhr.responseType = "blob";
//关键部分
xhr.onload = function (e) {
//如果请求执行成功
if (this.status == 200) {
var blob = this.response;
var reader = new FileReader();
reader.readAsDataURL(blob)
reader.onload = function (e) {
var a = document.createElement("a");
a.download = '员工导出表格.xlsx';
a.href = e.target.result;
document.getElementsByTagName('body')[0].append(a); // 修复firefox中无法触发click
a.click();
a.remove();
};
}
};
//发送请求
xhr.send();
// 关闭弹窗
this.exportBox = false;
},
vue 文件导出
最新推荐文章于 2024-07-19 10:03:02 发布