zhangjie преди 3 години
родител
ревизия
1df91e0d82
променени са 2 файла, в които са добавени 59 реда и са изтрити 6 реда
  1. 1 2
      src/api.js
  2. 58 4
      src/modules/main/StudentScore.vue

+ 1 - 2
src/api.js

@@ -80,8 +80,7 @@ export const clientUserPageList = datas => {
   return $get("/api/admin/users/collect", datas);
 };
 export const clientUserQuery = workId => {
-  // TODO:
-  return $get("/api/admin/users/collect", { workId });
+  return $get("/api/admin/users/collect/all", { workId });
 };
 export const updateClientUser = datas => {
   if (datas.id) {

+ 58 - 4
src/modules/main/StudentScore.vue

@@ -98,7 +98,7 @@
         <image-action-list
           :data="curStudent.scores"
           :column-number="curStudent.scores.length"
-          loop
+          @on-review="toReview"
           ref="ImageActionList"
         ></image-action-list>
 
@@ -135,6 +135,14 @@
         @on-change="toPage"
       ></Page>
     </div>
+
+    <!-- image-preview -->
+    <simple-image-preview
+      :cur-image="curPaper"
+      @on-prev="toPrevPaper"
+      @on-next="toNextPaper"
+      ref="SimpleImagePreview"
+    ></simple-image-preview>
   </div>
 </template>
 
@@ -142,10 +150,11 @@
 import { studentScoreList, workList, subjectList, areaList } from "@/api";
 import { CODE_TYPE } from "@/constants/enumerate";
 import ImageActionList from "./components/ImageActionList";
+import SimpleImagePreview from "@/components/SimpleImagePreview";
 
 export default {
   name: "student-score",
-  components: { ImageActionList },
+  components: { ImageActionList, SimpleImagePreview },
   data() {
     return {
       filter: {
@@ -165,7 +174,11 @@ export default {
       total: 0,
       size: 1,
       curStudent: { name: "" },
-      students: []
+      students: [],
+      // image preview
+      papers: [],
+      curPaper: {},
+      curPaperIndex: 0
     };
   },
   mounted() {
@@ -217,6 +230,8 @@ export default {
       }
       data.map(student => {
         student.scores.map(score => {
+          // score.imgSrc = score.sheetSrc;
+          // score.thumbSrc = score.sheetSrc;
           score.title = score.subjectName;
           score.key = this.$randomCode();
         });
@@ -226,8 +241,10 @@ export default {
       this.toPage(1);
     },
     toPage(page) {
+      if (!this.students[page - 1]) return;
       this.current = page;
-      this.curStudent = this.students[page - 1] || {};
+      this.curStudent = this.students[page - 1];
+      this.papers = this.curStudent.scores;
     },
     workChange() {
       this.filter.subject = null;
@@ -241,6 +258,43 @@ export default {
         this.filter.questionId = null;
         this.getAreaList();
       }
+    },
+    // paper view
+    toReview(index) {
+      this.selectPaper(index);
+      this.$refs.SimpleImagePreview.open();
+    },
+    selectPaper(index) {
+      let nindex = index;
+      if (!this.papers.length) {
+        nindex = 0;
+      } else if (index > this.papers.length - 1) {
+        nindex = this.papers.length - 1;
+      } else if (index < 0) {
+        nindex = 0;
+      }
+      this.curPaperIndex = nindex;
+      this.curPaper = this.papers[nindex] ? { ...this.papers[nindex] } : {};
+    },
+    async toPrevPaper() {
+      if (this.curPaperIndex === 0) {
+        this.$Message.warning("当前已经是第一条数据了");
+        return;
+      } else {
+        this.curPaperIndex--;
+      }
+
+      this.selectPaper(this.curPaperIndex);
+    },
+    async toNextPaper() {
+      if (this.curPaperIndex === this.papers.length - 1) {
+        this.$Message.warning("当前已经是最后一条数据了");
+        return;
+      } else {
+        this.curPaperIndex++;
+      }
+
+      this.selectPaper(this.curPaperIndex);
     }
   }
 };