Эх сурвалжийг харах

feat: 成绩检查详情新增导出成绩

zhangjie 11 сар өмнө
parent
commit
25dcec53ed

+ 5 - 0
src/modules/mark/api.js

@@ -171,6 +171,11 @@ export const packageListPage = (datas) => {
 export const objectiveScoreCalculate = (datas) => {
   return $postParam("/api/admin/mark/student/objective/calculate", datas);
 };
+export const scoreDetailListExport = (datas) => {
+  return $postParam("/api/admin/mark/student/score/export", datas, {
+    responseType: "blob",
+  });
+};
 
 // score manage --------->
 export const scoreListPage = (datas) => {

+ 45 - 3
src/modules/mark/components/ScoreCheckDetail.vue

@@ -215,6 +215,14 @@
             <el-dropdown-item command="objective">客观题复核</el-dropdown-item>
           </el-dropdown-menu>
         </el-dropdown>
+        <el-button
+          class="ml-2"
+          type="success"
+          :loading="downloading"
+          :disabled="!canExport"
+          @click="toExportScore"
+          >成绩导出</el-button
+        >
       </div>
     </div>
 
@@ -372,9 +380,14 @@
 </template>
 
 <script>
-import { scoreDetailListPage, objectiveScoreCalculate } from "../api";
+import {
+  scoreDetailListPage,
+  objectiveScoreCalculate,
+  scoreDetailListExport,
+} from "../api";
 import SimpleImagePreview from "@/components/SimpleImagePreview";
 import markMinxin from "../markMinxin";
+import { downloadByApi } from "@/plugins/download";
 
 export default {
   name: "score-check-detail",
@@ -397,8 +410,8 @@ export default {
         className: "",
         teacher: "",
         filter: 0,
-        status: null,
-        breach: null,
+        status: "",
+        breach: "",
         startScore: undefined,
         endScore: undefined,
         objectiveStartScore: undefined,
@@ -412,18 +425,28 @@ export default {
         orderType: undefined,
         orderField: undefined,
       },
+      searchfilter: {},
       current: 1,
       size: this.GLOBAL.pageSize,
       total: 0,
       dataList: [],
       loading: false,
       multipleSelection: [],
+      downloading: false,
       // img view
       curImage: {},
       curImageIndex: 0,
       imageList: [],
     };
   },
+  computed: {
+    canExport() {
+      return (
+        JSON.stringify(this.filter) === JSON.stringify(this.searchfilter) &&
+        this.total > 0
+      );
+    },
+  },
   methods: {
     cancel() {
       this.modalIsShow = false;
@@ -450,6 +473,7 @@ export default {
       const data = await scoreDetailListPage(datas);
       this.dataList = data.records;
       this.total = data.total;
+      this.searchfilter = { ...this.filter };
     },
     toPage(page) {
       this.current = page;
@@ -529,6 +553,24 @@ export default {
       this.$message.success("操作成功!");
       this.getList();
     },
+    async toExportScore() {
+      if (this.downloading) return;
+      this.downloading = true;
+
+      const res = await downloadByApi(() => {
+        return scoreDetailListExport({
+          ...this.searchfilter,
+          examId: this.instance.examId,
+          paperNumber: this.instance.paperNumber,
+        });
+      }).catch((e) => {
+        this.$message.error(e || "导出失败,请重新尝试!");
+      });
+      this.downloading = false;
+
+      if (!res) return;
+      this.$message.success("导出成功!");
+    },
     // img view
     async toViewTrack(row) {
       this.toMarkTrack(row.studentId);