Pārlūkot izejas kodu

feat: 报告下载调整

zhangjie 2 mēneši atpakaļ
vecāks
revīzija
7f24ec4fcb

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

@@ -219,7 +219,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("开始下载");
     },
   },
 };