Ver Fonte

抽卷几率校验

Michael Wang há 4 anos atrás
pai
commit
181db3909c

+ 12 - 0
src/features/examwork/CourseManagement/CoursePaperDialog.vue

@@ -43,6 +43,8 @@
               <el-input-number
               <el-input-number
                 v-model.trim="scope.row.weight"
                 v-model.trim="scope.row.weight"
                 :min="0"
                 :min="0"
+                :step="1"
+                step-strictly
                 :max="100"
                 :max="100"
               >
               >
                 <template slot="append">%</template></el-input-number
                 <template slot="append">%</template></el-input-number
@@ -151,6 +153,16 @@ export default {
     },
     },
     async submitForm() {
     async submitForm() {
       try {
       try {
+        const totalWieght = this.papers
+          .map((v) => v.weight)
+          .reduce((p, c) => p + c);
+        if (totalWieght !== 100) {
+          this.$notify({
+            type: "warning",
+            title: `抽卷几率之和必须等于100,当前之和为${totalWieght}`,
+          });
+          return;
+        }
         this.loading = true;
         this.loading = true;
         await saveCourse({
         await saveCourse({
           examId: this.refreshCourse.examId,
           examId: this.refreshCourse.examId,