lrf402788946 4 tahun lalu
induk
melakukan
02d5bca01d
1 mengubah file dengan 7 tambahan dan 6 penghapusan
  1. 7 6
      app/service/lesson.js

+ 7 - 6
app/service/lesson.js

@@ -525,7 +525,7 @@ class LessonService extends CrudService {
     // 指定期的数据
     termnum = JSON.parse(JSON.stringify(termnum));
     if (!termnum) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '该期不存在');
-    // // 该期的课表,没有就添加
+    // 该期的课表,没有就添加
     const has_lesson = await this.model.find({ termid });
     const classids = has_lesson.map(i => ObjectId(i.classid));
     // console.log(has_lesson);
@@ -535,14 +535,14 @@ class LessonService extends CrudService {
     // 确保batchnum是数组
     if (!_.isArray(batchnum)) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '该期下批次数据错误');
     for (const b of batchnum) {
-      const { _id: batchid, class: classArrange, type, startdate, enddate } = b;
+      const { _id: batchid, class: classArrange, startdate, enddate } = b;
       const classList = await this.clamodel.find({ planid, termid, batchid });
       // 确保list是数组
       if (!classList || classList.length === 0) continue;
       const clist = JSON.parse(JSON.stringify(classList));
       for (const c of clist) {
         // 排指定班
-        const { name, ...lessinfo } = await this.partsOfClass(c);
+        const { name, type, ...lessinfo } = await this.partsOfClass(c);
         // 查看该班级是否已经有课表
         const is_has = has_classList.find(f => f.name === name);
         if (is_has) continue;
@@ -560,11 +560,12 @@ class LessonService extends CrudService {
           continue;
         }
         // 根据班级类型找到原课表模板
-        let lessonModel = lmodelList.find(f => f.code === type);
+        let lessonModel = lmodelList.find(f => f.type === type);
         lessonModel = JSON.parse(JSON.stringify(lessonModel));
         // 原模板
         let { lessons: otemplate } = lessonModel;
         otemplate = JSON.parse(otemplate);
+
         // 日期列表,感谢裕哥能给我留个可用的东西
         const dayList = await this.getAllDays(startdate, enddate);
         const lessons = [];
@@ -614,8 +615,8 @@ class LessonService extends CrudService {
   // 新排课,将班级层面处理抽出来
   async partsOfClass(classinfo) {
     classinfo = JSON.parse(JSON.stringify(classinfo));
-    const { termid, batchid, _id: classid, name } = classinfo;
-    const obj = { termid, batchid, classid, name };
+    const { termid, batchid, _id: classid, name, type } = classinfo;
+    const obj = { termid, batchid, classid, name, type };
     return obj;
   }