|
@@ -42,7 +42,11 @@ class LessonService extends CrudService {
|
|
|
// 取得当前批次开始结束日期,并根据日期取得所有天数
|
|
|
const sedays = await this.getAllDays(batch.startdate, batch.enddate);
|
|
|
// 根据批次取得当前批次下所有班级
|
|
|
- const _classs = await this.clamodel.find({ planid: id, termid: elm.id, batchid: batch.id });
|
|
|
+ const _classs = await this.clamodel.find({
|
|
|
+ planid: id,
|
|
|
+ termid: elm.id,
|
|
|
+ batchid: batch.id,
|
|
|
+ });
|
|
|
// 循环班级
|
|
|
for (const cla of _classs) {
|
|
|
// 记录天数
|
|
@@ -64,18 +68,27 @@ class LessonService extends CrudService {
|
|
|
if (i === 6) {
|
|
|
allday = _lessonmode.allday;
|
|
|
}
|
|
|
- const data = { subid: _subid, subname: lessm['day' + i], date: day, time: lessm.time, day: allday };
|
|
|
+ const data = {
|
|
|
+ subid: _subid,
|
|
|
+ subname: lessm['day' + i],
|
|
|
+ date: day,
|
|
|
+ time: lessm.time,
|
|
|
+ day: allday,
|
|
|
+ };
|
|
|
newlesson.push(data);
|
|
|
}
|
|
|
}
|
|
|
i = i + 1;
|
|
|
}
|
|
|
- const newdata = { termid: elm.id, batchid: batch.id, classid: cla.id, lessons: newlesson };
|
|
|
+ const newdata = {
|
|
|
+ termid: elm.id,
|
|
|
+ batchid: batch.id,
|
|
|
+ classid: cla.id,
|
|
|
+ lessons: newlesson,
|
|
|
+ };
|
|
|
// 将课程信息填入课程表
|
|
|
await this.model.create(newdata);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -86,11 +99,19 @@ class LessonService extends CrudService {
|
|
|
resultArr = [],
|
|
|
dateReg = /^[2]\d{3}-[01]\d-[0123]\d$/;
|
|
|
|
|
|
- if (typeof begin_date !== 'string' || begin_date === '' || !dateReg.test(begin_date)) {
|
|
|
+ if (
|
|
|
+ typeof begin_date !== 'string' ||
|
|
|
+ begin_date === '' ||
|
|
|
+ !dateReg.test(begin_date)
|
|
|
+ ) {
|
|
|
return errArr;
|
|
|
}
|
|
|
|
|
|
- if (typeof end_date !== 'string' || end_date === '' || !dateReg.test(end_date)) {
|
|
|
+ if (
|
|
|
+ typeof end_date !== 'string' ||
|
|
|
+ end_date === '' ||
|
|
|
+ !dateReg.test(end_date)
|
|
|
+ ) {
|
|
|
return errArr;
|
|
|
}
|
|
|
|
|
@@ -112,15 +133,12 @@ class LessonService extends CrudService {
|
|
|
let tempTimestamp = beginTimestamp,
|
|
|
tempDate = begin_date;
|
|
|
|
|
|
-
|
|
|
// 新增日期是否和结束日期相等, 相等跳出循环
|
|
|
while (tempTimestamp !== endTimestamp) {
|
|
|
resultArr.push(tempDate);
|
|
|
|
|
|
// 增加一天
|
|
|
- tempDate = moment(tempTimestamp)
|
|
|
- .add(1, 'd')
|
|
|
- .format('YYYY-MM-DD');
|
|
|
+ tempDate = moment(tempTimestamp).add(1, 'd').format('YYYY-MM-DD');
|
|
|
|
|
|
// 将增加时间变为时间戳
|
|
|
tempTimestamp = Date.parse(new Date(tempDate));
|
|
@@ -129,7 +147,6 @@ class LessonService extends CrudService {
|
|
|
// 将最后一天放入数组
|
|
|
resultArr.push(end_date);
|
|
|
return resultArr;
|
|
|
-
|
|
|
} catch (err) {
|
|
|
return errArr;
|
|
|
}
|
|
@@ -148,7 +165,10 @@ class LessonService extends CrudService {
|
|
|
const data = [];
|
|
|
for (const term of terms) {
|
|
|
// 根据期id与教师id查出课程班级信息
|
|
|
- const lessons = await this.model.find({ termid: term.id, 'lessons.teaid': teaid });
|
|
|
+ const lessons = await this.model.find({
|
|
|
+ termid: term.id,
|
|
|
+ 'lessons.teaid': teaid,
|
|
|
+ });
|
|
|
const batchs = await term.batchnum;
|
|
|
for (const elm of lessons) {
|
|
|
const newdata = {};
|
|
@@ -174,6 +194,11 @@ class LessonService extends CrudService {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ async uplessones(data) {
|
|
|
+ for (const _data of data) {
|
|
|
+ await this.model.findByIdAndUpdate(_data.id, _data);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = LessonService;
|