export function handerFillZero(num){ return num>=10 ? num : '0'+num; }
export function exportExcel(vm, params) { if (vm.choosedResumeIds.length == 0) return; vm.$http.get(url_exportCsv, { params: { resumes: vm.choosedResumeIds.join(','), response: true, t:Date.now() } }).then((res) => { // console.log('excel-res:', res); // console.log('excel-res:',res.request.getAllResponseHeaders()); // console.log("res.headers['content-type']", res.headers['content-type']); let _file = new Blob([new Uint8Array([0xEF, 0xBB, 0xBF]),res.data], { type: 'text/plain;charset=utf-8' }), _date = new Date(), _year = _date.getFullYear(), _month = _date.getMonth()+1, _day = _date.getDate(), _hour = _date.getHours(), _min = _date.getMinutes(), _sec = _date.getSeconds(); // console.log('_file',_file); var href = window.URL.createObjectURL(_file); // console.log('href', href) var downloadElement = document.createElement('a'); downloadElement.href = href; downloadElement.download = `导出的List ${_year}-${handerFillZero(_month)}-${handerFillZero(_day)}.csv`; //下载后文件名 document.body.appendChild(downloadElement); downloadElement.click(); //点击下载 document.body.removeChild(downloadElement); //下载完成移除元素 window.URL.revokeObjectURL(href); //释放掉blob对象 ipcRenderer.removeAllListeners('exprot-excel-success'); ipcRenderer.on('exprot-excel-success',(e,params)=>{ if(params.state=='completed'){ vm.$message({ type:'success', message:'Excel导出成功' }) vm.clearChoosedIds(); } }) }) }