浏览代码

feat: 报告下载调整

zhangjie 3 月之前
父节点
当前提交
dd392c99fd
共有 3 个文件被更改,包括 16 次插入16 次删除
  1. 1 3
      src/modules/mark/api.js
  2. 14 12
      src/modules/mark/components/ScoreReportPreview.vue
  3. 1 1
      vue.config.js

+ 1 - 3
src/modules/mark/api.js

@@ -225,7 +225,5 @@ export const scoreReport = (datas) => {
   return $postParam("/api/admin/mark/archive/score/report", datas);
 };
 export const scoreReportExport = (datas) => {
-  return $post("/api/admin/mark/archive/score/report/download", datas, {
-    responseType: "blob",
-  });
+  return $post("/api/admin/mark/archive/score/report/download", datas);
 };

+ 14 - 12
src/modules/mark/components/ScoreReportPreview.vue

@@ -35,7 +35,7 @@
 
 <script>
 import Report from "./report/Report.vue";
-import { downloadByApi } from "@/plugins/download";
+import { downloadByUrl } from "@/plugins/download";
 import { scoreReportExport } from "../api";
 
 export default {
@@ -73,22 +73,24 @@ export default {
       this.downloading = true;
 
       const filename = `${this.title}.pdf`;
-      const res = await downloadByApi(() => {
-        const formData = new FormData();
-        const htmlFile = new File(
-          [this.$refs.reportRef.getTemp()],
-          `${Date.now()}.html`,
-          { type: "text/html" }
-        );
-        formData.append("file", htmlFile);
-        return scoreReportExport(formData);
-      }, filename).catch((e) => {
+      const formData = new FormData();
+      const htmlFile = new File(
+        [this.$refs.reportRef.getTemp()],
+        `${Date.now()}.html`,
+        { type: "text/html" }
+      );
+      formData.append("file", htmlFile);
+      formData.append("examId", this.instance.examId);
+      formData.append("paperNumber", this.instance.paperNumber);
+      const res = await scoreReportExport(formData).catch((e) => {
         this.$message.error(e || "下载失败,请重新尝试!");
       });
       this.downloading = false;
 
       if (!res) return;
-      this.$message.success("下载成功!");
+
+      downloadByUrl(res, filename);
+      this.$message.success("开始下载");
     },
   },
 };

+ 1 - 1
vue.config.js

@@ -11,7 +11,7 @@ let config = {
   devServer: {
     port: process.env.VUE_APP_DEV_PORT || 8056,
     proxy: {
-      "/(api|fss|pdf-temp)/": {
+      "/(api|fss|pdf-temp|file-temp)/": {
         target: process.env.VUE_APP_DEV_PROXY,
         changeOrigin: true,
       },