소스 검색

抽卷几率校验

Michael Wang 4 년 전
부모
커밋
181db3909c
1개의 변경된 파일12개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      src/features/examwork/CourseManagement/CoursePaperDialog.vue

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

@@ -43,6 +43,8 @@
               <el-input-number
                 v-model.trim="scope.row.weight"
                 :min="0"
+                :step="1"
+                step-strictly
                 :max="100"
               >
                 <template slot="append">%</template></el-input-number
@@ -151,6 +153,16 @@ export default {
     },
     async submitForm() {
       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;
         await saveCourse({
           examId: this.refreshCourse.examId,