Преглед изворни кода

修复添加课程选择小节的问题

caoliqin пре 1 месец
родитељ
комит
f470633584
1 измењених фајлова са 21 додато и 6 уклоњено
  1. 21 6
      src/views/course/userCoursePeriod/index.vue

+ 21 - 6
src/views/course/userCoursePeriod/index.vue

@@ -324,7 +324,7 @@
     <el-dialog title="添加课程" :visible.sync="course.addOpen" width="500px" append-to-body>
       <el-form ref="courseAddForm" :model="course.form" label-width="100px">
         <el-form-item label="课程" prop="courseId">
-          <el-select filterable  v-model="course.form.courseId" placeholder="请选择课程"  clearable size="small" @change="courseChange(course.form.courseId)" style="width: 100%">
+          <el-select filterable  v-model="course.form.courseId" placeholder="请选择课程"  clearable size="small" @change="courseChange(course.form.courseId)" style="width: 100%" :value-key="'dictValue'">
             <el-option
               v-for="dict in courseList"
               :key="dict.dictValue"
@@ -334,7 +334,7 @@
           </el-select>
         </el-form-item>
         <el-form-item label="小节" prop="videoId">
-          <el-select filterable  v-model="course.form.videoIds" placeholder="请选择小节" :multiple-limit="getDiff(course.row.periodStartingTime, course.row.periodEndTime) - course.total" multiple clearable size="small" style="width: 100%">
+          <el-select filterable  v-model="course.form.videoIds" placeholder="请选择小节" :multiple-limit="getDiff(course.row.periodStartingTime, course.row.periodEndTime) - course.total" multiple clearable size="small" style="width: 100%" :value-key="'dictValue'">
             <el-option
               v-for="dict in videoList"
               :key="dict.dictValue"
@@ -979,17 +979,32 @@ export default {
         this.course.loading = false;
       });
     },
-    handleAddCourse(){
+    handleAddCourse() {
       this.course.addOpen = true;
       this.course.form = {
         periodId: this.course.row.periodId,
+        courseId: null,
+        videoIds: []
       };
+      // 重置表单
+      this.$nextTick(() => {
+        if (this.$refs.courseAddForm) {
+          this.$refs.courseAddForm.resetFields();
+        }
+      });
     },
-    closeAddCourse(){
+    closeAddCourse() {
       this.course.addOpen = false;
+      this.course.form = {
+        periodId: null,
+        courseId: null,
+        videoIds: []
+      };
+      // 重置表单
+      if (this.$refs.courseAddForm) {
+        this.$refs.courseAddForm.resetFields();
+      }
     },
-
-    //查询小节
     courseChange(row){
       this.course.form.videoIds = [];
       videoList(row).then(response => {