Ver Fonte

上传名单,字段检测bug

lrf402788946 há 3 anos atrás
pai
commit
2663be8e61
1 ficheiros alterados com 3 adições e 3 exclusões
  1. 3 3
      app/service/school.js

+ 3 - 3
app/service/school.js

@@ -226,6 +226,7 @@ class SchoolService extends CrudService {
     const headRow = worksheet.getRow(1);
     // 设置,检查表头
     headRow.eachCell((cell, coli) => {
+      console.log(cell.value);
       if (cell.value !== '序号') {
         const r = cols.find(f => f.key === cell.value);
         if (r) {
@@ -237,11 +238,10 @@ class SchoolService extends CrudService {
           throw new BusinessError(`模板中"${cell.value}"列错误,请检查excel!`);
         }
       }
-
     });
     // 检查表头结果,如果有没有 colIndex,说明表头里有不符合要求的,退回去
-    const excelIsRigth = cols.find(f => f.colIndex);
-    if (!excelIsRigth) throw new BusinessError(ErrorCode.DATA_INVALID, 'Excel表格格式不正确,请使用系统提供的模板!');
+    const excelIsRigth = cols.every(f => f.colIndex);
+    if (!excelIsRigth) throw new BusinessError(ErrorCode.DATA_INVALID, 'Excel表格格式不正确,请使用系统提供的模板,或重新下载模板!');
     // 删除掉第一行 表头行,这不是数据
     worksheet.spliceRows(0, 1);
     const stuList = [];