riku
2024-03-21 5f20f4bba739f0f81101a2c1d99f494647125e05
src/api/fysp/evaluateApi.js
@@ -26,16 +26,22 @@
    return $fysp
      .post(`evaluation/auto/record/download`, param, { responseType: 'blob' })
      .then((res) => {
        // return res.data;
        const name = Base64.decode(res.headers.get('filename'));
        const url = window.URL.createObjectURL(res.data);
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', name);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        window.URL.revokeObjectURL(url);
        // 文档未生成,已启动文档生成后台任务
        if (res.data.type == 'application/json') {
          return false
        }
        // 文档已存在,直接下载
        else {
          const name = Base64.decode(res.headers.get('filename'));
          const url = window.URL.createObjectURL(res.data);
          const link = document.createElement('a');
          link.href = url;
          link.setAttribute('download', name);
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
          window.URL.revokeObjectURL(url);
        }
      });
  },
  }
};