( fileName: string, url: string, params: any, data: any, loading?: NProgress | Ref<boolean>, )
| 349 | data: any, |
| 350 | loading?: NProgress | Ref<boolean>, |
| 351 | ) => Promise<any> = ( |
| 352 | fileName: string, |
| 353 | url: string, |
| 354 | params: any, |
| 355 | data: any, |
| 356 | loading?: NProgress | Ref<boolean>, |
| 357 | ) => { |
| 358 | return promise( |
| 359 | request({ |
| 360 | url: url, |
| 361 | method: 'post', |
| 362 | params, // 查询字符串参数 |
| 363 | data, // 请求体数据 |
| 364 | responseType: 'blob', |
| 365 | }), |
| 366 | loading, |
| 367 | ).then((res: any) => { |
| 368 | if (res) { |
| 369 | const blob = new Blob([res], { |
| 370 | type: 'application/vnd.ms-excel', |
| 371 | }) |
| 372 | const link = document.createElement('a') |
| 373 | link.href = window.URL.createObjectURL(blob) |
| 374 | link.download = fileName |
| 375 | link.click() |
| 376 | // 释放内存 |
| 377 | window.URL.revokeObjectURL(link.href) |
| 378 | } |
| 379 | return true |
| 380 | }) |
| 381 | } |
| 382 | |
| 383 | export const exportFilePost: ( |
| 384 | fileName: string, |
no test coverage detected