文件导出:后端返回文件流,前端导出xlsx

function getExportLoginDate (getLogParams) {
  inbiz.request.post('/edrms/api/OperationLog/ExportOperationLog?order=desc&sort=creationTime', {
    responseType: 'blob',
    params: {
      where: getLogParams,
    }
  }).then((res) => {
    if (res.code === "Data:NotFound") {
      inbiz.message.error({
        content: res.message,
        key: "",
      });
    } else {
      let elink = document.createElement('a');
      elink.download = '导出日志.xlsx';
      elink.style.display = 'none';
      let blob = new Blob([res], { type: 'application/octet-stream' });
      elink.href = URL.createObjectURL(blob);
      document.body.appendChild(elink);
      elink.click();
      document.body.removeChild(elink);
      inbiz.message.success({
        content: "导出成功",
        key: "",
      });
    }
  })
}

你可能感兴趣的:(前端)