Просмотр исходного кода

解决:新增作业时可以啥也不填

chenjiayao 1 год назад
Родитель
Сommit
8604d00233
1 измененных файлов с 29 добавлено и 1 удалено
  1. 29 1
      src/views/CoursePage/CoursePage.vue

+ 29 - 1
src/views/CoursePage/CoursePage.vue

@@ -49,7 +49,7 @@
 
   <el-dialog v-model="visible" title="新增课程">
     <el-form :model="newCourse">
-      <el-form-item label="课程名称">
+      <el-form-item label="课程名称" >
         <el-input v-model="newCourse.courseName" placeholder="请输入名称"></el-input>
       </el-form-item>
       <el-form-item label="面向年级">
@@ -238,6 +238,34 @@
   }
 
   const handleSubmit = () => {
+    if(newCourse.courseName === '') {
+      ElNotification({title: '课程名称不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.targetGrade === '') {
+      ElNotification({title: '面向年级不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.description === '') {
+      ElNotification({title: '描述不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.enrollCode === '') {
+      ElNotification({title: '选课码不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.startTime === '') {
+      ElNotification({title: '开始时间不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.endTime === '') {
+      ElNotification({title: '结束时间不得为空',type: 'error',})
+      return
+    }
+    if(newCourse.startTime >= newCourse.endTime) {
+      ElNotification({title: '结束时间不得在起始时间之前',type: 'error',})
+      return
+    }
     newCourse.endTime = formatDate(newCourse.endTime)
     newCourse.startTime = formatDate(newCourse.startTime)
     apis.createCourse(newCourse)