|
@@ -307,6 +307,16 @@
|
|
|
:clearable="true">
|
|
:clearable="true">
|
|
|
</el-date-picker>
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
+ <el-form-item label="课程选择" prop="courseId" v-if="courseSelectionIsAdd">
|
|
|
|
|
+ <el-select v-model="form.courseId" placeholder="请选课程" filterable clearable size="small" >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="dict in courseSelection"
|
|
|
|
|
+ :key="dict.courseId"
|
|
|
|
|
+ :label="dict.courseName"
|
|
|
|
|
+ :value="dict.courseId"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
<div class="drawer-footer">
|
|
<div class="drawer-footer">
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
@@ -368,15 +378,15 @@
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="小节" prop="videoIds">
|
|
<el-form-item label="小节" prop="videoIds">
|
|
|
<div style="display: flex; align-items: center; gap: 10px; width: 100%;">
|
|
<div style="display: flex; align-items: center; gap: 10px; width: 100%;">
|
|
|
- <el-select
|
|
|
|
|
- filterable
|
|
|
|
|
- v-model="course.form.videoIds"
|
|
|
|
|
- placeholder="请选择小节"
|
|
|
|
|
- :multiple-limit="getDiff(periodSettingsData.periodStartingTime, periodSettingsData.periodEndTime) - course.total"
|
|
|
|
|
- multiple
|
|
|
|
|
- clearable
|
|
|
|
|
- size="small"
|
|
|
|
|
- style="flex: 1"
|
|
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ filterable
|
|
|
|
|
+ v-model="course.form.videoIds"
|
|
|
|
|
+ placeholder="请选择小节"
|
|
|
|
|
+ :multiple-limit="getDiff(periodSettingsData.periodStartingTime, periodSettingsData.periodEndTime) - course.total"
|
|
|
|
|
+ multiple
|
|
|
|
|
+ clearable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ style="flex: 1"
|
|
|
:value-key="'dictValue'"
|
|
:value-key="'dictValue'"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
@@ -386,9 +396,9 @@
|
|
|
:value="parseInt(dict.dictValue)"
|
|
:value="parseInt(dict.dictValue)"
|
|
|
/>
|
|
/>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
- <el-button
|
|
|
|
|
- type="primary"
|
|
|
|
|
- size="small"
|
|
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ size="small"
|
|
|
@click="handleBatchSelectSections"
|
|
@click="handleBatchSelectSections"
|
|
|
:disabled="!course.form.courseId || !videoList || videoList.length === 0"
|
|
:disabled="!course.form.courseId || !videoList || videoList.length === 0"
|
|
|
title="一键选择所有可用小节"
|
|
title="一键选择所有可用小节"
|
|
@@ -644,6 +654,7 @@ import BatchRedPacket from './batchRedPacket.vue'
|
|
|
import CourseStatistics from './statistics.vue'
|
|
import CourseStatistics from './statistics.vue'
|
|
|
import Da from "element-ui/src/locale/lang/da";
|
|
import Da from "element-ui/src/locale/lang/da";
|
|
|
import { getConfigByKey } from '@/api/system/config'
|
|
import { getConfigByKey } from '@/api/system/config'
|
|
|
|
|
+ import {listUserCourse} from "@/api/course/userCourse";
|
|
|
export default {
|
|
export default {
|
|
|
name: "Period",
|
|
name: "Period",
|
|
|
components: {
|
|
components: {
|
|
@@ -863,6 +874,9 @@ export default {
|
|
|
batchSetRedPacketDisabled: true,
|
|
batchSetRedPacketDisabled: true,
|
|
|
// 批量设置红包弹出框
|
|
// 批量设置红包弹出框
|
|
|
batchRedPacketVisible: false,
|
|
batchRedPacketVisible: false,
|
|
|
|
|
+ //课程选择
|
|
|
|
|
+ courseSelection: [],
|
|
|
|
|
+ courseSelectionIsAdd: true, // 默认新增状态,编辑时会设为false
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
@@ -873,7 +887,10 @@ export default {
|
|
|
// this.getList();
|
|
// this.getList();
|
|
|
this.getLeftList();
|
|
this.getLeftList();
|
|
|
this.getCompanyList();
|
|
this.getCompanyList();
|
|
|
-
|
|
|
|
|
|
|
+ /** 获取课程下拉框*/
|
|
|
|
|
+ listUserCourse().then(response => {
|
|
|
|
|
+ this.courseSelection = response.rows;
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
/** 删除按钮操作 */
|
|
/** 删除按钮操作 */
|
|
@@ -975,6 +992,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
/** 新增按钮操作 */
|
|
|
handleAdd() {
|
|
handleAdd() {
|
|
|
|
|
+ this.courseSelectionIsAdd = true;
|
|
|
this.reset();
|
|
this.reset();
|
|
|
this.open = true;
|
|
this.open = true;
|
|
|
this.title = "添加会员营期";
|
|
this.title = "添加会员营期";
|
|
@@ -982,6 +1000,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
handleUpdate(row) {
|
|
|
|
|
+ this.courseSelectionIsAdd = false;
|
|
|
this.reset();
|
|
this.reset();
|
|
|
const periodId = row.periodId || this.ids
|
|
const periodId = row.periodId || this.ids
|
|
|
getPeriod(periodId).then(response => {
|
|
getPeriod(periodId).then(response => {
|
|
@@ -1008,31 +1027,32 @@ export default {
|
|
|
submitForm() {
|
|
submitForm() {
|
|
|
this.$refs["form"].validate(valid => {
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
|
|
+ // 显示加载提示(全屏遮罩+转圈)
|
|
|
|
|
+ const loading = this.$loading({
|
|
|
|
|
+ lock: true, // 锁定屏幕滚动
|
|
|
|
|
+ text: '提交中,请稍候...', // 提示文本
|
|
|
|
|
+ spinner: 'el-icon-loading', // 加载图标
|
|
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)' // 背景遮罩
|
|
|
|
|
+ });
|
|
|
let data = JSON.parse(JSON.stringify(this.form));
|
|
let data = JSON.parse(JSON.stringify(this.form));
|
|
|
// 处理看课时间范围
|
|
// 处理看课时间范围
|
|
|
if (data.timeRange && data.timeRange.length === 2) {
|
|
if (data.timeRange && data.timeRange.length === 2) {
|
|
|
data.viewStartTime = data.timeRange[0];
|
|
data.viewStartTime = data.timeRange[0];
|
|
|
data.viewEndTime = data.timeRange[1];
|
|
data.viewEndTime = data.timeRange[1];
|
|
|
}
|
|
}
|
|
|
- data.companyId = data.companyId.join()
|
|
|
|
|
- data.trainingCampId = this.queryParams.trainingCampId
|
|
|
|
|
- if (data.periodId != null) {
|
|
|
|
|
- updatePeriod(data).then(response => {
|
|
|
|
|
- if (response.code === 200) {
|
|
|
|
|
- this.msgSuccess("修改成功");
|
|
|
|
|
- this.open = false;
|
|
|
|
|
- this.getList();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- addPeriod(data).then(response => {
|
|
|
|
|
- if (response.code === 200) {
|
|
|
|
|
- this.msgSuccess("新增成功");
|
|
|
|
|
- this.open = false;
|
|
|
|
|
- this.getList();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ data.companyId = data.companyId.join();
|
|
|
|
|
+ data.trainingCampId = this.queryParams.trainingCampId;
|
|
|
|
|
+ const request = data.periodId != null ? updatePeriod(data) : addPeriod(data);
|
|
|
|
|
+ request.then(response => {
|
|
|
|
|
+ if (response.code === 200) {
|
|
|
|
|
+ this.msgSuccess(data.periodId != null ? "修改成功" : "新增成功");
|
|
|
|
|
+ this.open = false;
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ // 无论成功失败,都关闭加载提示
|
|
|
|
|
+ loading.close();
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
@@ -1540,13 +1560,13 @@ 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];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 检查是否有选择的小节
|
|
// 检查是否有选择的小节
|
|
|
if (!this.course.form.videoIds || this.course.form.videoIds.length === 0) {
|
|
if (!this.course.form.videoIds || this.course.form.videoIds.length === 0) {
|
|
|
this.$message.warning('请选择至少一个小节');
|
|
this.$message.warning('请选择至少一个小节');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 如果选择了多个小节,使用批量添加接口
|
|
// 如果选择了多个小节,使用批量添加接口
|
|
|
if (this.course.form.videoIds.length > 1) {
|
|
if (this.course.form.videoIds.length > 1) {
|
|
|
const batchData = {
|
|
const batchData = {
|
|
@@ -1558,7 +1578,7 @@ export default {
|
|
|
endDateTime: this.course.form.endTime1, // 添加endDateTime参数
|
|
endDateTime: this.course.form.endTime1, // 添加endDateTime参数
|
|
|
joinTime: this.course.form.joinTime
|
|
joinTime: this.course.form.joinTime
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 调用批量添加小节接口
|
|
// 调用批量添加小节接口
|
|
|
batchAddCourseSections(batchData).then(response => {
|
|
batchAddCourseSections(batchData).then(response => {
|
|
|
if (response.code === 200) {
|
|
if (response.code === 200) {
|
|
@@ -1590,12 +1610,12 @@ export default {
|
|
|
this.$message.warning('请先选择课程');
|
|
this.$message.warning('请先选择课程');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!this.videoList || this.videoList.length === 0) {
|
|
if (!this.videoList || this.videoList.length === 0) {
|
|
|
this.$message.warning('该课程下暂无可选择的小节');
|
|
this.$message.warning('该课程下暂无可选择的小节');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
this.$confirm('确认要批量选择所有小节吗?', '提示', {
|
|
this.$confirm('确认要批量选择所有小节吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
cancelButtonText: '取消',
|
|
@@ -1603,10 +1623,10 @@ export default {
|
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
// 获取所有可用的小节ID
|
|
// 获取所有可用的小节ID
|
|
|
const allVideoIds = this.videoList.map(video => parseInt(video.dictValue));
|
|
const allVideoIds = this.videoList.map(video => parseInt(video.dictValue));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 获取剩余可选择数量
|
|
// 获取剩余可选择数量
|
|
|
const remainingLimit = this.getDiff(this.periodSettingsData.periodStartingTime, this.periodSettingsData.periodEndTime) - this.course.total;
|
|
const remainingLimit = this.getDiff(this.periodSettingsData.periodStartingTime, this.periodSettingsData.periodEndTime) - this.course.total;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 调试信息
|
|
// 调试信息
|
|
|
console.log('批量选择调试信息:', {
|
|
console.log('批量选择调试信息:', {
|
|
|
营期开始时间: this.periodSettingsData.periodStartingTime,
|
|
营期开始时间: this.periodSettingsData.periodStartingTime,
|
|
@@ -1616,15 +1636,15 @@ export default {
|
|
|
剩余可选择数量: remainingLimit,
|
|
剩余可选择数量: remainingLimit,
|
|
|
可用小节总数: allVideoIds.length
|
|
可用小节总数: allVideoIds.length
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 只选择剩余数量内的小节
|
|
// 只选择剩余数量内的小节
|
|
|
const selectedVideoIds = allVideoIds.slice(0, remainingLimit);
|
|
const selectedVideoIds = allVideoIds.slice(0, remainingLimit);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (selectedVideoIds.length === 0) {
|
|
if (selectedVideoIds.length === 0) {
|
|
|
this.$message.warning('已达到营期天数限制,无法添加更多小节');
|
|
this.$message.warning('已达到营期天数限制,无法添加更多小节');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// 将选中的小节ID设置到表单中(只是选择,不调用API)
|
|
// 将选中的小节ID设置到表单中(只是选择,不调用API)
|
|
|
this.course.form.videoIds = selectedVideoIds;
|
|
this.course.form.videoIds = selectedVideoIds;
|
|
|
this.$message.success(`批量选择成功,已选择 ${selectedVideoIds.length} 个小节`);
|
|
this.$message.success(`批量选择成功,已选择 ${selectedVideoIds.length} 个小节`);
|