|
@@ -150,21 +150,30 @@ class TrainplanService extends CrudService {
|
|
|
await this.clamodel.create(newdata);
|
|
|
}
|
|
|
} else {
|
|
|
- // 编辑只会针对班级人数进行修改。
|
|
|
- const _class = await this.clamodel.find({ termid: el.id, batchid: batchnum.id });
|
|
|
- if (_class.length !== 0) {
|
|
|
- for (const ee of _class) {
|
|
|
- ee.number = batchnum.number;
|
|
|
- await ee.save();
|
|
|
+ if (batchnum.class === trainplanold.termnum.id(el.id).batchnum.id(batchnum.id).class) {
|
|
|
+ // 编辑只会针对班级人数进行修改。
|
|
|
+ const _class = await this.clamodel.find({ termid: el.id, batchid: batchnum.id });
|
|
|
+ if (_class.length !== 0) {
|
|
|
+ for (const ee of _class) {
|
|
|
+ ee.number = batchnum.number;
|
|
|
+ await ee.save();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const classnum = batchnum.class;
|
|
|
+ for (let i = 1; i <= classnum; i++) {
|
|
|
+ const newdata = { name: i + '班', number: batchnum.number, batchid: batchnum.id, termid: el.id };
|
|
|
+ await this.clamodel.create(newdata);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
+ // 当班级数有更改时
|
|
|
+ // 删除所有班级 并重新生成班级
|
|
|
const classnum = batchnum.class;
|
|
|
for (let i = 1; i <= classnum; i++) {
|
|
|
const newdata = { name: i + '班', number: batchnum.number, batchid: batchnum.id, termid: el.id };
|
|
|
await this.clamodel.create(newdata);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|