|
@@ -66,7 +66,8 @@ class TrainplanService extends CrudService {
|
|
|
if (res) {
|
|
|
if (status === '1') {
|
|
|
|
|
|
- await this.autoclass(res, trainplanold);
|
|
|
+
|
|
|
+ await this.autoclassNew(res, trainplanold);
|
|
|
|
|
|
|
|
|
|
|
@@ -99,6 +100,22 @@ class TrainplanService extends CrudService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ async autoclassNew(res) {
|
|
|
+
|
|
|
+ await this.clamodel.deleteMany({ planid: res.id });
|
|
|
+
|
|
|
+ for (const term of res.termnum) {
|
|
|
+ for (const batch of term.batchnum) {
|
|
|
+ const classs = await batch.class;
|
|
|
+ for (const cla of classs) {
|
|
|
+ const newdata = { name: cla.name, number: cla.number, batchid: batch.id, termid: term.id, planid: res.id, type: cla.type, headteacherid: cla.headteacherid };
|
|
|
+ await this.clamodel.create(newdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
async autoclass(res, trainplanold) {
|
|
|
|