|
@@ -367,14 +367,35 @@
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="小节" prop="videoIds">
|
|
<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>
|
|
|
|
|
|
|
+ <div style="display: flex; align-items: center; gap: 10px; 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="flex: 1"
|
|
|
|
|
+ :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="handleBatchSelectSections"
|
|
|
|
|
+ :disabled="!course.form.courseId || !videoList || videoList.length === 0"
|
|
|
|
|
+ title="一键选择所有可用小节"
|
|
|
|
|
+ >
|
|
|
|
|
+ 批量选择
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="看课时间" prop="timeRange">
|
|
<el-form-item label="看课时间" prop="timeRange">
|
|
|
<el-time-picker
|
|
<el-time-picker
|
|
@@ -614,7 +635,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod} from "@/api/course/userCoursePeriod";
|
|
|
|
|
|
|
+import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod, batchAddCourseSections} from "@/api/course/userCoursePeriod";
|
|
|
import {getCompanyList} from "@/api/company/company";
|
|
import {getCompanyList} from "@/api/company/company";
|
|
|
import { listCamp, addCamp, editCamp, delCamp, copyCamp } from "@/api/course/userCourseCamp";
|
|
import { listCamp, addCamp, editCamp, delCamp, copyCamp } from "@/api/course/userCourseCamp";
|
|
|
import { courseList,videoList } from '@/api/course/courseRedPacketLog'
|
|
import { courseList,videoList } from '@/api/course/courseRedPacketLog'
|
|
@@ -1519,14 +1540,86 @@ export default {
|
|
|
this.course.form.startTime = this.course.form.timeRange[0];
|
|
this.course.form.startTime = this.course.form.timeRange[0];
|
|
|
this.course.form.endTime1 = this.course.form.timeRange[1];
|
|
this.course.form.endTime1 = this.course.form.timeRange[1];
|
|
|
}
|
|
}
|
|
|
- // 提交数据
|
|
|
|
|
- addCourse(this.course.form).then(response => {
|
|
|
|
|
- this.$message.success('添加成功');
|
|
|
|
|
- this.course.addOpen = false;
|
|
|
|
|
- // 重新加载训练营列表
|
|
|
|
|
- this.getCourseList();
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否有选择的小节
|
|
|
|
|
+ if (!this.course.form.videoIds || this.course.form.videoIds.length === 0) {
|
|
|
|
|
+ this.$message.warning('请选择至少一个小节');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果选择了多个小节,使用批量添加接口
|
|
|
|
|
+ if (this.course.form.videoIds.length > 1) {
|
|
|
|
|
+ const batchData = {
|
|
|
|
|
+ periodId: this.course.form.periodId,
|
|
|
|
|
+ courseId: this.course.form.courseId,
|
|
|
|
|
+ videoIds: this.course.form.videoIds,
|
|
|
|
|
+ startTime: this.course.form.startTime,
|
|
|
|
|
+ endTime1: this.course.form.endTime1,
|
|
|
|
|
+ endDateTime: this.course.form.endTime1, // 添加endDateTime参数
|
|
|
|
|
+ joinTime: this.course.form.joinTime
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 调用批量添加小节接口
|
|
|
|
|
+ batchAddCourseSections(batchData).then(response => {
|
|
|
|
|
+ if (response.code === 200) {
|
|
|
|
|
+ this.$message.success('批量添加课程成功');
|
|
|
|
|
+ this.course.addOpen = false;
|
|
|
|
|
+ this.getCourseList();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error(response.msg || '批量添加课程失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$message.error('批量添加课程失败:' + (error.message || '未知错误'));
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 单个小节,使用原来的接口
|
|
|
|
|
+ addCourse(this.course.form).then(response => {
|
|
|
|
|
+ this.$message.success('添加成功');
|
|
|
|
|
+ this.course.addOpen = false;
|
|
|
|
|
+ this.getCourseList();
|
|
|
|
|
+ }).catch(error => {
|
|
|
|
|
+ this.$message.error('添加失败:' + (error.message || '未知错误'));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ /** 批量选择小节 */
|
|
|
|
|
+ handleBatchSelectSections() {
|
|
|
|
|
+ if (!this.course.form.courseId) {
|
|
|
|
|
+ this.$message.warning('请先选择课程');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.videoList || this.videoList.length === 0) {
|
|
|
|
|
+ this.$message.warning('该课程下暂无可选择的小节');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.$confirm('确认要批量选择所有小节吗?', '提示', {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'info'
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ // 获取所有可用的小节ID
|
|
|
|
|
+ const allVideoIds = this.videoList.map(video => parseInt(video.dictValue));
|
|
|
|
|
+
|
|
|
|
|
+ // 获取剩余可选择数量
|
|
|
|
|
+ const remainingLimit = this.getDiff(this.course.row.periodStartingTime, this.course.row.periodEndTime) - this.course.total;
|
|
|
|
|
+
|
|
|
|
|
+ // 只选择剩余数量内的小节
|
|
|
|
|
+ const selectedVideoIds = allVideoIds.slice(0, remainingLimit);
|
|
|
|
|
+
|
|
|
|
|
+ if (selectedVideoIds.length === 0) {
|
|
|
|
|
+ this.$message.warning('已达到营期天数限制,无法添加更多小节');
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 将选中的小节ID设置到表单中(只是选择,不调用API)
|
|
|
|
|
+ this.course.form.videoIds = selectedVideoIds;
|
|
|
|
|
+ this.$message.success(`批量选择成功,已选择 ${selectedVideoIds.length} 个小节`);
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.$message.info('已取消批量选择');
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
submitUpdateCourseForm(){
|
|
submitUpdateCourseForm(){
|