|
|
@@ -155,7 +155,18 @@
|
|
|
@click="handleBatchSetRedPacket"
|
|
|
v-hasPermi="['course:period:setRedPacket']"
|
|
|
:disabled="batchSetRedPacketDisabled"
|
|
|
- >批量设置红包</el-button>
|
|
|
+ >批量设置红包
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAddExistCampPeriod"
|
|
|
+ v-hasPermi="['course:period:add']"
|
|
|
+ >复制现有营期</el-button>
|
|
|
</el-col>
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
@@ -312,10 +323,10 @@
|
|
|
:clearable="false"
|
|
|
>
|
|
|
</el-date-picker>
|
|
|
- <el-button
|
|
|
+ <el-button
|
|
|
v-if="form.periodType == 1"
|
|
|
- type="warning"
|
|
|
- size="small"
|
|
|
+ type="warning"
|
|
|
+ size="small"
|
|
|
icon="el-icon-setting"
|
|
|
@click="setEndDateTo2099"
|
|
|
title="一键将结束日期设置为2099-12-31"
|
|
|
@@ -681,19 +692,102 @@
|
|
|
</div>
|
|
|
</el-drawer>
|
|
|
|
|
|
- <batch-red-packet
|
|
|
- :visible.sync="batchRedPacketVisible"
|
|
|
- :selected-data="selectedPeriods"
|
|
|
- @success="handleBatchRedPacketSuccess"
|
|
|
- />
|
|
|
+ <batch-red-packet
|
|
|
+ :visible.sync="batchRedPacketVisible"
|
|
|
+ :selected-data="selectedPeriods"
|
|
|
+ @success="handleBatchRedPacketSuccess"
|
|
|
+ />
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ :title="addExistCampPeriodName"
|
|
|
+ :visible.sync="addExistCampPeriod"
|
|
|
+ width="1000px"
|
|
|
+ append-to-body
|
|
|
+ @close="handleDialogClose"
|
|
|
+ >
|
|
|
+ <el-form ref="createCampPeriodForm" :model="createCampPeriodForm" :rules="campRules" label-width="500px">
|
|
|
+ <el-form-item label="营期创建方式" prop="campPeriodType">
|
|
|
+ <el-radio-group v-model="createCampPeriodForm.campPeriodType" @change="handlePeriodTypeChange">
|
|
|
+ <el-radio :label="1">从当前训练营复制</el-radio>
|
|
|
+ <el-radio :label="2">从其他训练营复制</el-radio>
|
|
|
+ <el-radio :label="3">我要新建一个训练营</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- 从当前训练营复制 -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="createCampPeriodForm.campPeriodType === 1"
|
|
|
+ label="选择当前营期"
|
|
|
+ prop="periodId"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ v-model="createCampPeriodForm.periodId"
|
|
|
+ placeholder="请选择当前营期"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in currentCampPeriods"
|
|
|
+ :key="item.periodId"
|
|
|
+ :label="item.periodName"
|
|
|
+ :value="item.periodId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- 从其他训练营复制 -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="createCampPeriodForm.campPeriodType === 2"
|
|
|
+ label="选择其他营期"
|
|
|
+ prop="periodId"
|
|
|
+ >
|
|
|
+ <el-select
|
|
|
+ v-model="createCampPeriodForm.periodId"
|
|
|
+ placeholder="请选择其他营期"
|
|
|
+ :loading="loadingNew"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in otherCampPeriods"
|
|
|
+ :key="item.periodId"
|
|
|
+ :label="item.periodName"
|
|
|
+ :value="item.periodId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <div v-if="loadingNew" class="loading-text">
|
|
|
+ <i class="el-icon-loading"></i> 加载中...
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <!-- 新建营期 -->
|
|
|
+ <el-form-item
|
|
|
+ v-if="createCampPeriodForm.campPeriodType === 3"
|
|
|
+ label="新建营期名称"
|
|
|
+ prop="trainingCampName"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ v-model="createCampPeriodForm.trainingCampName"
|
|
|
+ placeholder="请输入新训练营名称"
|
|
|
+ style="width: 300px"
|
|
|
+ maxlength="50"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="copySubmitCampForm" :loading="submitLoading">确 定</el-button>
|
|
|
+ <el-button @click="cancelExistCampPeriod" :disabled="submitLoading">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod, batchAddCourseSections} from "@/api/course/userCoursePeriod";
|
|
|
+import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse,delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod, batchAddCourseSections,copyExistCampPeriod} from "@/api/course/userCoursePeriod";
|
|
|
import {getCompanyList} from "@/api/company/company";
|
|
|
-import { listCamp, addCamp, editCamp, delCamp, copyCamp } from "@/api/course/userCourseCamp";
|
|
|
+import {listCamp, addCamp, editCamp, delCamp, copyCamp, getScreeningCampPeriod} from "@/api/course/userCourseCamp";
|
|
|
import { courseList,videoList } from '@/api/course/courseRedPacketLog'
|
|
|
import RedPacket from './redPacket.vue'
|
|
|
import BatchRedPacket from './batchRedPacket.vue'
|
|
|
@@ -923,6 +1017,22 @@ export default {
|
|
|
//课程选择
|
|
|
courseSelection: [],
|
|
|
courseSelectionIsAdd: true, // 默认新增状态,编辑时会设为false
|
|
|
+ // 训练营对话框是否显示
|
|
|
+ addExistCampPeriod: false,
|
|
|
+ addExistCampPeriodName: "新增已存在营期",
|
|
|
+ loadingNew: false,
|
|
|
+ submitLoading: false,
|
|
|
+ // 表单数据
|
|
|
+ createCampPeriodForm: {
|
|
|
+ campPeriodType: 1,
|
|
|
+ periodId: null,
|
|
|
+ trainingCampName: null,
|
|
|
+ },
|
|
|
+ // 数据列表
|
|
|
+ currentCampPeriods: [], // 当前训练营的期数列表
|
|
|
+ otherCampPeriods: [], // 其他训练营的期数列表
|
|
|
+ // 缓存数据避免重复请求
|
|
|
+ periodDataCache: new Map(),
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
@@ -1374,6 +1484,7 @@ export default {
|
|
|
// 加载对应的训练营营期数据
|
|
|
const selectedCamp = this.campList[index];
|
|
|
this.queryParams.trainingCampId = selectedCamp.trainingCampId;
|
|
|
+ this.trainingCampIdValue=selectedCamp.trainingCampId;
|
|
|
this.getList();
|
|
|
},
|
|
|
/** 处理滚动事件,实现滚动到底部加载更多 */
|
|
|
@@ -1467,7 +1578,7 @@ export default {
|
|
|
this.$message.warning('请先选择开始日期');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
this.$confirm('是否将结束日期设置为 2099-12-31?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
@@ -1927,6 +2038,165 @@ export default {
|
|
|
// 强制更新组件以刷新领取红包时间的可选范围
|
|
|
this.$forceUpdate();
|
|
|
},
|
|
|
+ /** 新建存在训练营按钮操作 */
|
|
|
+ handleAddExistCampPeriod() {
|
|
|
+ this.resetForm();
|
|
|
+ this.addExistCampPeriod = true;
|
|
|
+ // 初始化当前训练营的期数列表
|
|
|
+ this.initCurrentCampPeriods();
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 初始化当前训练营期数列表 */
|
|
|
+ initCurrentCampPeriods() {
|
|
|
+ this.currentCampPeriods = [...(this.periodList || [])];
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 处理创建方式变更 */
|
|
|
+ async handlePeriodTypeChange(value) {
|
|
|
+ this.createCampPeriodForm.periodId = null;
|
|
|
+ this.createCampPeriodForm.trainingCampName = null;
|
|
|
+ if (value === 1) {
|
|
|
+ // 从当前训练营复制 - 使用本地数据
|
|
|
+ this.initCurrentCampPeriods();
|
|
|
+ } else if (value === 2) {
|
|
|
+ // 从其他训练营复制 - 需要请求接口
|
|
|
+ await this.loadOtherCampPeriods();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /** 加载其他训练营期数列表 */
|
|
|
+ async loadOtherCampPeriods() {
|
|
|
+ if (this.trainingCampIdValue == null) {
|
|
|
+ this.$message.error('缺少训练营ID,无法查询数据');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 检查缓存
|
|
|
+ const cacheKey = `otherCampPeriods_${this.trainingCampIdValue}`;
|
|
|
+ if (this.periodDataCache.has(cacheKey)) {
|
|
|
+ this.otherCampPeriods = this.periodDataCache.get(cacheKey);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ const requestParams = {
|
|
|
+ periodId: this.trainingCampIdValue,
|
|
|
+ campPeriodType: this.createCampPeriodForm.campPeriodType
|
|
|
+ };
|
|
|
+
|
|
|
+ const response = await getScreeningCampPeriod(requestParams);
|
|
|
+
|
|
|
+ if (response && Array.isArray(response.resultList)) {
|
|
|
+ this.otherCampPeriods = response.resultList;
|
|
|
+ // 缓存数据
|
|
|
+ this.periodDataCache.set(cacheKey, response.resultList);
|
|
|
+ } else {
|
|
|
+ console.warn('接口返回格式异常:', response);
|
|
|
+ this.otherCampPeriods = [];
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('接口请求失败:', error);
|
|
|
+ this.$message.error('查询失败,请重试');
|
|
|
+ this.otherCampPeriods = [];
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 提交表单 */
|
|
|
+ copySubmitCampForm() {
|
|
|
+ try {
|
|
|
+ // 表单验证
|
|
|
+ const valid = this.$refs.createCampPeriodForm.validate();
|
|
|
+ if (!valid) return ;
|
|
|
+ this.submitLoading = true;
|
|
|
+ const submitData = this.buildSubmitData();
|
|
|
+ if (submitData.campPeriodType===3){
|
|
|
+ // 新增训练营
|
|
|
+ addCamp(submitData).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('新建训练营成功');
|
|
|
+ this.addExistCampPeriod = false;
|
|
|
+ // 重新加载训练营列表
|
|
|
+ this.getLeftList();
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '新建训练营失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error('新建训练营失败: ' + (error.message || '未知错误'));
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ // 调用批量添加小节接口
|
|
|
+ copyExistCampPeriod(submitData).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('复制营期成功');
|
|
|
+ this.course.addOpen = false;
|
|
|
+ this.addExistCampPeriod = false;
|
|
|
+ // 重新加载训练营列表
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '复制营期失败');
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ this.$message.error('复制营期失败:' + (error.message || '未知错误'));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error('提交失败:' + (error.message || '未知错误'));
|
|
|
+ } finally {
|
|
|
+ this.submitLoading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 组装提交数据 */
|
|
|
+ buildSubmitData() {
|
|
|
+ const { campPeriodType, periodId, trainingCampName } = this.createCampPeriodForm;
|
|
|
+ const baseData = {
|
|
|
+ campPeriodType,
|
|
|
+ trainingCampId: this.trainingCampIdValue // 这里已经正确添加了 trainingCampId
|
|
|
+ };
|
|
|
+ switch (campPeriodType) {
|
|
|
+ case 1: // 从当前训练营复制
|
|
|
+ case 2: // 从其他训练营复制
|
|
|
+ if (!periodId) {
|
|
|
+ throw new Error('请选择要复制的营期');
|
|
|
+ }
|
|
|
+ return { ...baseData, periodId };
|
|
|
+ case 3: // 新建营期
|
|
|
+ if (!trainingCampName?.trim()) {
|
|
|
+ throw new Error('请输入营期名称');
|
|
|
+ }
|
|
|
+ return { ...baseData, trainingCampName: trainingCampName.trim() };
|
|
|
+ default:
|
|
|
+ throw new Error('未知的创建方式');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 取消新建存在训练营 */
|
|
|
+ cancelExistCampPeriod() {
|
|
|
+ this.addExistCampPeriod = false;
|
|
|
+ this.resetForm();
|
|
|
+ },
|
|
|
+ /** 对话框关闭事件 */
|
|
|
+ handleDialogClose() {
|
|
|
+ this.resetForm();
|
|
|
+ },
|
|
|
+ /** 重置表单 */
|
|
|
+ resetForm() {
|
|
|
+ this.createCampPeriodForm = {
|
|
|
+ campPeriodType: 1,
|
|
|
+ periodId: null,
|
|
|
+ trainingCampName: null,
|
|
|
+ };
|
|
|
+
|
|
|
+ this.currentCampPeriods = [];
|
|
|
+ this.otherCampPeriods = [];
|
|
|
+ this.loading = false;
|
|
|
+ this.submitLoading = false;
|
|
|
+
|
|
|
+ // 清除表单验证
|
|
|
+ if (this.$refs.createCampPeriodForm) {
|
|
|
+ this.$refs.createCampPeriodForm.clearValidate();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|