按天复制课程

This commit is contained in:
limqhz
2021-03-28 23:53:10 +08:00
parent c04a284369
commit 8ae8ef1c90
8 changed files with 209 additions and 10 deletions

View File

@@ -20,3 +20,10 @@ export function remove(ids) {
export function save(params) {
return http.post('/venue/lesson', params)
}
/**
* 复制课程
*/
export function copy(params) {
return http.post('/venue/lesson/copy', params)
}

View File

@@ -84,6 +84,7 @@
<el-button size="small" type="text" @click="handleEdit(scope.row.id)">编辑</el-button>
<el-button size="small" type="text" v-if="scope.row.saleNum > 0" @click="handleInfo(scope.row.id)">预约记录</el-button>
<el-button size="small" type="text" @click="showimg(scope.row.id)">复制</el-button>
<el-button size="small" type="text" @click="showCopyByDay(scope.row.id)">按天复制</el-button>
<el-button size="small" v-if="scope.row.saleNum <= 0" type="text" class="danger" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
@@ -124,6 +125,29 @@
<el-button @click="dialogFormVisible = false"> </el-button>
</div>
</el-dialog>
<el-dialog title="复制该课程所在日期的所有课程到目标日期范围" :visible.sync="dialogFormByDay">
<div class="dialog_div">
<span>选择复制起期</span>
<el-date-picker
class="filter-item" v-model="copyParam.leftDate" type="date" placeholder="选择复制起期"
:picker-options="startDatePicker"
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
</el-date-picker>
</div>
<div class="dialog_div">
<span>选择复制止期</span>
<el-date-picker
class="filter-item" v-model="copyParam.rightDate" type="date" placeholder="选择复制止期"
:picker-options="endDatePicker"
value-format="yyyy-MM-dd" format="yyyy-MM-dd">
</el-date-picker>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="copyLessonByDay">保存</el-button>
<el-button @click="dialogFormByDay = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
@@ -137,7 +161,7 @@
<script>
import { findByVenueType } from '@/api//coach'
import { remove, find, save } from '@/api//venue/lesson'
import { remove, find, save, copy } from '@/api//venue/lesson'
import waves from '@/directive/waves.js' // 水波纹指令
import Pagination from '@/components/Pagination'
import moment from 'moment'
@@ -152,6 +176,7 @@ export default {
return {
coaches: [],
dialogFormVisible: false,
dialogFormByDay: false,
params: {
search_eq_v$venueId: undefined,
search_eq_v$date: undefined,
@@ -162,11 +187,18 @@ export default {
leftTime: undefined,
rightTime: undefined
},
copyParam: {
lessonId: undefined,
leftDate: '',
rightDate: ''
},
pickerOptions: {
disabledDate(time) {
return Date.now() > time
disabledDate(date) {
return Date.now() > date
}
},
startDatePicker: this.beginDate(),
endDatePicker: this.processDate(),
time: undefined,
times: '',
data: '',
@@ -223,9 +255,44 @@ export default {
this.dialogFormVisible = true
this.findById(id)
},
/**
* 按天复制
*/
showCopyByDay(id) {
this.copyParam.lessonId = id
this.dialogFormByDay = true
},
onDateChange(value) {
},
beginDate() {
const self = this
return {
disabledDate(time) {
if (self.copyParam.rightDate && time.getTime() > Date.now()) {
return new Date(self.form.rightDate).getTime() < time.getTime()
} else {
return time.getTime() < Date.now()
}
}
}
},
processDate() {
const self = this
return {
disabledDate(time) {
if (self.copyParam.leftDate) {
return new Date(self.copyParam.leftDate).getTime() > time.getTime()
} else {
return time.getTime() < Date.now()
}
}
}
},
onTimeChange(value) {
if (value) {
this.form.startTime = value[0] + ':00.000'
@@ -265,6 +332,31 @@ export default {
this.dialogFormVisible = false
},
/**
* 保存复制的课程
*/
copyLessonByDay() {
if (this.copyParam.leftDate === '' || this.copyParam.leftDate === null) {
this.$message({
message: '请选择起始日期!',
type: 'warning'
})
return
}
if (this.copyParam.rightDate === '' || this.copyParam.rightDate === null) {
this.$message({
message: '请选择结束日期!',
type: 'warning'
})
return
}
copy(this.copyParam).then(response => {
this.$refs.pagination.handleSearch()
}).finally(() => {
this.dialogFormByDay = false
})
},
/**
* 查询复制课程信息
*/

View File

@@ -1,18 +1,22 @@
package com.sv.oms.controller;
import com.sv.dto.oms.VenueLessonOmsDTO;
import com.sv.service.api.util.DateUtilCard;
import com.ydd.framework.core.common.Pagination;
import com.ydd.framework.core.common.dto.ResponseDTO;
import com.ydd.oms.controller.OmsController;
import com.sv.entity.VenueLesson;
import com.sv.service.oms.VenueLessonService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
/**
* Controller - 场馆课程
@@ -24,7 +28,7 @@ import java.text.ParseException;
public class VenueLessonController extends OmsController {
private final Logger logger = LoggerFactory.getLogger(VenueLessonController.class);
@Resource
private VenueLessonService venueLessonService;
@@ -51,7 +55,7 @@ public class VenueLessonController extends OmsController {
*/
@RequestMapping(value = "/venue/lesson", method = RequestMethod.POST)
public ResponseDTO save(VenueLessonOmsDTO venueLesson) throws ParseException {
venueLessonService.save(venueLesson);
venueLessonService. save(venueLesson);
return ResponseDTO.ok("保存成功");
}
@@ -64,4 +68,16 @@ public class VenueLessonController extends OmsController {
return ResponseDTO.ok("删除成功");
}
/**
* 复制课程
*/
@RequestMapping(value = "/venue/lesson/copy", method = RequestMethod.POST)
public ResponseDTO copy(@RequestParam("lessonId") Integer lessonId,@RequestParam("leftDate") String leftDate,@RequestParam("rightDate") String rightDate) throws ParseException {
DateUtils.parseDate(leftDate,"YYYY-MM-DD");
Date start = DateUtilCard.getDateFromStr(leftDate);
Date end = DateUtilCard.getDateFromStr(rightDate);
venueLessonService.copy(lessonId,start,end);
return ResponseDTO.ok("保存成功");
}
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF8"?>
<configuration>
<jmxConfigurator />
<property name="LOG_HOME" value="/home/logs/oms_log"/>
<property name="LOG_HOME" value="~/home/logs/oms_log"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">