const exportX=async ()=>{ await getData() let filter=JSON.parse(JSON.stringify(data.filter)) filter.PageIndex=1 data.loading=true console.log("==============") console.log(filter) const res=await analyseApi.dayExportExcel(filter).catch(e=>{ ElMessage.error(e) data.loading=false }) console.log(res) let url = window.URL.createObjectURL(new Blob([res.data],{ type: 'application/vnd.ms-excel' })); let a = document.createElement("a"); a.style.display = "none"; a.href = url; a.setAttribute("download", '每日汇总'+moment().format('YYYY-MM-DD-HH-mm-ss')+".xlsx"); document.body.appendChild(a); a.click(); //执行下载 document.body.removeChild(a); //释放标签 window.URL.revokeObjectURL(a.href); //释放url data.loading=false }
接口
export const dayExportExcel=(data:any)=>{ return request.post({ url:'/UnionBillAudit/ExportDayAudit', data, responseType: 'blob', }) }