|
@@ -23,6 +23,7 @@ class SchoolService extends CrudService {
|
|
|
const _filepath = this.ctx.app.config.baseUrl + filepath;
|
|
|
console.log(_filepath);
|
|
|
const studatas = await this.getImportXLSXData(_filepath, termid, schid);
|
|
|
+ console.log(studatas);
|
|
|
// 将得到的数据校验
|
|
|
const datacheck = await this.datacheck(studatas);
|
|
|
if (datacheck.errorcode === '1') {
|
|
@@ -47,7 +48,6 @@ class SchoolService extends CrudService {
|
|
|
const theadRule = [ sheet.A1.v, sheet.B1.v, sheet.C1.v, sheet.D1.v, sheet.E1.v, sheet.F1.v, sheet.G1.v, sheet.H1.v, sheet.I1.v, sheet.J1.v, sheet.K1.v, sheet.L1.v, sheet.M1.v, sheet.N1.v, sheet.O1.v, sheet.P1.v ];
|
|
|
const params = XLSX.utils.sheet_to_json(sheet); // 通过工具将表对象的数据读出来并转成json
|
|
|
// const theadRule = [ '序号', '姓名', '性别', '民族', '身份证号', '学校名称', '院系', '专业', '入学年份', '毕业年份', '在校曾担任何种职务', '手机号', 'QQ号', '家庭所在地', '家庭是否困难', '是否获得过助学金' ];
|
|
|
- console.log(params);
|
|
|
if (!params) return [];
|
|
|
let i = 0;
|
|
|
const length = params.length;
|
|
@@ -87,38 +87,35 @@ class SchoolService extends CrudService {
|
|
|
// 判断是否为空
|
|
|
if (!data.name) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '姓名不允许为空';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '姓名不允许为空,';
|
|
|
}
|
|
|
if (!data.gender) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '性别不允许为空';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '性别不允许为空,';
|
|
|
}
|
|
|
if (!data.id_number) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '身份证号不允许为空';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '身份证号不允许为空,';
|
|
|
}
|
|
|
if (!data.school_name) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '姓学校名称不允许为空';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '姓学校名称不允许为空,';
|
|
|
}
|
|
|
if (!data.phone) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '手机号不允许为空';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '手机号不允许为空,';
|
|
|
}
|
|
|
if (!/^\d{11}$/i.test(data.phone)) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '手机号不正确';
|
|
|
- errormsg.push(data);
|
|
|
+ data.msg = data.msg + '手机号不正确,';
|
|
|
+
|
|
|
}
|
|
|
const res = await this.model.findOne({ id_number: data.id_number });
|
|
|
if (res) {
|
|
|
errorcode = '1';
|
|
|
- data.msg = '学生已经存在请检查';
|
|
|
+ data.msg = data.msg + '学生已经存在请检查,';
|
|
|
+ }
|
|
|
+ if (errorcode === '1') {
|
|
|
errormsg.push(data);
|
|
|
}
|
|
|
}
|