فهرست منبع

优化分数校验和提交

Michael Wang 3 سال پیش
والد
کامیت
fb71065b4d
1فایلهای تغییر یافته به همراه15 افزوده شده و 10 حذف شده
  1. 15 10
      src/features/mark/Mark.vue

+ 15 - 10
src/features/mark/Mark.vue

@@ -34,7 +34,7 @@
 </template>
 
 <script setup lang="ts">
-import { onMounted, watch } from "vue";
+import { onMounted, watch, h } from "vue";
 import {
   clearMarkTask,
   getGroup,
@@ -259,20 +259,25 @@ const saveTaskToServer = async () => {
   const mkey = "save_task_key";
 
   const errors = markResult.scoreList.reduce((p, c, index) => {
-    if (!isNumber(c) && store.currentTask) {
-      const question = store.currentTask.questionList[index];
-      p.push({
-        question,
-        index,
-        error: `${question.mainNumber}-${question.subNumber} 没有赋分不能提交。`,
-      });
+    const question = store.currentTask?.questionList[index]!;
+    let error;
+    if (!isNumber(c)) {
+      error = `${question.mainNumber}-${question.subNumber} 没有赋分不能提交。`;
+    } else if (isNumber(question.maxScore) && c > question.maxScore) {
+      error = `${question.mainNumber}-${question.subNumber} 赋分大于最高分不能提交。`;
+    } else if (isNumber(question.minScore) && c < question.minScore) {
+      error = `${question.mainNumber}-${question.subNumber} 赋分小于最低分不能提交。`;
+    }
+    if (error) {
+      p.push({ question, index, error });
     }
     return p;
   }, [] as Array<{ question: Question; index: number; error: string }>);
   if (errors.length !== 0) {
     console.log(errors);
-    message.error({
-      content: errors.map((e) => `${e.error}`).join("\n"),
+    const msg = errors.map((v) => h("div", `${v.error}`));
+    message.warning({
+      content: h("span", ["校验失败", ...msg]),
       duration: 10,
       key: mkey,
     });