|
@@ -622,6 +622,35 @@ class LessonService extends CrudService {
|
|
return obj;
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async teaIndex({ planid, teaid }) {
|
|
|
|
+ const trainplan = await this.tmodel.findById(planid);
|
|
|
|
+ if (!trainplan) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定年度计划');
|
|
|
|
+ const { termnum } = trainplan;
|
|
|
|
+ const termids = termnum.map(i => i._id);
|
|
|
|
+ let lessons = await this.model.find({ termid: termids, status: '1', lessons: { $elemMatch: { teaid } } });
|
|
|
|
+ if (lessons.length > 0)lessons = JSON.parse(JSON.stringify(lessons));
|
|
|
|
+ else return [];
|
|
|
|
+ const classids = lessons.map(i => i.classid);
|
|
|
|
+ // 找期,班级信息
|
|
|
|
+ const classes = await this.clamodel.find({ _id: classids });
|
|
|
|
+ let res = [];
|
|
|
|
+ for (const i of lessons) {
|
|
|
|
+ const { lessons: ls, classid, termid } = i;
|
|
|
|
+ let term,
|
|
|
|
+ cla;
|
|
|
|
+ const list = ls.filter(f => f.teaid === teaid);
|
|
|
|
+ const t = termnum.find(f => ObjectId(f._id).equals(termid));
|
|
|
|
+ if (t) term = t.term;
|
|
|
|
+ const c = classes.find(f => ObjectId(f._id).equals(classid));
|
|
|
|
+ if (c) cla = c.name;
|
|
|
|
+ for (const l of list) {
|
|
|
|
+ const { subname, date } = l;
|
|
|
|
+ res.push({ subname, date, term, class: cla });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ res = _.uniqWith(res, _.isEqual);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = LessonService;
|
|
module.exports = LessonService;
|