尝试修改学生名单方式

This commit is contained in:
win7 committed 2019-12-20 17:02:09 +08:00
1 parent b02efc84b5
commit 7a7b7a0c81
5 files changed
+75 -12

No files matched your search

+30 -1
View File
@@ -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;
}
+41 -7
View File
@@ -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;
+1 -1
View File
@@ -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'); # 批量保存
});
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more