浏览代码

上一页下一页

zhangjie 1 年之前
父节点
当前提交
eb483c5544

+ 15 - 12
src/features/invigilation/InvigilationDetail/InvigilationDetail.vue

@@ -328,8 +328,11 @@ export default {
     this.initData();
   },
   methods: {
-    ...mapActions("invigilation", ["updateDetailIds", "updateSelectedExamId"]),
-    ...mapMutations("invigilation", ["setDetailIds", "setSelectedExamId"]),
+    ...mapActions("invigilation", [
+      "updateDetailInfos",
+      "updateSelectedExamId",
+    ]),
+    ...mapMutations("invigilation", ["setSelectedExamId"]),
     async initData() {
       this.dataReady = false;
       try {
@@ -376,16 +379,6 @@ export default {
       this.setSelectedExamId(this.filter.examId);
       this.current = 1;
       await this.getList();
-
-      // if (this.total > this.size) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: invigilationHistoryList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
     async toExport() {
       this.isDownload = true;
@@ -451,6 +444,16 @@ export default {
       }
     },
     toDetail(row) {
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: invigilationHistoryList,
+      });
       const router = this.IS_INVIGILATE
         ? "WarningDetail"
         : "InvigilationWarningDetail";

+ 12 - 13
src/features/invigilation/OnlinePatrol/OnlinePatrol.vue

@@ -263,7 +263,7 @@ import EchartRender from "../common/EchartRender";
 import SummaryLine from "../common/SummaryLine";
 import RightOrWrong from "../common/RightOrWrong";
 import ExportSetDialog from "./ExportSetDialog.vue";
-import { mapState, mapMutations, mapActions } from "vuex";
+import { mapState, mapActions } from "vuex";
 import { downloadBlob } from "@/utils/utils";
 
 export default {
@@ -320,8 +320,7 @@ export default {
     this.initData();
   },
   methods: {
-    ...mapActions("invigilation", ["updateDetailIds"]),
-    ...mapMutations("invigilation", ["setDetailIds"]),
+    ...mapActions("invigilation", ["updateDetailInfos"]),
     async initData() {
       await this.getExamBatchList();
       this.filter.examId = this.examBatchs[0] ? this.examBatchs[0].id : "";
@@ -352,16 +351,6 @@ export default {
       await this.getList();
 
       this.getPatrolReportList();
-
-      // if (this.total > this.size) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: patrolList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
     async getExamBatchList() {
       const res = await examBatchList({});
@@ -381,6 +370,16 @@ export default {
       this.getExamActivityRoomList();
     },
     toDetail(row) {
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: patrolList,
+      });
       this.$router.push({
         name: "PatrolWarningDetail",
         params: { examRecordId: row.examRecordId },

+ 12 - 13
src/features/invigilation/OnlinePatrol/PatrolExamDetail.vue

@@ -270,7 +270,7 @@ import {
   CLIENT_WEBSOCKET_STATUS,
   MONITOR_STATUS_SOURCE,
 } from "@/constant/constants";
-import { mapState, mapMutations, mapActions } from "vuex";
+import { mapState, mapActions } from "vuex";
 
 export default {
   name: "patrol-exam-detail",
@@ -330,8 +330,7 @@ export default {
     this.initData();
   },
   methods: {
-    ...mapActions("invigilation", ["updateDetailIds"]),
-    ...mapMutations("invigilation", ["setDetailIds"]),
+    ...mapActions("invigilation", ["updateDetailInfos"]),
     async initData() {
       await this.getExamDetail();
       if (this.curExamBatch.monitorVideoSource) {
@@ -441,18 +440,18 @@ export default {
     async toSearch() {
       this.current = 1;
       await this.getList();
-
-      // if (this.total > this.size) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: invigilateVideoList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
     toDetail(row) {
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: invigilateVideoList,
+      });
       this.$router.push({
         name: "PatrolWarningDetail",
         params: { examRecordId: row.examRecordId },

+ 31 - 9
src/features/invigilation/OnlinePatrol/PatrolWarningDetail.vue

@@ -232,7 +232,7 @@ import {
   objTypeOf,
   snakeToHump,
 } from "@/utils/utils";
-import { mapState } from "vuex";
+import { mapState, mapActions } from "vuex";
 
 export default {
   name: "patrol-warning-detail",
@@ -251,7 +251,11 @@ export default {
     };
   },
   computed: {
-    ...mapState("invigilation", ["detailIds", "liveDomains"]),
+    ...mapState("invigilation", [
+      "detailIds",
+      "detailFilterData",
+      "liveDomains",
+    ]),
     isBreach() {
       return (
         !this.detailInfo.breachStatus && this.detailInfo.breachStatus !== null
@@ -269,6 +273,7 @@ export default {
     this.initData();
   },
   methods: {
+    ...mapActions("invigilation", ["fetchDetailIds", "resetDetailInfos"]),
     async initData() {
       this.examRecordId = this.$route.params.examRecordId;
       await this.getInvigilateDetail().catch(() => {});
@@ -445,20 +450,34 @@ export default {
       });
       return logs;
     },
-    changeStudent(type) {
+    async changeStudent(type) {
       let index = this.detailIds.indexOf(this.examRecordId);
+      const { pageNumber, pages } = this.detailFilterData;
+
       if (type) {
         if (index >= this.detailIds.length - 1) {
-          this.$message.error("当前没有下一个学生了");
-          return;
+          if (pageNumber >= pages) {
+            this.$message.error("当前没有下一个学生了");
+            return;
+          } else {
+            await this.fetchDetailIds(1);
+            index = 0;
+          }
+        } else {
+          index++;
         }
-        index++;
       } else {
         if (index <= 0) {
-          this.$message.error("当前没有上一个学生了");
-          return;
+          if (pageNumber <= 1) {
+            this.$message.error("当前没有上一个学生了");
+            return;
+          } else {
+            await this.fetchDetailIds(-1);
+            index = this.detailIds.length - 1;
+          }
+        } else {
+          index--;
         }
-        index--;
       }
 
       if (this.holding) return;
@@ -497,5 +516,8 @@ export default {
       window.history.go(-1);
     },
   },
+  beforeDestroy() {
+    this.resetDetailInfos();
+  },
 };
 </script>

+ 13 - 15
src/features/invigilation/RealtimeMonitoring/RealtimeMonitoring.vue

@@ -452,11 +452,8 @@ export default {
     },
   },
   methods: {
-    ...mapActions("invigilation", ["updateDetailIds"]),
-    ...mapMutations("invigilation", [
-      "setDetailIds",
-      "setWarningMessageTimeCaches",
-    ]),
+    ...mapActions("invigilation", ["updateDetailInfos"]),
+    ...mapMutations("invigilation", ["setWarningMessageTimeCaches"]),
     clearLoopSetTs() {
       if (!this.loopSetTs.length) return;
       this.loopSetTs.forEach((sett) => {
@@ -604,16 +601,6 @@ export default {
     async toSearch() {
       this.current = 1;
       await this.getList();
-
-      // if (this.total > this.size) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: invigilateVideoList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
     async getMonitorCallCount() {
       if (!this.filter.examId) return;
@@ -750,6 +737,17 @@ export default {
       });
     },
     toDetail(row) {
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: invigilateVideoList,
+      });
+
       this.$router.push({
         name: "WarningDetail",
         params: { examRecordId: row.examRecordId },

+ 13 - 13
src/features/invigilation/RealtimeMonitoring/RealtimeMonitoringFull.vue

@@ -88,7 +88,7 @@ import {
   communicationOver,
 } from "@/api/invigilation";
 
-import { mapState, mapMutations, mapActions } from "vuex";
+import { mapState, mapActions } from "vuex";
 import RealtimeMonitoringFullHeader from "./components/RealtimeMonitoringFullHeader";
 import EarlyWarningList from "./components/EarlyWarningList";
 import RequestCallList from "./components/RequestCallList";
@@ -189,8 +189,7 @@ export default {
     },
   },
   methods: {
-    ...mapActions("invigilation", ["updateDetailIds"]),
-    ...mapMutations("invigilation", ["setDetailIds"]),
+    ...mapActions("invigilation", ["updateDetailInfos"]),
     /** esc 返回 */
     onBack() {
       document.exitFullscreen?.();
@@ -225,16 +224,6 @@ export default {
         item.progress = item.progress ? Math.round(item.progress * 100) : 0;
         return item;
       });
-      this.total = res.data.data.total;
-      // if (this.total > this.filter.pageSize) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: invigilateVideoList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
 
     onOperation({ type, data }) {
@@ -275,6 +264,17 @@ export default {
       const stdKey = `${item.examRecordId}_${item.title}`;
       this.warningMessageListTimeCaches[stdKey] = Date.now();
 
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: invigilateVideoList,
+      });
+
       this.$router
         .push({
           name: "WarningDetail",

+ 29 - 9
src/features/invigilation/RealtimeMonitoring/WarningDetail.vue

@@ -385,7 +385,7 @@ import {
   dateFormatForAPI,
 } from "@/utils/utils";
 import MoveEle from "@/plugins/move-ele";
-import { mapState } from "vuex";
+import { mapState, mapActions } from "vuex";
 
 const domEmpty = (dom) => {
   dom.childNodes.forEach((childNode) => {
@@ -429,7 +429,11 @@ export default {
     };
   },
   computed: {
-    ...mapState("invigilation", ["detailIds", "liveDomains"]),
+    ...mapState("invigilation", [
+      "detailIds",
+      "detailFilterData",
+      "liveDomains",
+    ]),
     isBreach() {
       return (
         !this.detailInfo.breachStatus && this.detailInfo.breachStatus !== null
@@ -455,6 +459,7 @@ export default {
     this.initData();
   },
   methods: {
+    ...mapActions("invigilation", ["fetchDetailIds", "resetDetailInfos"]),
     async initData() {
       this.examRecordId = this.$route.params.examRecordId;
       await this.getInvigilateDetail().catch(() => {});
@@ -681,20 +686,34 @@ export default {
       });
       return logs;
     },
-    changeStudent(type) {
+    async changeStudent(type) {
       let index = this.detailIds.indexOf(this.examRecordId);
+      const { pageNumber, pages } = this.detailFilterData;
+
       if (type) {
         if (index >= this.detailIds.length - 1) {
-          this.$message.error("当前没有下一个学生了");
-          return;
+          if (pageNumber >= pages) {
+            this.$message.error("当前没有下一个学生了");
+            return;
+          } else {
+            await this.fetchDetailIds(1);
+            index = 0;
+          }
+        } else {
+          index++;
         }
-        index++;
       } else {
         if (index <= 0) {
-          this.$message.error("当前没有上一个学生了");
-          return;
+          if (pageNumber <= 1) {
+            this.$message.error("当前没有上一个学生了");
+            return;
+          } else {
+            await this.fetchDetailIds(-1);
+            index = this.detailIds.length - 1;
+          }
+        } else {
+          index--;
         }
-        index--;
       }
 
       if (this.holding) return;
@@ -998,6 +1017,7 @@ export default {
   },
   beforeDestroy() {
     window.sessionStorage.removeItem("autoAnswerInfo");
+    this.resetDetailInfos();
     this.loopRunning = false;
     this.clearLoopSetTs();
     this.clearSubscribeSetTs();

+ 13 - 11
src/features/invigilation/WarningManage/WarningManage.vue

@@ -295,11 +295,11 @@ export default {
   },
   methods: {
     ...mapActions("invigilation", [
-      "updateDetailIds",
+      "updateDetailInfos",
       "updateSelectedExamId",
       "fetchWarningManageCount",
     ]),
-    ...mapMutations("invigilation", ["setDetailIds", "setSelectedExamId"]),
+    ...mapMutations("invigilation", ["setSelectedExamId"]),
     async initData() {
       this.dataReady = false;
       try {
@@ -342,15 +342,6 @@ export default {
       this.setSelectedExamId(this.filter.examId);
       this.current = 1;
       await this.getList();
-      // if (this.total > this.size) {
-      //   this.updateDetailIds({
-      //     filterData: this.filter,
-      //     fetchFunc: invigilationWarningList,
-      //   });
-      // } else {
-      const ids = this.dataList.map((item) => item.examRecordId);
-      this.setDetailIds([...new Set(ids)]);
-      // }
     },
     async getExamBatchList() {
       const userId = this.IS_INVIGILATE ? this.user.id : null;
@@ -410,6 +401,17 @@ export default {
       this.fetchWarningManageCount(datas);
     },
     toDetail(row) {
+      this.updateDetailInfos({
+        filterData: {
+          ...this.filter,
+          pageNumber: this.current,
+          pageSize: this.size,
+          pages: Math.ceil(this.total / this.size),
+        },
+        detailIds: this.dataList.map((item) => item.examRecordId),
+        fetchFunc: invigilationWarningList,
+      });
+
       const router = this.IS_INVIGILATE
         ? "WarningDetail"
         : "InvigilationWarningDetail";

+ 35 - 6
src/store/modules/invigilation.js

@@ -21,6 +21,8 @@ const state = {
     },
   },
   detailIds: [],
+  detailFilterData: {},
+  detailFilterFunc: null,
   liveDomains: [],
   selectedExamId: null,
   warningMessageTimeCaches: {},
@@ -40,6 +42,12 @@ const mutations = {
   setDetailIds(state, detailIds) {
     state.detailIds = detailIds;
   },
+  setDetailFilterData(state, detailFilterData) {
+    state.detailFilterData = detailFilterData;
+  },
+  setDetailFilterFunc(state, detailFilterFunc) {
+    state.detailFilterFunc = detailFilterFunc;
+  },
   setLiveDomains(state, liveDomains) {
     state.liveDomains = liveDomains;
   },
@@ -67,15 +75,36 @@ const actions = {
     const res = await reexamPendingCount(datas);
     commit("setReexamPending", res.data.data.count);
   },
-  async updateDetailIds({ commit }, { filterData, fetchFunc }) {
-    const res = await fetchFunc({
-      ...filterData,
-      pageNumber: 1,
-      pageSize: 1000,
-    });
+  // 上一页,下一页 ------->
+  resetDetailInfos({ state }) {
+    state.detailIds = [];
+    state.detailFilterData = {};
+    state.detailFilterFunc = null;
+  },
+  async updateDetailInfos({ commit }, { filterData, fetchFunc, detailIds }) {
+    commit("setDetailIds", [...new Set(detailIds)]);
+    commit("setDetailFilterData", filterData);
+    commit("setDetailFilterFunc", fetchFunc);
+  },
+  async fetchDetailIds({ state, commit }, pno) {
+    const datas = { ...state.detailFilterData };
+    datas.pageNumber += pno;
+    if (datas.pageNumber === 0) return;
+    if (datas.pageNumber > state.detailFilterData.pages) return;
+    if (!state.detailFilterFunc) return;
+
+    const res = await state.detailFilterFunc(datas);
     const ids = res.data.data.records.map((item) => item.examRecordId);
     commit("setDetailIds", [...new Set(ids)]);
+    commit(
+      "setDetailFilterData",
+      Object.assign({}, state.detailFilterData, {
+        pages: res.data.data.pages,
+        pageNumber: res.data.data.current,
+      })
+    );
   },
+  // 上一页,下一页 ------->
   async fetchLiveDomains({ commit }) {
     const res = await getLiveDomains();
     commit("setLiveDomains", res.data.data || []);