lrf402788946 %!s(int64=4) %!d(string=hai) anos
pai
achega
0d8a59c87b
Modificáronse 2 ficheiros con 11 adicións e 3 borrados
  1. 1 1
      app/controller/.apply.js
  2. 10 2
      app/service/apply.js

+ 1 - 1
app/controller/.apply.js

@@ -41,7 +41,7 @@ module.exports = {
   },
   confirm: {
     params: ["!planid"],
-    requestBody: ["ids"],
+    requestBody: ["ids", "classtype"],
     service: "arrangeConfirm",
   },
 };

+ 10 - 2
app/service/apply.js

@@ -141,8 +141,8 @@ class ApplyService extends CrudService {
     await trainplan.save();
   }
   // 确认计划安排
-  async arrangeConfirm({ planid, ids }) {
-    console.log(planid, ids);
+  async arrangeConfirm({ planid, ids, classtype }) {
+    console.log(planid, ids, classtype);
     const trainplan = await this.trainmodel.findById(planid);
     if (!trainplan) {
       throw new BusinessError(ErrorCode.DATA_EXISTED, '年度计划不存在');
@@ -162,6 +162,13 @@ class ApplyService extends CrudService {
         const { batch } = b;
         if (!(b.class && _.isArray(b.class))) continue;
         for (const c of b.class) {
+          // 检查是否要求班级类型
+          if (classtype) {
+            // 获取这个班级的班级类型
+            const { type } = c;
+            // 判断班级类型与要求的符不符合,不符合就跳过不改
+            if (`${type}` !== `${classtype}`) continue;
+          }
           if (!(c.lessons && _.isArray(c.lessons))) continue;
           for (const l of c.lessons) {
             l.status = '1';
@@ -169,6 +176,7 @@ class ApplyService extends CrudService {
         }
       }
     }
+    // console.log(termnum);
     trainplan.termnum = termnum;
     await trainplan.save();
   }