|
|
@@ -178,19 +178,13 @@
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
v-hasPermi="['course:period:edit']"
|
|
|
>修改</el-button>
|
|
|
- <!-- <el-button-->
|
|
|
- <!-- size="mini"-->
|
|
|
- <!-- type="text"-->
|
|
|
- <!-- icon="el-icon-edit"-->
|
|
|
- <!-- @click="handleCourse(scope.row)"-->
|
|
|
- <!-- v-hasPermi="['course:period:edit']"-->
|
|
|
- <!-- >课程管理</el-button>-->
|
|
|
- <!-- <el-button-->
|
|
|
- <!-- size="mini"-->
|
|
|
- <!-- type="text"-->
|
|
|
- <!-- icon="el-icon-money"-->
|
|
|
- <!-- @click="setRedPacket(scope.row)"-->
|
|
|
- <!-- >设置红包</el-button>-->
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-copy-document"
|
|
|
+ @click="handleCopyPeriod(scope.row)"
|
|
|
+ v-hasPermi="['course:period:copy']"
|
|
|
+ >复制</el-button>
|
|
|
<el-button
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
@@ -585,7 +579,7 @@
|
|
|
size="mini"
|
|
|
icon="el-icon-delete"
|
|
|
:disabled="updateCourse.ids.length <= 0"
|
|
|
- @click="handleDeleteCourse"
|
|
|
+ @click="handleDeleteCourse()"
|
|
|
v-hasPermi="['course:period:dayRemove']"
|
|
|
>删除课程</el-button>
|
|
|
</el-col>
|
|
|
@@ -681,7 +675,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse, insertCourse, delPeriodDay, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod} from "@/api/course/userCoursePeriod";
|
|
|
+import {addPeriod, delPeriod, exportPeriod, getPeriod, pagePeriod, updatePeriod, getDays, addCourse, insertCourse, delPeriodDay, delPeriodDayAndReorder, updateCourseTime, updateCourseDate, updateListCourseData, periodCourseMove, closePeriod, copyPeriod} from "@/api/course/userCoursePeriod";
|
|
|
import {getCompanyList} from "@/api/company/company";
|
|
|
import { listCamp, addCamp, editCamp, delCamp, copyCamp } from "@/api/course/userCourseCamp";
|
|
|
import { courseList,videoList } from '@/api/course/courseRedPacketLog'
|
|
|
@@ -726,6 +720,10 @@ export default {
|
|
|
isDisabledDateRange: false, //是否禁用开营日期
|
|
|
// 是否显示弹出层
|
|
|
open: false,
|
|
|
+ // 是否为复制模式
|
|
|
+ isCopyMode: false,
|
|
|
+ // 复制的源营期ID
|
|
|
+ copySourcePeriodId: null,
|
|
|
// 查询参数
|
|
|
queryParams: {
|
|
|
pageNum: 1,
|
|
|
@@ -952,24 +950,69 @@ export default {
|
|
|
methods: {
|
|
|
/** 删除按钮操作 */
|
|
|
async handleDeleteCourse(row) {
|
|
|
- const periodDayIds = row.id || this.updateCourse.ids;
|
|
|
+ const isSingleRow = !!(row && row.id != null);
|
|
|
+ const periodDayIds = isSingleRow ? row.id : this.updateCourse.ids;
|
|
|
+
|
|
|
+ const now = new Date();
|
|
|
+ const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
|
|
+ let canReorder = false;
|
|
|
+ if (isSingleRow && row.dayDate) {
|
|
|
+ const dayDateStr = String(row.dayDate).slice(0, 10);
|
|
|
+ canReorder = dayDateStr > todayStr;
|
|
|
+ } else if (!isSingleRow) {
|
|
|
+ canReorder = this.course.list
|
|
|
+ .filter(item => this.updateCourse.ids.includes(item.id))
|
|
|
+ .some(item => {
|
|
|
+ if (!item.dayDate) return false;
|
|
|
+ return String(item.dayDate).slice(0, 10) > todayStr;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('[handleDeleteCourse] isSingleRow:', isSingleRow, 'periodDayIds:', periodDayIds, 'canReorder:', canReorder);
|
|
|
try {
|
|
|
- await this.$confirm('是否确认删除该课程?', "提示", {
|
|
|
- confirmButtonText: "确定",
|
|
|
- cancelButtonText: "取消",
|
|
|
- type: "warning"
|
|
|
+ console.log('[handleDeleteCourse] about to show confirm, $confirm type:', typeof this.$confirm);
|
|
|
+ await this.$confirm('是否确认删除该课程?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
});
|
|
|
|
|
|
- const res = await delPeriodDay(periodDayIds);
|
|
|
+ // 满足条件时弹出是否重排序询问框
|
|
|
+ let reorder = false;
|
|
|
+ if (canReorder) {
|
|
|
+ await new Promise(resolve => setTimeout(resolve, 300));
|
|
|
+ try {
|
|
|
+ await this.$confirm(
|
|
|
+ '是否重新排序?选择"是"后,被删课程之后的课程日期将整体提前 1 天。',
|
|
|
+ '是否重新排序',
|
|
|
+ {
|
|
|
+ confirmButtonText: '是',
|
|
|
+ cancelButtonText: '否',
|
|
|
+ type: 'info'
|
|
|
+ }
|
|
|
+ );
|
|
|
+ reorder = true;
|
|
|
+ } catch (e) {
|
|
|
+ reorder = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await delPeriodDayAndReorder(
|
|
|
+ Array.isArray(periodDayIds) ? periodDayIds : [periodDayIds],
|
|
|
+ reorder
|
|
|
+ );
|
|
|
|
|
|
if (res && res.code === 200) {
|
|
|
- this.getCourseList();// 刷新列表
|
|
|
+ this.getCourseList();
|
|
|
this.$message.success('删除成功');
|
|
|
+ if (reorder) {
|
|
|
+ this.$message.success('课程日期已重新排序');
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.error(res.msg);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
-
|
|
|
+ // 用户取消删除,不处理
|
|
|
}
|
|
|
},
|
|
|
/** 查询会员营期列表 */
|
|
|
@@ -1050,10 +1093,37 @@ export default {
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd() {
|
|
|
this.reset();
|
|
|
+ this.isCopyMode = false;
|
|
|
+ this.copySourcePeriodId = null;
|
|
|
this.open = true;
|
|
|
this.title = "添加会员营期";
|
|
|
this.isDisabledDateRange = false;
|
|
|
},
|
|
|
+ /** 复制营期按钮操作 */
|
|
|
+ handleCopyPeriod(row) {
|
|
|
+ this.reset();
|
|
|
+ getPeriod(row.periodId).then(res => {
|
|
|
+ this.form = res.data;
|
|
|
+ this.form.periodId = null;
|
|
|
+ if (this.form.companyId) {
|
|
|
+ this.form.companyId = this.form.companyId.split(',').map(id => Number(id));
|
|
|
+ }
|
|
|
+ if (this.form.viewStartTime && this.form.viewEndTime) {
|
|
|
+ this.form.timeRange = [this.form.viewStartTime, this.form.viewEndTime];
|
|
|
+ }
|
|
|
+ if (this.form.periodType == 1) {
|
|
|
+ this.$set(this.form, 'dateRange', [this.form.periodStartingTime, this.form.periodEndTime]);
|
|
|
+ }
|
|
|
+ if (this.form.periodType == 2) {
|
|
|
+ this.$set(this.form, 'date', this.form.periodStartingTime);
|
|
|
+ }
|
|
|
+ this.isCopyMode = true;
|
|
|
+ this.copySourcePeriodId = row.periodId;
|
|
|
+ this.open = true;
|
|
|
+ this.title = '复制营期';
|
|
|
+ this.isDisabledDateRange = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
this.reset();
|
|
|
@@ -1083,14 +1153,35 @@ export default {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
let data = JSON.parse(JSON.stringify(this.form));
|
|
|
- // 处理看课时间范围
|
|
|
if (data.timeRange && data.timeRange.length === 2) {
|
|
|
data.viewStartTime = data.timeRange[0];
|
|
|
data.viewEndTime = data.timeRange[1];
|
|
|
}
|
|
|
data.companyId = data.companyId.join()
|
|
|
data.trainingCampId = this.queryParams.trainingCampId
|
|
|
- if (data.periodId != null) {
|
|
|
+
|
|
|
+ if (this.isCopyMode && this.copySourcePeriodId) {
|
|
|
+ copyPeriod(this.copySourcePeriodId).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ data.periodId = response.data;
|
|
|
+ updatePeriod(data).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.msgSuccess("复制成功");
|
|
|
+ this.open = false;
|
|
|
+ this.isCopyMode = false;
|
|
|
+ this.copySourcePeriodId = null;
|
|
|
+ this.getList();
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.msg || '保存失败');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '复制失败');
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error('复制营期失败');
|
|
|
+ });
|
|
|
+ } else if (data.periodId != null) {
|
|
|
updatePeriod(data).then(response => {
|
|
|
if (response.code === 200) {
|
|
|
this.msgSuccess("修改成功");
|