zhangjie 1 жил өмнө
parent
commit
8db0d8cbc5

+ 19 - 3
src/components/ImportFile.vue

@@ -49,7 +49,8 @@
         size="small"
         type="primary"
         icon="icon icon-export-white"
-        @click="exportFile"
+        :loading="downloading"
+        @click="toDownload"
       >
         下载模板
       </el-button>
@@ -62,6 +63,7 @@
 <script>
 import { fileMD5 } from "@/plugins/md5";
 import { $httpWithMsg } from "@/plugins/axios";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "ImportFile",
@@ -113,6 +115,7 @@ export default {
       uploadDataDict: {},
       filename: "",
       fileValid: false,
+      downloading: false,
     };
   },
   methods: {
@@ -233,8 +236,21 @@ export default {
       this.res = {};
       this.$refs.UploadComp.clearFiles();
     },
-    exportFile() {
-      window.location.href = this.templateUrl;
+    async toDownload() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return $httpWithMsg.get(this.templateUrl, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     setLoading(loading) {
       this.loading = loading;

+ 27 - 3
src/components/ImportFileDialog.vue

@@ -57,6 +57,7 @@
         size="small"
         type="primary"
         icon="icon icon-export-white"
+        :loading="downloading"
         @click="exportFile"
       >
         下载模板
@@ -70,6 +71,7 @@
 <script>
 import { fileMD5 } from "@/plugins/md5";
 import { $httpWithMsg } from "@/plugins/axios";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "ImportFileDialog",
@@ -130,6 +132,7 @@ export default {
       uploadDataDict: {},
       filename: "",
       fileValid: false,
+      downloading: false,
     };
   },
   methods: {
@@ -247,15 +250,36 @@ export default {
     },
     exportFile() {
       if (this.templateUrl) {
-        window.open(this.templateUrl);
+        this.toDownload();
         return;
       }
 
       if (this.templateDownloadHandle) {
-        this.templateDownloadHandle();
-        return;
+        this.toHandleDownload();
       }
     },
+    async toDownload() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return $httpWithMsg.get(this.templateUrl, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
+    },
+    async toHandleDownload() {
+      if (this.downloading) return;
+      this.downloading = true;
+      await this.templateDownloadHandle().catch(() => {});
+      this.downloading = false;
+    },
   },
 };
 </script>

+ 19 - 3
src/modules/card/components/BatchBuildCardDialog.vue

@@ -57,7 +57,8 @@
         size="small"
         type="primary"
         icon="icon icon-export-white"
-        @click="exportFile"
+        :loading="downloading"
+        @click="toDownload"
       >
         下载模板
       </el-button>
@@ -78,6 +79,7 @@
 <script>
 import { fileMD5 } from "@/plugins/md5";
 import { $httpWithMsg } from "@/plugins/axios";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "BatchBuildCardDialog",
@@ -127,6 +129,7 @@ export default {
       filename: "",
       fileValid: false,
       seqMode: "MODE3",
+      downloading: false,
     };
   },
   methods: {
@@ -242,8 +245,21 @@ export default {
       this.res = {};
       this.$refs.UploadComp.clearFiles();
     },
-    exportFile() {
-      window.location.href = this.templateUrl;
+    async toDownload() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return $httpWithMsg.get(this.templateUrl, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
   },
 };

+ 1 - 2
src/modules/card/views/CardManage.vue

@@ -284,7 +284,7 @@ export default {
       buildProgress: 0,
       // upload
       uploadUrl: `${QUESTION_API}/card/structure/import`,
-      templateUrl: "",
+      templateUrl: `${QUESTION_API}/card/import/template`,
     };
   },
   computed: {
@@ -312,7 +312,6 @@ export default {
       this.handleCurrentChange(1);
     }
     this.getCoursesList();
-    this.templateUrl = `${QUESTION_API}/card/import/template?$key=${this.user.key}&$token=${this.user.token}`;
     this.registBuildEmit();
   },
   beforeDestroy() {

+ 6 - 0
src/modules/paper/api.js

@@ -97,6 +97,12 @@ export const paperCardDeleteApi = (paperId) => {
     }
   );
 };
