From 7a7b7a0c814f085f0822a3fb17a76c0e9c3bdf7a Mon Sep 17 00:00:00 2001 From: win7 Date: Fri, 20 Dec 2019 17:02:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E6=94=B9=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=90=8D=E5=8D=95=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/renshi/common.php | 31 ++++++++++++++++++- app/renshi/controller/Student.php | 48 +++++++++++++++++++++++++----- app/renshi/route/renshi.php | 2 +- app/renshi/view/student/index.html | 4 +-- database/seeds/Rule.php | 2 +- 5 files changed, 75 insertions(+), 12 deletions(-) diff --git a/app/renshi/common.php b/app/renshi/common.php index 7ae1c79f..214a917c 100644 --- a/app/renshi/common.php +++ b/app/renshi/common.php @@ -89,6 +89,35 @@ function smDownload($url,$newname='') flush(); readfile($file); exit; - } + } } + + +/** +* 将“一年级一班”格式的班级名转换成入学年和班级排序 +* $str是原文件格式 +* $data['ruxuenian'=>'',paixu=>''] +*/ +function strBjmArray($str) +{ + + if(stristr($str,'年级',true)==false || stristr($str,'班',true)==false) + { + $data = array('ruxuenian'=>'','paixu'=>''); + return $data; + } + + + // 获取年级、班级列表 + $njlist = nianjiList(); + $bjlist = banjinamelist(); + + $nj = substr($str,0,9); + $bj = substr($str,9,strlen($str)-9); + + $data['ruxuenian'] = array_search($nj,$njlist); + $data['paixu'] = array_search($bj, $bjlist); + + return $data; +} \ No newline at end of file diff --git a/app/renshi/controller/Student.php b/app/renshi/controller/Student.php index 6cecb122..801be5c3 100644 --- a/app/renshi/controller/Student.php +++ b/app/renshi/controller/Student.php @@ -397,10 +397,10 @@ class Student extends BaseController { // 设置页面标题 $list['set'] = array( - 'webtitle'=>'校对并删除学生信息', - 'butname'=>'校对删除', + 'webtitle'=>'校对学生名单', + 'butname'=>'校对', 'formpost'=>'POST', - 'url'=>'/renshi/student/jiaoduidel', + 'url'=>'/renshi/student/jiaoduixlsx', ); // 模板赋值 @@ -411,7 +411,7 @@ class Student extends BaseController // 使用上传的表格进行校对,表格中不存在的数据删除 - public function jiaoduiDel() + public function jiaoduiXlsx() { // 获取表单数据 $list = request()->only(['school','url'],'post'); @@ -423,7 +423,7 @@ class Student extends BaseController $stuinfo = $excel->readXls(public_path().'public\\uploads\\'.$list['url']); // 判断表格是否正确 - if($stuinfo[0][0] != "学生信息上传模板" ) + if($stuinfo[0][2] != "序号" && $stuinfo[1][2] != "姓名" && $stuinfo[2][2] != "身份证号") { $data = array('msg'=>'请使用模板上传','val'=>0,'url'=>null); return json($data); @@ -432,10 +432,44 @@ class Student extends BaseController // 删除标题行 array_splice($stuinfo,0,3); + $bj = array_column($stuinfo, 3); + $bj = array_unique($bj); + foreach ($bj as $key => $value) { + if($value==null) + { + unset($bj[$key]); + }else{ + $bj[$key] = strBjmArray($value); + } + } + // 实例化班级数据模型 $banji = new \app\teach\model\Banji; - $njlist = nianjilist(); - $bjlist = banjinamelist(); + + $djdata=array(); + foreach ($bj as $key => $value) { + $bjid = ''; + foreach ($stuinfo as $k => $val) { + // 如果姓名、身份证号为空则跳过 + if(empty($value[1]) || empty($value[2])) + { + $djdata[] = [ + 'row'=>$k, + 'msg'=>'缺少信息' + ]; + } + } + + + + + + + + } + + halt('aa'); + $i = 0; diff --git a/app/renshi/route/renshi.php b/app/renshi/route/renshi.php index 450df2f4..0150ebc8 100644 --- a/app/renshi/route/renshi.php +++ b/app/renshi/route/renshi.php @@ -25,7 +25,7 @@ Route::group('student', function () { Route::rule('createall','student/createAll','get'); # 批量导入 Route::rule('saveall','student/saveAll','post'); # 批量保存 Route::rule('jiaodui','student/jiaoDui','get'); # 批量保存 - Route::rule('jiaoduidel','student/jiaoduiDel','post'); # 批量保存 + Route::rule('jiaoduixlsx','student/jiaoduiXlsx','post'); # 批量保存 Route::rule('download','student/download','get'); # 批量保存 }); diff --git a/app/renshi/view/student/index.html b/app/renshi/view/student/index.html index ad9c14d2..0e6e6b78 100644 --- a/app/renshi/view/student/index.html +++ b/app/renshi/view/student/index.html @@ -135,8 +135,8 @@ window.open("/renshi/student/download"); break; case 'jdsc': - layer.msg('这个操作很危险,暂时不开放'); - break; + // layer.msg('这个操作很危险,暂时不开放'); + // break; cjgl.add('校对删除','student/jiaodui'); break; }; diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index b9efafa2..6cf54b1b 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -126,7 +126,7 @@ class Rule extends Seeder ['title'=>'批量上传','name'=>'renshi/Student/createAll','paixu'=>9,'pid'=>401], ['title'=>'批量保存','name'=>'renshi/Student/saveAll','paixu'=>10,'pid'=>401], ['title'=>'校对','name'=>'renshi/Student/jiaodui','paixu'=>11,'pid'=>401], - ['title'=>'校对删除','name'=>'renshi/Student/jiaoduiDel','paixu'=>12,'pid'=>401], + ['title'=>'校对删除','name'=>'renshi/Student/jiaoduiXlsx','paixu'=>12,'pid'=>401], // 教师管理权限 ['title'=>'添加','name'=>'renshi/Teacher/create','paixu' =>1,'pid'=>402],