1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| const formData = new FormData(); formData.append('参数1', 参数1); formData.append('参数2', 参数2); formData.append('参数3', 参数3); formData.append('参数4', 参数4); formData.append('参数5', 参数5);
fetch(`/api${PREFIX_URL}/export`, { method: 'POST', body: formData, headers:{ 'token':store.state.token, } }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.blob(); }) .then(blob => { const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = this.projectInfo.projectName+'.'+(this.exportInfo.fileType==='1'?'xlsx':'csv'); document.body.appendChild(a); a.click(); a.remove(); window.URL.revokeObjectURL(url); }) .catch(error => { console.error('There was a problem with the fetch operation:', error); });
|