+export const paperPropertyExportApi = (paperId) => {
+  return $httpWithMsg.get(`${QUESTION_API}/paper/property/export`, {
+    params: { paperId },
+    responseType: "blob",
+  });
+};
 // paper-info
 export const paperAuditInfoApi = ({ paperId, curPage, pageSize }) => {
   return $httpWithMsg.get(

+ 19 - 21
src/modules/paper/views/EditPaper.vue

@@ -79,13 +79,6 @@
             @click="toImportPaperProperty"
             >导入属性</el-button
           >
-          <!-- <el-button
-            size="small"
-            type="primary"
-            plain
-            @click="toExportPaperAnswer"
-            >导出答案</el-button
-          > -->
           <el-button
             size="small"
             type="danger"
@@ -144,6 +137,7 @@
             size="small"
             type="primary"
             plain
+            :loading="downloading"
             @click="toExportPaperBlue"
             >导出试卷蓝图</el-button
           >
@@ -635,6 +629,7 @@ import {
   paperDetailAddQuestionApi,
   paperQuestionChangeApi,
   paperCardDeleteApi,
+  paperPropertyExportApi,
 } from "../api";
 import { QUESTION_API } from "@/constants/constants";
 
@@ -649,6 +644,7 @@ import QuestionEditDialog from "../../question/components/QuestionEditDialog.vue
 import SelectQuestionDialog from "../components/SelectQuestionDialog.vue";
 import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 import { calcSum } from "@/plugins/utils";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "EditPaper",
@@ -687,6 +683,7 @@ export default {
       curQuestion: {},
       paperQuestionIds: [],
       changeSelectQuestionMap: {},
+      downloading: false,
       // upload answer
       uploadAnswerUrl: "",
       answerTemplateUrl: "",
@@ -793,27 +790,28 @@ export default {
     },
     // 导入答案
     toImportPaperAnswer() {
-      const { key, token } = this.user;
-      this.answerTemplateUrl = `${QUESTION_API}/paper/answer/export/${this.paperId}?$key=${key}&$token=${token}`;
+      this.answerTemplateUrl = `${QUESTION_API}/paper/answer/export/${this.paperId}`;
       this.uploadAnswerUrl = `${QUESTION_API}/paper/answer/import/${this.paperId}`;
       this.$refs.ImportAnswerDialog.open();
     },
-    // 导出答案
-    toExportPaperAnswer() {
-      const { key, token } = this.user;
-      const url = `${QUESTION_API}/paper/answer/export/${this.paperId}?$key=${key}&$token=${token}`;
-      window.open(url);
-    },
     // 导出试卷蓝图
-    toExportPaperBlue() {
-      const { key, token } = this.user;
-      const url = `${QUESTION_API}/paper/property/export?paperId=${this.paperId}&$key=${key}&$token=${token}`;
-      window.open(url);
+    async toExportPaperBlue() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return paperPropertyExportApi(this.paperId);
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     // 导入属性
     toImportPaperProperty() {
-      const { key, token } = this.user;
-      this.propertyTemplateUrl = `${QUESTION_API}/paper/property/template?paperId=${this.paperId}&$key=${key}&$token=${token}`;
+      this.propertyTemplateUrl = `${QUESTION_API}/paper/property/template?paperId=${this.paperId}`;
       this.uploadPropertyUrl = `${QUESTION_API}/paper/property/import?paperId=${this.paperId}`;
       this.$refs.ImportPorpertyDialog.open();
     },

+ 1 - 1
src/modules/question/components/QuestionImportDialog.vue

@@ -239,7 +239,7 @@ export default {
         this.importType === "excel"
           ? "word/parse/excel_template_download"
           : "import/paper/template";
-      this.templateUrl = `${QUESTION_API}/${urlBody}?$key=${this.user.key}&$token=${this.user.token}`;
+      this.templateUrl = `${QUESTION_API}/${urlBody}`;
     },
     fileChange(fileData) {
       this.fileData = fileData;

+ 14 - 0
src/modules/questions/api.js

@@ -34,6 +34,12 @@ export const synthesizePaperDownloadApi = (datas) => {
     }
   );
 };
+export const synthesizePaperPreviewApi = (synthesizePaperId) => {
+  return $httpWithMsg.get(QUESTION_API + "/synthesize/paper/preview", {
+    params: { synthesizePaperId },
+    responseType: "blob",
+  });
+};
 
 export const paperPageListApi = (datas) => {
   return $httpWithMsg.post(
@@ -64,3 +70,11 @@ export const orgAiTransactionListApi = (rootOrgId) => {
 export const orgAiTransactionSaveApi = (datas) => {
   return $httpWithMsg.post(`${QUESTION_API}/ai/transaction/save`, datas);
 };
+
+// course
+export const courseExportApi = (params) => {
+  return $httpWithMsg.get(QUESTION_API + "/course/export", {
+    params,
+    responseType: "blob",
+  });
+};

+ 34 - 18
src/modules/questions/views/Course.vue

@@ -60,6 +60,7 @@
             type="primary"
             plain
             icon="icon icon-export"
+            :loading="downloading"
             @click="exportCourse"
             >导出</el-button
           >
@@ -249,6 +250,7 @@
               size="small"
               type="primary"
               icon="icon icon-export-white"
+              :loading="tempDownloading"
               @click="exportFile"
             >
               下载模板
@@ -279,6 +281,8 @@
 import { QUESTION_API } from "@/constants/constants.js";
 import { ENABLE_TYPE, LEVEL_TYPE } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { courseExportApi } from "../api";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "Course",
@@ -317,6 +321,8 @@ export default {
 
       courseDialog: false,
       relationDialog: false,
+      downloading: false,
+      tempDownloading: false,
 
       rules: {
         name: [
@@ -498,17 +504,19 @@ export default {
 
       this.courseDialog = true;
     },
-    exportCourse() {
-      var param = new URLSearchParams(this.formSearch);
-      window.open(
-        QUESTION_API +
-          "/course/export?$key=" +
-          this.user.key +
-          "&$token=" +
-          this.user.token +
-          "&" +
-          param
-      );
+    async exportCourse() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return courseExportApi(this.formSearch);
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
 
     closeCourse() {
@@ -781,13 +789,21 @@ export default {
       this.$refs.upload.clearFiles();
     },
     //下载模板
-    exportFile() {
-      window.location.href =
-        QUESTION_API +
-        "/course/importTemplate?$key=" +
-        this.user.key +
-        "&$token=" +
-        this.user.token;
+    async exportFile() {
+      if (this.tempDownloading) return;
+      this.tempDownloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(`${QUESTION_API}/course/importTemplate`, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.tempDownloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
   },
 };

+ 41 - 13
src/modules/questions/views/CourseProperty.vue

@@ -255,6 +255,7 @@
               size="small"
               type="primary"
               icon="icon icon-export-white"
+              :loading="tempDownloading"
               @click="exportFile"
             >
               下载模板
@@ -284,6 +285,8 @@
 <script>
 import { QUESTION_API } from "@/constants/constants";
 import { mapState } from "vuex";
+import { downloadByApi } from "@/plugins/download";
+
 export default {
   data() {
     return {
@@ -322,6 +325,8 @@ export default {
           { required: true, message: "请选择课程名称", trigger: "change" },
         ],
       },
+      downloading: false,
+      tempDownloading: false,
     };
   },
   computed: {
@@ -370,17 +375,29 @@ export default {
 
   methods: {
     // 导出
-    exportCourseProperty(coursePropertyIds) {
+    async exportCourseProperty(coursePropertyIds) {
       if (!coursePropertyIds.length) {
         this.$message.error("请选择要导出的属性");
         return;
       }
-      var param = new URLSearchParams({
-        $key: this.user.key,
-        $token: this.user.token,
-        coursePropertyIds: coursePropertyIds.join(),
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/courseProperty/detail/export`,
+          {
+            params: { coursePropertyIds: coursePropertyIds.join() },
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "导出失败,请重新尝试!");
       });
-      window.open(QUESTION_API + "/courseProperty/detail/export?" + param);
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("导出成功!");
     },
     //导入
     impCourseProperty() {
@@ -464,13 +481,24 @@ export default {
       this.$refs.upload.clearFiles();
     },
     //下载模板
-    exportFile() {
-      window.location.href =
-        QUESTION_API +
-        "/courseProperty/importTemplate?$key=" +
-        this.user.key +
-        "&$token=" +
-        this.user.token;
+    async exportFile() {
+      if (this.tempDownloading) return;
+      this.tempDownloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/courseProperty/importTemplate`,
+          {
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.tempDownloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     //查询所有课程属性
     searchFrom() {

+ 41 - 19
src/modules/questions/views/EditPaperPendingTrial.vue

@@ -99,6 +99,7 @@
                   size="small"
                   type="primary"
                   plain
+                  :loading="downloading"
                   @click="exportPaperAnswer()"
                   >导出答案</el-button
                 >
@@ -1126,7 +1127,11 @@
             @change="answerFileChange"
           />
         </div>
-        <el-button type="primary" @click="downAnswerTemplate">
+        <el-button
+          type="primary"
+          :loading="downloading"
+          @click="downAnswerTemplate"
+        >
           <span>下载模板</span>
         </el-button>
         <el-button
@@ -1230,6 +1235,7 @@ import AuditInfo from "./AuditInfo.vue";
 import AuditPaper from "./AuditPaper.vue";
 import QuestionAnswer from "../../question/components/QuestionAnswer.vue";
 import { checkRichTextContentIsEmpty } from "@/plugins/utils";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "EditPaperApp",
@@ -1367,6 +1373,7 @@ export default {
       showSubButtons: {},
       answerFileName: "",
       audioFileName: "",
+      downloading: false,
     };
   },
   computed: {
@@ -1753,12 +1760,21 @@ export default {
         return false;
       }
     },
-    downAnswerTemplate() {
-      var key = this.user.key;
-      var token = this.user.token;
-      window.open(
-        QUESTION_API + "/paper/answer/template?$key=" + key + "&$token=" + token
-      );
+    async downAnswerTemplate() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(`${QUESTION_API}/paper/answer/template`, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     openAnswerDialog() {
       this.checkResultAnswer = false;
@@ -2592,18 +2608,24 @@ export default {
         },
       });
     },
-    exportPaperAnswer() {
-      var key = this.user.key;
-      var token = this.user.token;
-      window.open(
-        QUESTION_API +
-          "/paper/answer/export/" +
-          this.paperId +
-          "?$key=" +
-          key +
-          "&$token=" +
-          token
-      );
+    async exportPaperAnswer() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/paper/answer/export/${this.paperId}`,
+          {
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     getSubQuesEditId(paperDetailUnit, subQuestion) {
       return paperDetailUnit.question.id + "_" + subQuestion.subNumber;

+ 21 - 12
src/modules/questions/views/ExamPaperPendingTrial.vue

@@ -258,6 +258,7 @@
                       size="mini"
                       type="primary"
                       plain
+                      :loading="downloading"
                       @click="exportPaper(scope.row)"
                       >下载</el-button
                     >
@@ -305,6 +306,7 @@ import { QUESTION_API } from "@/constants/constants";
 import { LEVEL_TYPE } from "../constants/constants";
 import { mapState } from "vuex";
 import AuditPaper from "./AuditPaper.vue";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   components: { AuditPaper },
@@ -364,6 +366,7 @@ export default {
       rules: {
         examId: [{ required: true, message: "请输入名称", trigger: "change" }],
       },
+      downloading: false,
     };
   },
   computed: {
@@ -470,18 +473,24 @@ export default {
       }
       return false;
     },
-    exportPaper(row) {
-      var key = this.user.key;
-      var token = this.user.token;
-      window.open(
-        QUESTION_API +
-          "/originalPaper/export/" +
-          row.id +
-          "?$key=" +
-          key +
-          "&$token=" +
-          token
-      );
+    async exportPaper(row) {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/originalPaper/export/${row.id}`,
+          {
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     submitPapers() {
       this.$confirm("确认提交试卷吗?", "提示", {

+ 26 - 40
src/modules/questions/views/GenPaper.vue

@@ -873,7 +873,7 @@ export default {
       this.printExamPackagePassword = "";
     },
     //导出试卷,答案,机考数据包
-    exportPaperInfo() {
+    async exportPaperInfo() {
       // 下载pdf
       if (this.exportModel.exportContent === "PAPER") {
         if (!this.curPaperTemp) {
@@ -918,48 +918,34 @@ export default {
           return false;
         }
       }
-      var key = this.user.key;
-      var token = this.user.token;
+
+      if (this.downloading) return;
+      this.downloading = true;
+      const params = {
+        psw: this.printExamPackagePassword,
+        seqMode: this.exportModel.seqMode,
+        templateId: this.exportModel.templateId,
+      };
+      let url = "";
       if (this.isShow) {
-        window.location.href =
-          QUESTION_API +
-          "/paper/export/" +
-          this.exportModel.id +
-          "/" +
-          this.exportModel.exportContent +
-          "/onLine" +
-          "?psw=" +
-          this.printExamPackagePassword +
-          "&$key=" +
-          key +
-          "&$token=" +
-          token +
-          "&seqMode=" +
-          this.exportModel.seqMode +
-          "&templateId=" +
-          this.exportModel.templateId;
-        this.exportDialog = false;
+        url = `${QUESTION_API}/paper/export/${this.exportModel.id}/${this.exportModel.exportContent}/onLine`;
       } else {
-        var paperIds = this.paperIds;
-        window.location.href =
-          QUESTION_API +
-          "/paper/batch_export/" +
-          paperIds +
-          "/" +
-          this.exportModel.exportContent +
-          "/onLine" +
-          "?psw=" +
-          this.printExamPackagePassword +
-          "&$key=" +
-          key +
-          "&$token=" +
-          token +
-          "&seqMode=" +
-          this.exportModel.seqMode +
-          "&templateId=" +
-          this.exportModel.templateId;
-        this.exportDialog = false;
+        url = `${QUESTION_API}/paper/batch_export/${this.paperIds}/${this.exportModel.exportContent}/onLine`;
       }
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(url, {
+          params,
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+
+      this.exportDialog = false;
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     removeItem() {
       sessionStorage.removeItem("gen_paper");

+ 18 - 7
src/modules/questions/views/ImportPaperInfo.vue

@@ -91,6 +91,7 @@
               type="info"
               plain
               icon="icon el-icon-download"
+              :loading="tempDownloading"
               @click="donwTemplate"
               >下载word模板
             </el-button>
@@ -121,6 +122,7 @@
 <script>
 import { QUESTION_API } from "@/constants/constants";
 import { mapState } from "vuex";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "ImportPaperInfo",
@@ -145,6 +147,7 @@ export default {
       errDialog: false,
       fileList: [],
       uploadHeaders: {},
+      tempDownloading: false,
     };
   },
   computed: {
@@ -316,13 +319,21 @@ export default {
       }
       return true;
     },
-    donwTemplate() {
-      window.location.href =
-        QUESTION_API +
-        "/import/paper/template?$key=" +
-        this.user.key +
-        "&$token=" +
-        this.user.token;
+    async donwTemplate() {
+      if (this.tempDownloading) return;
+      this.tempDownloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(`${QUESTION_API}/import/paper/template`, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.tempDownloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     //确定上传
     submitUpload() {

+ 21 - 8
src/modules/questions/views/License.vue

@@ -86,6 +86,7 @@
             v-show="form.type == 'OFFLINE'"
             type="primary"
             size="small"
+            :loading="tempDownloading"
             @click="exportFile"
             >导出硬件信息</el-button
           >
@@ -146,6 +147,8 @@
 <script>
 import { QUESTION_API } from "@/constants/constants";
 import { mapState } from "vuex";
+import { downloadByApi } from "@/plugins/download";
+
 export default {
   data() {
     return {
@@ -270,14 +273,24 @@ export default {
         });
       });
     },
-    exportFile() {
-      window.open(
-        QUESTION_API +
-          "/system/auth/device/info?$key=" +
-          this.user.key +
-          "&$token=" +
-          this.user.token
-      );
+    async exportFile() {
+      if (this.tempDownloading) return;
+      this.tempDownloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/system/auth/device/info`,
+          {
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.tempDownloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     submitUpload() {
       var fileList = this.$refs.upload.uploadFiles;

+ 20 - 12
src/modules/questions/views/PaperPendingTrial.vue

@@ -258,6 +258,7 @@
                       size="mini"
                       type="primary"
                       plain
+                      :loading="downloading"
                       @click="exportPaper(scope.row)"
                       >下载</el-button
                     >
@@ -305,6 +306,7 @@ import { QUESTION_API } from "@/constants/constants";
 import { LEVEL_TYPE } from "../constants/constants";
 import { mapState } from "vuex";
 import AuditPaper from "./AuditPaper.vue";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   components: { AuditPaper },
@@ -458,18 +460,24 @@ export default {
       }
       return false;
     },
-    exportPaper(row) {
-      var key = this.user.key;
-      var token = this.user.token;
-      window.open(
-        QUESTION_API +
-          "/originalPaper/export/" +
-          row.id +
-          "?$key=" +
-          key +
-          "&$token=" +
-          token
-      );
+    async exportPaper(row) {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(
+          `${QUESTION_API}/originalPaper/export/${row.id}`,
+          {
+            responseType: "blob",
+          }
+        );
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     submitPapers() {
       this.$confirm("确认提交试卷吗?", "提示", {

+ 16 - 12
src/modules/questions/views/SynthesisPaperStorage.vue

@@ -162,6 +162,7 @@
                 size="mini"
                 type="primary"
                 plain
+                :loading="downloading"
                 @click="toViewPaper(scope.row)"
                 >预览</el-button
               >
@@ -257,6 +258,7 @@ import {
   synthesizePaperPageListApi,
   synthesizePaperDeleteApi,
   synthesizePaperDownloadApi,
+  synthesizePaperPreviewApi,
 } from "../api";
 import { downloadByApi } from "@/plugins/download";
 import { QUESTION_API } from "@/constants/constants";
@@ -289,6 +291,7 @@ export default {
         exportContent: "",
         seqMode: "MODE3",
       },
+      downloading: false,
     };
   },
   computed: {
@@ -397,18 +400,19 @@ export default {
     selectChange(row) {
       this.selectedPaperIds = row.map((item) => item.id);
     },
-    toViewPaper(row) {
-      var key = this.user.key;
-      var token = this.user.token;
-      window.open(
-        QUESTION_API +
-          "/synthesize/paper/preview?synthesizePaperId=" +
-          row.id +
-          "&$key=" +
-          key +
-          "&$token=" +
-          token
-      );
+    async toViewPaper(row) {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return synthesizePaperPreviewApi(row.id);
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     toEditPaper(paper) {
       this.cacheSearchInfo();

+ 18 - 7
src/modules/questions/views/user.vue

@@ -520,6 +520,7 @@
               size="small"
               type="primary"
               icon="icon icon-export-white"
+              :loading="tempDownloading"
               @click="exportFile"
             >
               下载模板
@@ -549,6 +550,7 @@
 <script>
 import { QUESTION_API } from "@/constants/constants.js";
 import { mapState } from "vuex";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "User",
@@ -683,6 +685,7 @@ export default {
           },
         ],
       },
+      tempDownloading: false,
     };
   },
   computed: {
@@ -834,13 +837,21 @@ export default {
       this.$refs.upload.clearFiles();
     },
     //下载模板
-    exportFile() {
-      window.location.href =
-        QUESTION_API +
-        "/user/importTemplate?$key=" +
-        this.user.key +
-        "&$token=" +
-        this.user.token;
+    async exportFile() {
+      if (this.tempDownloading) return;
+      this.tempDownloading = true;
+
+      const res = await downloadByApi(() => {
+        return this.$httpWithMsg.get(`${QUESTION_API}/user/importTemplate`, {
+          responseType: "blob",
+        });
+      }).catch((e) => {
+        this.$message.error(e || "下载失败,请重新尝试!");
+      });
+      this.tempDownloading = false;
+
+      if (!res) return;
+      this.$message.success("下载成功!");
     },
     getCourses4Search(query) {
       this.courseLoading4Search = true;

+ 7 - 1
src/plugins/axios.js

@@ -7,7 +7,7 @@ import { initSyncTime, fetchTime } from "./syncServerTime";
 import { getAuthorization } from "./crypto";
 function setAuth(config) {
   let userSession = sessionStorage.getItem("user");
-  console.log("userSession", userSession);
+  // console.log("userSession", userSession);
   if (userSession && !config.noAuth) {
     let user = JSON.parse(userSession);
     const timestamp = fetchTime();
@@ -217,6 +217,8 @@ _$httpWith500Msg.interceptors.response.use(
         type: "error",
       });
       return Promise.reject(error);
+    } else {
+      initSyncTime(new Date(error.response.headers.date).getTime());
     }
 
     if (error.config.noToast) {
@@ -307,6 +309,8 @@ _$http.interceptors.response.use(
         type: "error",
       });
       return Promise.reject(error);
+    } else {
+      initSyncTime(new Date(error.response.headers.date).getTime());
     }
 
     if (error.config.noToast) {
@@ -418,6 +422,8 @@ _$httpWithoutBar.interceptors.response.use(
         type: "error",
       });
       return Promise.reject(error);
+    } else {
+      initSyncTime(new Date(error.response.headers.date).getTime());
     }
 
     if (error.config.noToast) {