Explorar el Código

feat: 参数设置步骤校调整

zhangjie hace 3 meses
padre
commit
9eb4a4594f

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

@@ -22,6 +22,9 @@ export const markSettingBatchSave = (datas) => {
   return $post("/api/admin/mark/setting/paper/batch_save", datas);
 };
 // mark-params --------->
+export const markParamStepStatus = (datas) => {
+  return $postParam("/api/admin/mark/question/subjective/step/status", datas);
+};
 // structure
 export const markStructureList = (datas) => {
   return $postParam("/api/admin/mark/question/list", datas);

+ 13 - 4
src/modules/mark/components/markParam/MarkParamClass.vue

@@ -140,6 +140,7 @@ export default {
     ...mapMutations("markParam", ["setOpenClassMark"]),
     async initData() {
       this.classMarkIsOpen = this.openClassMark;
+      if (!this.classMarkIsOpen) return;
 
       const params = {
         examId: this.basicInfo.examId,
@@ -150,7 +151,7 @@ export default {
       this.classList = res.classNames || [];
 
       this.updateUnsignData();
-      this.updateCacheDataMd5();
+      this.cacheDataMd5 = this.getSubmitDataMd5();
     },
     resetData() {
       this.dataList = [];
@@ -159,7 +160,7 @@ export default {
       this.unsignData = [];
       this.cacheDataMd5 = "";
     },
-    updateCacheDataMd5() {
+    getSubmitDataMd5() {
       this.cacheDataMd5 = MD5(JSON.stringify(this.dataList));
     },
     async markClassChange() {
@@ -254,13 +255,13 @@ export default {
       }).catch(() => {});
       if (!res) return;
       this.$message.success("保存成功!");
-      this.updateCacheDataMd5();
+      this.cacheDataMd5 = this.getSubmitDataMd5();
       return true;
     },
     async toPrev(step = 1) {
       if (
         !this.classMarkIsOpen ||
-        this.cacheDataMd5 === MD5(JSON.stringify(this.dataList))
+        this.cacheDataMd5 === this.getSubmitDataMd5()
       ) {
         this.$emit("prev", step);
         return;
@@ -283,6 +284,14 @@ export default {
       this.$emit("prev", step);
     },
     async toNext(step = 1) {
+      if (
+        !this.classMarkIsOpen ||
+        this.cacheDataMd5 === this.getSubmitDataMd5()
+      ) {
+        this.$emit("next", step);
+        return;
+      }
+
       const res = await this.submit();
       if (!res) return;
       this.$emit("next", step);

+ 5 - 5
src/modules/mark/components/markParam/MarkParamObjectiveAnswer.vue

@@ -296,10 +296,10 @@ export default {
       this.prevPaperType = this.curPaperType;
       this.tableData = this.tableDict[this.curPaperType];
 
-      this.updateCacheDataMd5();
+      this.cacheDataMd5 = this.getSubmitDataMd5();
     },
-    updateCacheDataMd5() {
-      this.cacheDataMd5 = MD5(JSON.stringify(this.tableDict));
+    getSubmitDataMd5() {
+      return MD5(JSON.stringify(this.tableDict));
     },
     paperTypeChange() {
       if (!this.checkData()) {
@@ -436,7 +436,7 @@ export default {
       this.loading = false;
       if (!data) return;
 
-      this.updateCacheDataMd5();
+      this.cacheDataMd5 = this.getSubmitDataMd5();
       this.$message.success(
         "保存成功,请到成绩检查菜单点击客观题统分按钮进行统分!"
       );
@@ -466,7 +466,7 @@ export default {
     },
     // step change
     async toPrev(step = 1) {
-      if (MD5(JSON.stringify(this.tableDict)) === this.cacheDataMd5) {
+      if (this.cacheDataMd5 === this.getSubmitDataMd5()) {
         this.$emit("prev", step);
         return;
       }

+ 11 - 2
src/modules/mark/components/markParam/MarkParamStructure.vue

@@ -273,6 +273,7 @@ import { QUESTION_TYPE_LIST } from "@/constants/enumerate";
 import { mapState, mapMutations } from "vuex";
 import { markStructureSave } from "../../api";
 import { omit } from "lodash";
+import { MD5 } from "@/plugins/md5";
 
 export default {
   name: "mark-paper-structure",
@@ -280,6 +281,7 @@ export default {
     return {
       tableData: [],
       curRow: {},
+      cacheDataMd5: "",
       QUESTION_TYPE_LIST,
       questionTypeDict: {},
       scoresPerTopic: {},
@@ -382,6 +384,10 @@ export default {
       if (!this.tableData.length && this.structureEditable) {
         this.createMain();
       }
+      this.cacheDataMd5 = this.getSubmitDataMd5();
+    },
+    getSubmitDataMd5() {
+      return MD5(JSON.stringify(this.getData()));
     },
     getNewRow(val) {
       return this.$objAssign(
@@ -672,8 +678,11 @@ export default {
       return true;
     },
     async toNext(step = 1) {
-      const res = await this.submit();
-      if (!res) return;
+      // 如果试卷结构有变动,先保存
+      if (this.cacheDataMd5 !== this.getSubmitDataMd5()) {
+        const res = await this.submit();
+        if (!res) return;
+      }
       this.$emit("next", step);
     },
   },

+ 22 - 10
src/modules/mark/components/markParam/ModifyMarkParams.vue

@@ -62,7 +62,11 @@ import MarkParamStructure from "./MarkParamStructure.vue";
 import MarkParamGroup from "./MarkParamGroup.vue";
 import MarkParamClass from "./MarkParamClass.vue";
 import MarkParamObjectiveAnswer from "./MarkParamObjectiveAnswer.vue";
-import { markStructureList, markSubjectiveList } from "../../api";
+import {
+  markStructureList,
+  markSubjectiveList,
+  markParamStepStatus,
+} from "../../api";
 
 const steps = [
   {
@@ -151,6 +155,22 @@ export default {
         examId: this.instance.examId,
         paperNumber: this.instance.paperNumber,
       };
+      // check step status
+      const stepRes = await markParamStepStatus(params);
+      const stepMap = {
+        subjectiveStruct: 0,
+        subjectiveMarker: 1,
+        subjectiveMarkerClass: 2,
+        objectiveAnswer: 3,
+      };
+      const finishedSteps = Object.keys(stepMap)
+        .filter((key) => stepRes[key])
+        .map((key) => stepMap[key]);
+      this.curStepIndex = Math.max(...finishedSteps);
+      if (this.curStepIndex !== this.lastStep) {
+        this.curStepIndex++;
+      }
+      this.initSteps();
 
       // structure
       const structRes = await markStructureList(params);
@@ -169,22 +189,14 @@ export default {
       this.setPaperStructureInfo(questions || []);
       this.setStructureCanEdit(structRes.canCreate);
       this.questionSubmit = structRes.questionSubmit;
-      if (questions && questions.length) {
-        // TODO:这里的判断需要调整
-        this.curStepIndex = 1;
-      }
+
       // group
       const subjectRes = await markSubjectiveList(params);
       this.setSubjectiveTaskList(subjectRes.questions || []);
       this.setOpenMergeMarker(!!subjectRes.mergeMarker);
       this.setOpenDoubleMark(!!subjectRes.doubleMark);
       this.setOpenClassMark(!!subjectRes.classMark);
-      if (subjectRes.questionsList && subjectRes.questionsList.length) {
-        // TODO:这里的判断需要调整
-        this.curStepIndex = 2;
-      }
 
-      this.initSteps();
       this.dataReady = true;
     },
     initSteps() {