Răsfoiți Sursa

feat: 步骤调整

zhangjie 3 luni în urmă
părinte
comite
d424eeca6b

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

@@ -233,13 +233,20 @@ export default {
         })
         .filter((item) => item.unsignGroups.length);
     },
-    async submit() {
+    checkData() {
+      if (!this.classMarkIsOpen) return true;
+
       if (this.unsignData.length) {
         this.$message.error("存在未分配班级,请完成分配!");
-        return;
+        return false;
       }
-      if (this.loading) return;
+      return true;
+    },
+    async submit() {
+      if (!this.checkData()) return;
 
+      if (this.loading) return;
+      this.loading = true;
       const unvalid = this.dataList.some(
         (item) => !item.markerClassList.length
       );
@@ -253,6 +260,7 @@ export default {
         paperNumber: this.basicInfo.paperNumber,
         questionMarkerClass: this.dataList,
       }).catch(() => {});
+      this.loading = false;
       if (!res) return;
       this.$message.success("保存成功!");
       this.cacheDataMd5 = this.getSubmitDataMd5();
@@ -284,6 +292,8 @@ export default {
       this.$emit("prev", step);
     },
     async toNext(step = 1) {
+      if (!this.checkData()) return;
+
       if (
         !this.classMarkIsOpen ||
         this.cacheDataMd5 === this.getSubmitDataMd5()

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

@@ -678,6 +678,8 @@ export default {
       return true;
     },
     async toNext(step = 1) {
+      if (!this.checkData()) return;
+
       // 如果试卷结构有变动,先保存
       if (this.cacheDataMd5 !== this.getSubmitDataMd5()) {
         const res = await this.submit();

+ 50 - 20
src/modules/mark/components/markParam/ModifyMarkParams.vue

@@ -118,6 +118,7 @@ export default {
       // step
       steps,
       curStepIndex: 0,
+      finishedSteps: [],
       questionSubmit: false,
     };
   },
@@ -151,27 +152,14 @@ export default {
     ]),
     async initData() {
       this.setBasicInfo({ ...this.instance });
+
+      // check step status
+      await this.initSteps();
+
       const params = {
         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);
       let curMainNumber = null;
@@ -199,9 +187,36 @@ export default {
 
       this.dataReady = true;
     },
-    initSteps() {
+    async initSteps() {
+      const stepRes = await markParamStepStatus({
+        examId: this.instance.examId,
+        paperNumber: this.instance.paperNumber,
+      });
+      const stepMap = {
+        subjectiveStruct: 0,
+        subjectiveMarker: 1,
+        subjectiveMarkerClass: 2,
+        objectiveAnswer: 3,
+      };
+      this.finishedSteps = Object.keys(stepMap)
+        .filter((key) => stepRes[key])
+        .map((key) => stepMap[key]);
+      if (this.finishedSteps.length > 0) {
+        this.curStepIndex = Math.max(...this.finishedSteps);
+        if (this.curStepIndex !== this.lastStep) {
+          this.curStepIndex++;
+        }
+      } else {
+        this.curStepIndex = 0;
+      }
+
       this.steps = steps.map((step, index) => {
-        step.status = index <= this.curStepIndex ? "success" : "wait";
+        step.status =
+          index < this.curStepIndex
+            ? "success"
+            : index === this.curStepIndex
+            ? "process"
+            : "wait";
         step.disabled = step.status === "wait";
         return step;
       });
@@ -228,7 +243,11 @@ export default {
       const nextStepIndex = this.curStepIndex + step;
       if (nextStepIndex > this.lastStep) return;
       this.steps[this.curStepIndex].status = "success";
-      this.steps[nextStepIndex].status = "success";
+      if (!this.finishedSteps.includes(this.curStepIndex)) {
+        this.finishedSteps.push(this.curStepIndex);
+      }
+
+      this.steps[nextStepIndex].status = "process";
       this.curStepIndex = nextStepIndex;
       this.steps.forEach((item) => {
         item.disabled = item.status === "wait";
@@ -239,7 +258,18 @@ export default {
       const prevStepIndex = this.curStepIndex - step;
       if (prevStepIndex < 0) return;
 
+      this.steps[this.curStepIndex].status = this.finishedSteps.includes(
+        this.curStepIndex
+      )
+        ? "success"
+        : "wait";
+
       this.curStepIndex = prevStepIndex;
+      this.steps[prevStepIndex].status = "process";
+
+      this.steps.forEach((item) => {
+        item.disabled = item.status === "wait";
+      });
     },
     async cancel() {
       const res = await this.$confirm("确定要退出阅卷参数编辑吗?", "提示", {