|
@@ -703,7 +703,7 @@ class TrainplanService extends CrudService {
|
|
|
if (schoolList && schoolList.length > 0) {
|
|
|
schoolList = JSON.parse(JSON.stringify(schoolList));
|
|
|
schoolList = schoolList.map(i => {
|
|
|
- i.schnum = parseInt(i.code);
|
|
|
+ i.schnum = this.toParseInt(i.code);
|
|
|
return i;
|
|
|
});
|
|
|
schoolList = _.orderBy(schoolList, [ 'schnum' ], [ 'asc' ]);
|
|
@@ -727,7 +727,6 @@ class TrainplanService extends CrudService {
|
|
|
|
|
|
// 学校实际分配的计划, 先不管别的,先把计划的问题处理了
|
|
|
const reaFRes = schArrange.filter(f => f.schid === code);
|
|
|
-
|
|
|
// 过滤出来学校已经分配的数据后,需要知道是什么类型的
|
|
|
const reaObj = { total: 0, reaTotal: 0 }; // key:班级类型, value:为实际分配的人数
|
|
|
for (const rr of reaFRes) {
|
|
@@ -735,8 +734,8 @@ class TrainplanService extends CrudService {
|
|
|
const r = batchs.find(f => f._id === batchid);
|
|
|
if (r) {
|
|
|
const { type } = r;
|
|
|
- reaObj[type] = (parseInt(reaObj[type]) || 0) + parseInt(number); // 计划人数累加
|
|
|
- reaObj.reaTotal = _.add(parseInt(reaObj.reaTotal), parseInt(number)); // 实际人数累加
|
|
|
+ reaObj[type] = (this.toParseInt(reaObj[type]) || 0) + this.toParseInt(number); // 计划人数累加
|
|
|
+ reaObj.reaTotal = _.add(this.toParseInt(reaObj.reaTotal), this.toParseInt(number)); // 实际人数累加
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -754,10 +753,10 @@ class TrainplanService extends CrudService {
|
|
|
if (r) {
|
|
|
// 找到对应类型的计划了,计算这个班级类型是否分配完毕
|
|
|
const { number } = r;
|
|
|
- if (number) n = parseInt(number);
|
|
|
+ if (number) n = this.toParseInt(number);
|
|
|
}
|
|
|
// 用code去reaObj中提取实际分配的人数,就可以算处的值
|
|
|
- const rea = parseInt(reaObj[code]) || 0;
|
|
|
+ const rea = this.toParseInt(reaObj[code]) || 0;
|
|
|
let word = _.subtract(n - rea);
|
|
|
// n===0:表示原来计划里没有这个类型,word再为0,说明实际上也没有这个类型,就不需要显示了
|
|
|
if (n === 0 && word === 0) word = '';
|
|
@@ -801,7 +800,7 @@ class TrainplanService extends CrudService {
|
|
|
for (let i = 1; i <= colTotal; i++) {
|
|
|
const cmid = [];
|
|
|
for (const arr of result) {
|
|
|
- let number = parseInt(_.get(arr, i, 0));
|
|
|
+ let number = this.toParseInt(_.get(arr, i, 0));
|
|
|
if (_.isNaN(number)) number = 0;
|
|
|
cmid.push(number);
|
|
|
}
|
|
@@ -809,9 +808,16 @@ class TrainplanService extends CrudService {
|
|
|
count.push(colCount);
|
|
|
}
|
|
|
result.push(count);
|
|
|
+ console.log(result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ toParseInt(number) {
|
|
|
+ let num = parseInt(number);
|
|
|
+ if (_.isNaN(num)) num = 0;
|
|
|
+ return num;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取批次列表(排完顺序了,直接拿出来)
|
|
|
* @param {Array} termnum 计划列表
|