From 14ba4ed9ece273a6cba29898806ea7d702f025b0 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Sun, 17 Feb 2019 19:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=B7=BB=E5=8A=A0=E6=95=99?= =?UTF-8?q?=E5=B8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/renshi/controller/Index.php | 49 +++++++++++++++++-- .../migrations/20181028023517_teacher.php | 6 +-- database/seeds/Rule.php | 16 +++++- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php index df4e736c..740324dc 100644 --- a/application/renshi/controller/Index.php +++ b/application/renshi/controller/Index.php @@ -261,16 +261,55 @@ class Index extends Base } // 删除标题行 - array_splice($stuinfo,0,3); + array_splice($teacherinfo,0,4 ); // 整理数据 $i = 0; - $teacher = array(); + $teacherlist = array(); - + foreach ($teacherinfo as $key => $value) { + // 如果姓名、性别、出生日期、全拼、首拼为空则跳过 + if(empty($value[1]) || empty($value[2]) || empty($value[3]) || empty($value[11]) || empty($value[12])) + { + continue; + } - - return json($data); + // 整理数据 + $teacherlist[$i]['xingming'] = $value[1]; + if($value[2] == '男') + { + $teacherlist[$i]['sex'] = 1; + }else if($value[2] == '女'){ + $teacherlist[$i]['sex'] = 0; + }else{ + $teacherlist[$i]['sex'] = 2; + } + $teacherlist[$i]['shengri'] = $value[3]; + $teacherlist[$i]['worktime'] = $value[4]; + $teacherlist[$i]['zhiwu'] = $value[5]; + $teacherlist[$i]['danwei'] = $list['school']; + $teacherlist[$i]['biey'] = $value[8]; + $teacherlist[$i]['zhuanye'] = $value[9]; + $teacherlist[$i]['xueli'] = $value[10]; + $teacherlist[$i]['quanpin'] = $value[11]; + $teacherlist[$i]['shoupin'] = $value[12]; + + $i++; + } + + + // 实例化学生信息数据模型 + $teacher = new Teacher(); + + // dump($teacherlist); + + // 保存或更新信息 + $data = $teacher->saveAll($teacherlist); + + // 返回添加结果 + $data ? $data = ['msg'=>'数据上传成功','val'=>true] : ['msg'=>'数据上传失败','val'=>false]; + + return json($data1); } diff --git a/database/migrations/20181028023517_teacher.php b/database/migrations/20181028023517_teacher.php index b687d17f..7a498be1 100644 --- a/database/migrations/20181028023517_teacher.php +++ b/database/migrations/20181028023517_teacher.php @@ -37,9 +37,9 @@ class Teacher extends Migrator ->addColumn('sex','boolean',['limit'=>1,'default'=>1,'null'=>false,'comment'=>'性别']) ->addColumn('shengri','integer',['limit'=>11,'null'=>true,'comment'=>'生日']) ->addColumn('worktime','integer',['limit'=>11,'null'=>true,'comment'=>'工作时间']) - ->addColumn('zhiwu','string',['limit'=>11,'null'=>true,'comment'=>'职务']) - ->addColumn('zhicheng','string',['limit'=>11,'null'=>true,'comment'=>'职称']) - ->addColumn('danwei','string',['limit'=>11,'null'=>false,'comment'=>'现工作单位']) + ->addColumn('zhiwu','integer',['limit'=>11,'null'=>true,'comment'=>'职务']) + ->addColumn('zhicheng','integer',['limit'=>11,'null'=>true,'comment'=>'职称']) + ->addColumn('danwei','integer',['limit'=>11,'null'=>false,'comment'=>'现工作单位']) ->addColumn('biye','string',['limit'=>50,'null'=>true,'comment'=>'毕业学校']) ->addColumn('zhuanye','string',['limit'=>20,'null'=>true,'comment'=>'专业']) ->addColumn('xueli','string',['limit'=>20,'null'=>true,'comment'=>'学历']) diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 1b4c9843..43e59062 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -60,7 +60,7 @@ class Rule extends Seeder ['id'=>801,'title'=>'单位荣誉','name'=>'rongyu/DwRongyu/index','paixu'=>1,'ismenu' =>true,'pid' =>8,'url'=>'/dwry',], ['id'=>802,'title'=>'教师荣誉册','name'=>'rongyu/JsRongyu/index','paixu'=>2,'ismenu' =>true,'pid' =>8,'url'=>'/jsry',], ['id'=>803,'title'=>'教师荣誉信息','name'=>'rongyu/JsRongyuInfo/index','paixu'=>3,'ismenu' =>true,'pid' =>8,'url'=>'/jsryinfo',], - ['id'=>804,'title'=>'学生荣誉','name'=>'rongyu/StuRongyu/index','paixu'=>7,'ismenu' =>true,'pid' =>8,'url'=>'/xsry',], + ['id'=>804,'title'=>'学生荣誉','name'=>'rongyu/StuRongyu/index','paixu'=>7,'ismenu' =>true,'pid' =>8,'url'=>'/xsry','status'=>0], @@ -176,6 +176,20 @@ class Rule extends Seeder ['title'=>'查看','name'=>'rongyu/DwRongyu/read','paixu'=>4,'pid'=>801,], ['title'=>'状态','name'=>'rongyu/DwRongyu/setStatus','paixu'=>5,'pid'=>801], ['title'=>'批量上传','name'=>'rongyu/DwRongyu/createAll','paixu'=>6,'pid'=>801], + // 教师荣誉册管理 + ['title'=>'添加','name'=>'rongyu/JsRongyu/create','paixu' =>1,'pid'=>801], + ['title'=>'删除','name'=>'rongyu/JsRongyu/delete','paixu'=>2,'pid'=>801], + ['title'=>'编辑','name'=>'rongyu/JsRongyu/edit','paixu'=>3,'pid'=>801,], + ['title'=>'查看','name'=>'rongyu/JsRongyu/read','paixu'=>4,'pid'=>801,], + ['title'=>'状态','name'=>'rongyu/JsRongyu/setStatus','paixu'=>5,'pid'=>801], + // 教师荣誉信息管理 + ['title'=>'添加','name'=>'rongyu/JsRongyuInfo/create','paixu' =>1,'pid'=>801], + ['title'=>'删除','name'=>'rongyu/JsRongyuInfo/delete','paixu'=>2,'pid'=>801], + ['title'=>'编辑','name'=>'rongyu/JsRongyuInfo/edit','paixu'=>3,'pid'=>801,], + ['title'=>'查看','name'=>'rongyu/JsRongyuInfo/read','paixu'=>4,'pid'=>801,], + ['title'=>'状态','name'=>'rongyu/JsRongyuInfo/setStatus','paixu'=>5,'pid'=>801], + ['title'=>'批量上传','name'=>'rongyu/JsRongyuInfo/createAll','paixu'=>6,'pid'=>801], + ];