请求下载Excel文件

  HTTP({
      method: 'post',
      url: API.projectManage.popeProjectReportExport,
      data,//参数
      responseType: 'arraybuffer',
      timeout:600000 
    }).then(res => {
      const url = window.URL.createObjectURL(
        new Blob([res], {
          type:
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
        })
      );
      const link = document.createElement('a');
      link.href = url;
      link.setAttribute(
        'download',
        intl.t(`项目查询{time}导出数据`,{
          time:moment().format('YYYYMMDDHHmm')
        }) 
      );
      document.body.appendChild(link);
      link.click();
      message.success(
        intl.t('导出成功')
      )
})

  

posted @ 2021-03-04 14:03  谢勇飞~  阅读(83)  评论(0编辑  收藏  举报