/*补货人员统计列表导出*/
export() {
const startDateInput = new Date(this.startDateInput);
const endDateInput = new Date(this.endDateInput);
let startDate = '';
let endDate = '';
if (this.startDateInput !== null && this.startDateInput !== undefined) {
startDate = startDateInput.getFullYear() + '-' + (startDateInput.getMonth() + 1) + '-' + startDateInput.getDate();
}
if (this.endDateInput !== null && this.endDateInput !== undefined) {
endDate = endDateInput.getFullYear() + '-' + (endDateInput.getMonth() + 1) + '-' + endDateInput.getDate();
}
const params = {
'startDate': startDate,
'endDate': endDate,
'companyId': this.selectCompany,
'operator': this.procurementName,
'isShowAll': 1
};
window.location.href = this.appProperties.getUrl() +
'/ReplenishmentReport/exportUserAll?token=' + sessionStorage.getItem('token')
+ '&companyId=' + this.selectCompany
+ '&operator=' + this.procurementName
+ '&isShowAll=1&startDate=' + startDate
+ '&endDate=' + endDate;
/*const url = this.appProperties.getUrl() + '/ReplenishmentReport/exportUserAll';
this.appService.postDataDownLoad(url, params).subscribe(
data => {
const blob = new Blob([data], {type: 'application/vnd.ms-excel'});
const fileName = '机器补货盘点统计.xls';
this.downLoad(blob, fileName);
},
error => {
console.log(error);
}
);*/
}
/*导出下载事件*/
downLoad(blob, fileName) {
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, fileName);
} else {
const link = document.createElement('a');
const body = document.querySelector('body');
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.style.display = 'none';
body.appendChild(link);
link.click();
body.removeChild(link);
window.URL.revokeObjectURL(link.href);
}
}复制代码
前端导出xls
转载于:https://juejin.im/post/5c3593bbe51d45523235cc54