|
@@ -469,7 +469,7 @@ class StudentService extends CrudService {
|
|
|
number = 1;
|
|
|
}
|
|
|
|
|
|
- // 导出学生 目前:拓展训练保险用
|
|
|
+ // 导出学生
|
|
|
async exportStudent(body) {
|
|
|
let { model, ...data } = body;
|
|
|
// 整理model
|
|
@@ -488,7 +488,18 @@ class StudentService extends CrudService {
|
|
|
});
|
|
|
model = _.compact(model);
|
|
|
// 请求数据
|
|
|
- let { data: studentList } = await this.query(data);
|
|
|
+ // 修改条件,termid变成数组了,需要一个一个查出来
|
|
|
+ const { planid, termid, batchid, classid } = data;
|
|
|
+ const queryObject = { };
|
|
|
+ if (planid) queryObject.planid = planid;
|
|
|
+ if (batchid) queryObject.batchid = batchid;
|
|
|
+ if (classid) queryObject.classid = classid;
|
|
|
+ let studentList = [];
|
|
|
+ for (const t of termid) {
|
|
|
+ queryObject.termid = t;
|
|
|
+ const { data: stuList } = await this.query(queryObject);
|
|
|
+ studentList.push(...stuList);
|
|
|
+ }
|
|
|
studentList = JSON.parse(JSON.stringify(studentList));
|
|
|
let ids = studentList.map(i => i.classid);
|
|
|
ids = _.uniq(ids);
|
|
@@ -506,7 +517,6 @@ class StudentService extends CrudService {
|
|
|
}
|
|
|
let fn = '学生名单';
|
|
|
// 因为是递进下来, batchid和classid并列,并非递进
|
|
|
- const { planid, termid, batchid, classid } = data;
|
|
|
const trainPlanInfo = async (termid, batchid) => {
|
|
|
const trainPlan = await this.ctx.model.Trainplan.findOne({ 'termnum._id': ObjectId(termid) });
|
|
|
if (!trainPlan) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到年度计划信息');
|
|
@@ -541,7 +551,8 @@ class StudentService extends CrudService {
|
|
|
}
|
|
|
} else if (batchid) {
|
|
|
// 文件名称,期,批
|
|
|
- const obj = await trainPlanInfo(termid, batchid);
|
|
|
+ const tid = _.head(termid);
|
|
|
+ const obj = await trainPlanInfo(tid, batchid);
|
|
|
if (obj) {
|
|
|
const { term, batch } = obj;
|
|
|
if (batch) fn = `第${batch}批${fn}`;
|
|
@@ -549,10 +560,25 @@ class StudentService extends CrudService {
|
|
|
}
|
|
|
} else if (termid) {
|
|
|
// 文件名称: 期
|
|
|
- const obj = await trainPlanInfo(termid);
|
|
|
- if (obj) {
|
|
|
- const { term } = obj;
|
|
|
- if (term) fn = `第${term}期${fn}`;
|
|
|
+ if (termid.length === 1) {
|
|
|
+ const obj = await trainPlanInfo(_.head(termid));
|
|
|
+ if (obj) {
|
|
|
+ const { term } = obj;
|
|
|
+ if (term) fn = `第${term}期${fn}`;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let tStr = '';
|
|
|
+ for (let i = 0; i < termid.length; i++) {
|
|
|
+ const tid = termid[i];
|
|
|
+ const obj = await trainPlanInfo(tid);
|
|
|
+ if (obj) {
|
|
|
+ const { term } = obj;
|
|
|
+ if (term) {
|
|
|
+ if (i === 0) { tStr += `${term}期`; } else { tStr += `,${term}期`; }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fn = `${tStr}${fn}`;
|
|
|
}
|
|
|
} else if (planid) {
|
|
|
// 文件名称:该计划标题
|