|
@@ -413,7 +413,7 @@ class StudentService extends CrudService {
|
|
|
}
|
|
|
|
|
|
// 导出学生 目前:拓展训练保险用
|
|
|
- async exportStudent({ insurance = true, ...data }) {
|
|
|
+ async exportStudent({ type = 'insurance', ...data }) {
|
|
|
let { data: studentList } = await this.query(data);
|
|
|
studentList = JSON.parse(JSON.stringify(studentList));
|
|
|
let ids = studentList.map(i => i.classid);
|
|
@@ -423,7 +423,7 @@ class StudentService extends CrudService {
|
|
|
for (const id of ids) {
|
|
|
const cla = await this.ctx.service.class.fetch({ id });
|
|
|
if (!cla) continue;
|
|
|
- if (insurance) { cla.date = moment(cla.startdate).add(1, 'd').format('YYYY-MM-DD'); }
|
|
|
+ if (type !== 'insurance') { cla.date = moment(cla.startdate).add(1, 'd').format('YYYY-MM-DD'); }
|
|
|
classList.push(cla);
|
|
|
}
|
|
|
studentList = studentList.map(i => {
|
|
@@ -431,25 +431,20 @@ class StudentService extends CrudService {
|
|
|
if (c) i.date = c.date;
|
|
|
return i;
|
|
|
});
|
|
|
- const meta = this.metaBx();
|
|
|
+ const meta = this.metaBx(type);
|
|
|
let fn = '学生名单';
|
|
|
const head = _.head(classList);
|
|
|
if (head) fn = `${head.term}期-${head.batch}批${fn}`;
|
|
|
return await this.ctx.service.util.toExcel(studentList, meta, fn);
|
|
|
}
|
|
|
|
|
|
- metaBx() {
|
|
|
+ metaBx(type) {
|
|
|
const header = [
|
|
|
{
|
|
|
header: '姓名',
|
|
|
key: 'name',
|
|
|
width: 20,
|
|
|
},
|
|
|
- {
|
|
|
- header: '拓训日期',
|
|
|
- key: 'date',
|
|
|
- width: 20,
|
|
|
- },
|
|
|
{
|
|
|
header: '性别',
|
|
|
key: 'gender',
|
|
@@ -501,6 +496,13 @@ class StudentService extends CrudService {
|
|
|
width: 20,
|
|
|
},
|
|
|
];
|
|
|
+ if (type === 'insurance') {
|
|
|
+ header.splice(1, 0, {
|
|
|
+ header: '拓训日期',
|
|
|
+ key: 'date',
|
|
|
+ width: 20,
|
|
|
+ });
|
|
|
+ }
|
|
|
return header;
|
|
|
}
|
|
|
}
|