Przeglądaj źródła

会员营期小节添加一键全选功能

xgb 2 dni temu
rodzic
commit
73e306d943
1 zmienionych plików z 30 dodań i 9 usunięć
  1. 30 9
      src/views/course/userCoursePeriod/index.vue

+ 30 - 9
src/views/course/userCoursePeriod/index.vue

@@ -366,15 +366,33 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item label="小节" prop="videoIds">
-          <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"
-              :label="dict.dictLabel"
-              :value="parseInt(dict.dictValue)"
-            />
-          </el-select>
+         <el-form-item label="小节" prop="videoIds">
+          <div style="display: flex; align-items: center;">
+            <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="flex: 1; margin-right: 10px;"
+              :value-key="'dictValue'">
+              <el-option
+                v-for="dict in videoList"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="parseInt(dict.dictValue)"
+              />
+            </el-select>
+            <el-button
+              type="primary"
+              size="small"
+              @click="selectAllVideos"
+              :disabled="videoList.length === 0 || !course.form.courseId">
+              全选
+            </el-button>
+          </div>
         </el-form-item>
         <el-form-item label="看课时间" prop="timeRange">
           <el-time-picker
@@ -855,6 +873,9 @@ export default {
 
   },
   methods: {
+    selectAllVideos() {
+      this.course.form.videoIds = this.videoList.map(video => parseInt(video.dictValue));
+    },
     /** 删除按钮操作 */
     async handleDeleteCourse(row) {
       const periodDayIds = row.id || this.updateCourse.ids;