Jelajahi Sumber

评卷员前端优化

zhangjie 4 tahun lalu
induk
melakukan
ecec8804fd

+ 9 - 0
src/api.js

@@ -277,6 +277,9 @@ export const scoreStatData = (subjectId, questionId) => {
 export const markerLevelStatData = (userId, questionId) => {
   return $get(`/api/markers/${userId}/stat/levels`, { questionId });
 };
+export const markerLevelTotalStatData = (userId, questionId) => {
+  return $get(`/api/markers/${userId}/stat/totalLevels`, { questionId });
+};
 // area
 export const areaList = ({ workId, subject }) => {
   return $get("/api/questions", { workId, subject });
@@ -322,6 +325,9 @@ export const leaderGradingPaper = datas => {
 export const actionHistory = datas => {
   return $get("/api/marktasks/reviewPaper", datas);
 };
+export const actionLeaderHistory = datas => {
+  return $get("/api/marktasks/kzzReviewPaper", datas);
+};
 // sn search
 export const taskSnSearch = (type, code, questionId) => {
   if (type === "task") {
@@ -370,6 +376,9 @@ export const markTaskInfo = (subjectId, questionId) => {
 export const markerScoreStatData = (userId, questionId) => {
   return $get(`/api/markers/${userId}/stat/scores`, { questionId });
 };
+export const markerScoreTotalStatData = (userId, questionId) => {
+  return $get(`/api/markers/${userId}/stat/totalScores`, { questionId });
+};
 // mark-operation
 export const markerChangeLevelPaperList = datas => {
   // ?markerId=49&size=6&page=0&isShift=true&isShiftScore=false&questionId=10

+ 40 - 8
src/modules/grading/GradingOperation.vue

@@ -195,7 +195,7 @@
 <script>
 import {
   markerTaskList,
-  markerLevelStatData,
+  markerLevelTotalStatData,
   areaList,
   workLevelList,
   subjectDetail,
@@ -322,7 +322,7 @@ export default {
       this.selectPaper(this.curPaperIndex);
     },
     async getStepLevels() {
-      const data = await markerLevelStatData(
+      const data = await markerLevelTotalStatData(
         this.filter.markerId,
         this.filter.questionId
       );
@@ -368,6 +368,31 @@ export default {
         this.curStep = curStep;
       }
     },
+    updateStepLevel(curStep, curLevel, count) {
+      if (curStep.type === "done") {
+        const lpos = this.steps.levelStep.findIndex(
+          item => item.name === curStep.name
+        );
+        this.steps.levelStep[lpos].count -= count;
+      } else {
+        const opos = this.steps.otherStep.findIndex(
+          item => item.type === curStep.type
+        );
+        this.steps.otherStep[opos].count -= count;
+      }
+
+      const pos = this.steps.levelStep.findIndex(
+        item => item.name === curLevel
+      );
+      this.steps.levelStep[pos].count += count;
+
+      this.steps.levelStep.forEach(item => {
+        item.percent =
+          item.finalKdTotal && item.count
+            ? ((100 * item.count) / item.finalKdTotal).toFixed(3)
+            : 0;
+      });
+    },
     async getWorkLevels() {
       const data = await workLevelList(this.workId);
       this.levels = data.map(item => {
@@ -402,6 +427,7 @@ export default {
       this.current = 1;
       this.isFullscreenMarking = false;
       await this.getList();
+      this.getStepLevels();
       if (this.papers.length) {
         this.selectPaper(0);
       } else {
@@ -411,6 +437,7 @@ export default {
     areaChange() {
       this.getStepLevels();
       this.toPage(1);
+      this.updateHistory();
     },
     // selectMultiplePaper
     selectMultiplePaper(paper) {
@@ -425,7 +452,7 @@ export default {
       const multipleGradingListCount = this.multipleGradingList.length;
 
       let result = true;
-      await paperSelectLevelBatch(
+      const papers = await paperSelectLevelBatch(
         this.multipleGradingList.map(item => item.id).join(), // is taskId
         level.name,
         "LEVEL"
@@ -437,8 +464,9 @@ export default {
       if (!result) return;
 
       this.multipleGradingList = [];
-      this.getStepLevels();
-      this.updateHistory();
+      // this.getStepLevels();
+      this.updateStepLevel(this.curStep, level.name, multipleGradingListCount);
+      this.updateCacheHistory(papers);
 
       // update paper list
       if (
@@ -514,13 +542,14 @@ export default {
       this.selectPaper(this.curPaperIndex);
     },
     async gradeCurPaper(level) {
-      await paperSelectLevelOrScore(
+      const paper = await paperSelectLevelOrScore(
         this.curPaper.id, // is taskId
         level.name,
         "LEVEL"
       );
-      this.getStepLevels();
-      this.updateHistory();
+      // this.getStepLevels();
+      this.updateStepLevel(this.curStep, level.name, 1);
+      this.updateCacheHistory([paper]);
       this.toActionNextPaper();
     },
     async passCurPaper() {
@@ -530,6 +559,9 @@ export default {
     updateHistory() {
       this.$refs.GradeHistoryPaper.updatePapers();
     },
+    updateCacheHistory(papers) {
+      this.$refs.GradeHistoryPaper.updateCachePapers(papers);
+    },
     // paper carousel
     toViewCarouselPaper(paperIndex, papers, type) {
       this.carouselType = type;

+ 54 - 8
src/modules/grading/components/GradeHistoryPaper.vue

@@ -13,9 +13,18 @@
 </template>
 
 <script>
-import { actionHistory } from "@/api";
+import { actionHistory, actionLeaderHistory } from "@/api";
 import PaperCarousel from "@/components/PaperCarousel";
 
+// 后台规则:
+// - 按操作时间倒叙排雷
+// - 管理员没有历史
+// - 科组长所有操作都不记录历史。(修改:科组长需要记录一键定档操作)
+// - 评卷员确认改档不记录历史,待评、回评、改档打分记录历史
+// 前端规则:
+// - 按操作时间新增记录。
+// - 已保存记录中存在相同试卷的,则将当前记录调到最前。
+
 export default {
   name: "grade-history-paper",
   components: { PaperCarousel },
@@ -30,13 +39,18 @@ export default {
   },
   data() {
     return {
+      workId: "",
+      subject: "",
+      subjectId: this.$route.params.subjectId,
       userId: "",
       curPaper: {},
-      papers: []
+      papers: [],
+      IS_MARK_LEADER: false
     };
   },
   computed: {
     title() {
+      if (this.IS_MARK_LEADER) return `一键定档  ${this.curPaper.level}`;
       return this.curPaper.result ? `已评  ${this.curPaper.result}` : "";
       // return this.curPaper.sn ? `NO.${this.curPaper.sn}` : "";
     }
@@ -49,23 +63,55 @@ export default {
   },
   mounted() {
     this.userId = this.$ls.get("user", { id: "" }).id;
+    const curUserRoleType = this.$ls.get("user", { role: "" }).role;
+    this.IS_MARK_LEADER = curUserRoleType === "MARK_LEADER";
+    const subjectId = this.subjectId.split("-");
+    this.workId = subjectId[0];
+    this.subject = subjectId[1];
     this.updatePapers();
   },
   methods: {
     async updatePapers() {
-      const datas = {
-        markerId: this.userId,
-        stage: this.stage,
-        questionId: this.questionId
-      };
+      let data = [];
+      if (this.IS_MARK_LEADER) {
+        const datas = {
+          workId: this.workId,
+          subject: this.subject,
+          questionId: this.questionId
+        };
+
+        data = await actionLeaderHistory(datas);
+      } else {
+        const datas = {
+          markerId: this.userId,
+          stage: this.stage,
+          questionId: this.questionId
+        };
 
-      const data = await actionHistory(datas);
+        data = await actionHistory(datas);
+      }
       this.papers = data.reverse();
       this.$nextTick(() => {
         const index = this.papers.length ? this.papers.length - 1 : 0;
         this.$refs.PaperCarousel.setCurPaper(index);
       });
     },
+    updateCachePapers(papers) {
+      papers.forEach(paper => {
+        const paperIndex = this.papers.findIndex(
+          item => item.paperId === paper.paperId
+        );
+        if (paperIndex !== -1) {
+          this.papers.splice(paperIndex, 1);
+        }
+      });
+      this.papers = [...this.papers, ...papers].slice(-5);
+
+      this.$nextTick(() => {
+        const index = this.papers.length ? this.papers.length - 1 : 0;
+        this.$refs.PaperCarousel.setCurPaper(index);
+      });
+    },
     setCurPaper(paper) {
       this.curPaper = paper;
     },

+ 1 - 1
src/modules/mark/MarkDetail.vue

@@ -450,7 +450,7 @@ export default {
           });
           this.$Message.success("申请改档成功!");
           this.getStepLevels();
-          this.updateHistory();
+          // this.updateHistory();
           this.toActionNextPaper();
         }
       });

+ 32 - 7
src/modules/mark/MarkOperation.vue

@@ -143,7 +143,7 @@ import {
   getParamsSet,
   markerTaskList,
   markerChangeLevelPaperList,
-  markerScoreStatData,
+  markerScoreTotalStatData,
   areaList,
   workLevelList,
   subjectDetail,
@@ -278,7 +278,7 @@ export default {
       this.selectPaper(this.curPaperIndex);
     },
     async getStepLevels() {
-      const data = await markerScoreStatData(
+      const data = await markerScoreTotalStatData(
         this.filter.markerId,
         this.filter.questionId
       );
@@ -330,6 +330,26 @@ export default {
         this.curStep = curStep;
       }
     },
+    updateStepLevel(curStep, curLevel, count = 1) {
+      if (curStep.type === "done") return;
+
+      const opos = this.steps.otherStep.findIndex(
+        item => item.type === curStep.type
+      );
+      this.steps.otherStep[opos].count -= count;
+
+      if (curStep.type === "shift") {
+        const spos = this.steps.otherStep.findIndex(
+          item => item.type === "shiftScore"
+        );
+        this.steps.otherStep[spos].count += count;
+      } else {
+        const pos = this.steps.levelStep.findIndex(
+          item => item.name === curLevel
+        );
+        this.steps.levelStep[pos].count += count;
+      }
+    },
     async getWorkLevels() {
       const data = await workLevelList(this.workId);
       this.levels = data.map(item => {
@@ -361,6 +381,7 @@ export default {
       this.curStep = step;
       this.current = 1;
       await this.getList();
+      this.getStepLevels();
       if (this.papers.length) {
         this.selectPaper(0);
       } else {
@@ -370,6 +391,7 @@ export default {
     areaChange() {
       this.getStepLevels();
       this.toPage(1);
+      this.updateHistory();
     },
     toReview(index) {
       this.isFullscreenMarking = true;
@@ -443,23 +465,23 @@ export default {
       this.selectPaper(this.curPaperIndex);
     },
     async gradingCurPaper({ selectedLevel }) {
+      // 确认改档
       await paperSelectLevelOrScore(
         this.curPaper.id, // is taskId
         selectedLevel,
         "LEVEL"
       );
-      this.getStepLevels();
-      this.updateHistory();
+      this.updateStepLevel(this.curStep, "shiftScore");
       this.toActionNextPaper();
     },
     async scoreCurPaper(score) {
-      await paperSelectLevelOrScore(
+      const paper = await paperSelectLevelOrScore(
         this.curPaper.id, // is taskId
         score,
         "SCORE"
       );
-      this.getStepLevels();
-      this.updateHistory();
+      this.updateStepLevel(this.curStep, this.curPaper.level);
+      this.updateCacheHistory([paper]);
       this.toActionNextPaper();
     },
     async passCurPaper(level) {
@@ -469,6 +491,9 @@ export default {
     updateHistory() {
       this.$refs.GradeHistoryPaper.updatePapers();
     },
+    updateCacheHistory(papers) {
+      this.$refs.GradeHistoryPaper.updateCachePapers(papers);
+    },
     // paper carousel
     toViewCarouselPaper(paperIndex, papers) {
       this.isFullscreenMarking = true;