Browse Source

减少客观分查询压力

Michael Wang 6 năm trước cách đây
mục cha
commit
e1367df1d8

+ 4 - 0
src/features/OnlineExam/OnlineExamList.vue

@@ -37,6 +37,8 @@
               </i-button>
               <i-poptip
                 :trigger="course.isObjScoreView ? 'hover' : 'click'"
+                @on-popper-show="cid = course.id"
+                @on-popper-hide="cid = null"
                 placement="left"
                 class="online-exam-list-override-poptip"
               >
@@ -49,6 +51,7 @@
                 </i-button>
                 <ecs-online-exam-result-list
                   slot="content"
+                  :popperShow="cid === course.id"
                   :examStudentId="course.examStudentId"
                 ></ecs-online-exam-result-list>
               </i-poptip>
@@ -82,6 +85,7 @@ export default {
       selectedCourse: null,
       spinShow: false,
       processingMessage: "",
+      cid: null,
     };
   },
   props: {

+ 22 - 17
src/features/OnlineExam/OnlineExamResultList.vue

@@ -31,6 +31,7 @@ export default {
   name: "EcsOnlineExamResultList",
   props: {
     examStudentId: Number,
+    popperShow: Boolean,
   },
   data() {
     return {
@@ -38,23 +39,27 @@ export default {
       results: [],
     };
   },
-  async mounted() {
-    try {
-      const results = (await this.$http.get(
-        "/api/ecs_oe_student/examScore/queryObjectiveScoreList?examStudentId=" +
-          this.examStudentId
-      )).data;
-      this.results = (results || [])
-        .sort((a, b) => b.examOrder - a.examOrder)
-        .slice(0, 10);
-      this.loading = false;
-    } catch (error) {
-      this.$Message.error({
-        content: "查询客观分列表出错!",
-        duration: 15,
-        closable: true,
-      });
-    }
+  watch: {
+    async popperShow() {
+      if (this.popperShow) {
+        try {
+          const results = (await this.$http.get(
+            "/api/ecs_oe_student/examScore/queryObjectiveScoreList?examStudentId=" +
+              this.examStudentId
+          )).data;
+          this.results = (results || [])
+            .sort((a, b) => b.examOrder - a.examOrder)
+            .slice(0, 10);
+          this.loading = false;
+        } catch (error) {
+          this.$Message.error({
+            content: "查询客观分列表出错!",
+            duration: 15,
+            closable: true,
+          });
+        }
+      }
+    },
   },
 };
 </script>