diff --git a/.gitignore b/.gitignore index ab8be6e1..41227271 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ .env .DS_Store runtime/ -!/public/uploads/pic.jpg vendor/ diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php index f6f32f30..68f0778c 100644 --- a/application/renshi/controller/Index.php +++ b/application/renshi/controller/Index.php @@ -80,7 +80,7 @@ class Index extends Base { // 设置页面标题 $list['set'] = array( - 'webtitle'=>'添加老师', + 'webtitle'=>'添加教师', 'butname'=>'添加', 'formpost'=>'POST', 'url'=>'/teacher', @@ -179,7 +179,7 @@ class Index extends Base // 设置页面标题 $list['set'] = array( - 'webtitle'=>'编辑单位', + 'webtitle'=>'编辑教师', 'butname'=>'修改', 'formpost'=>'PUT', 'url'=>'/teacher/'.$id, diff --git a/application/renshi/controller/Student.php b/application/renshi/controller/Student.php index 6241dc7f..94d554bc 100644 --- a/application/renshi/controller/Student.php +++ b/application/renshi/controller/Student.php @@ -31,75 +31,41 @@ class Student extends Base // 获取学生信息列表 public function ajaxData() { - - // 获取DT的传值 - $getdt = request()->param(); - - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['name']; - if($order_field=='') - { - $order_field = $getdt['columns'][$order_column]['data']; - } - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - $banji = $getdt['banji']; - - //处理入学年 - if(empty($getdt['ruxuenian'])) - { - $njlist = nianjiList(); - $njnum = array_keys($njlist); - }else{ - $njnum = $getdt['ruxuenian']; - } - - // 获取班级id - - $bj = new \app\teach\model\Banji; - $bjlist = $bj->where('ruxuenian','in',$njnum) - ->when(!empty($banji),function($query) use($banji){ - $query->where('paixu','in',$banji); - }) - ->column('id'); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'asc', + 'school'=>array(), + 'nianji'=>array(), + 'banji'=>array(), + 'searchval'=>'' + ],'POST'); - //得到搜索的关键词 - $search = [ - 'school'=>$getdt['school'], - 'banji'=>$bjlist, - 'order'=>$order, - 'order_field'=>$order_field, - 'search'=>$getdt['search']['value'] - ]; - - - // 实例化学生数据模型 + // 实例化 $stu = new STU; - // 筛选数据 - $data = $stu->searchMany($search); - //获取数据总数 + // 查询要显示的数据 + $data = $stu->search($src); + // 获取符合条件记录总数 $cnt = $data->count(); // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']-1; $data = $data->slice($limit_start,$limit_length); - // 获取本页数据总数 - $datacnt = $data->count(); - //追加属性 - $data = $data->append(['stu_school.title','stu_banji.title','age']); - // 组合返回数据 + + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } @@ -109,13 +75,17 @@ class Student extends Base public function create() { // 设置页面标题 - $list['title'] = '添加学生'; + $list['set'] = array( + 'webtitle'=>'添加学生', + 'butname'=>'添加', + 'formpost'=>'POOST', + 'url'=>'/student', + ); // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } @@ -166,13 +136,21 @@ class Student extends Base { // 获取学生信息 - $list = STU::field('id,xingming,sex,shenfenzhenghao,shengri,banji,school,status') - ->get($id); + $list['data'] = STU::field('id,xingming,sex,shenfenzhenghao,shengri,banji,school,status') + ->find($id); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑学生', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/sutdent/'.$id, + ); + // 模板赋值 $this->assign('list',$list); - - return $this->fetch(); + // 渲染 + return $this->fetch('create'); } diff --git a/application/renshi/model/Student.php b/application/renshi/model/Student.php index cbf6df67..449bb22d 100644 --- a/application/renshi/model/Student.php +++ b/application/renshi/model/Student.php @@ -52,14 +52,9 @@ class Student extends Base return $sex[$value]; } - // // 获取入学年 - // public function getNianjiAttr() - // { - // return $this->stuBanji()->ruxuenian; - // } // 数据筛选 - public function searchMany($search) + public function search($src) { // 设置变量 $schoolid = $search['school']; @@ -67,11 +62,15 @@ class Student extends Base $order = $search['order']; $order_field = $search['order_field']; $search = $search['search']; + // 获取参数 + $school = $src['school']; + $banji = $src['banji']; + $searchval = $src['searchval']; - $data = $this->field('id,xingming,sex,shengri,banji,school,status') - ->when(strlen($schoolid)>0,function($query) use($schoolid){ + $data = $this->order([$src['field'] =>$src['order']]) + ->when(strlen($school)>0,function($query) use($schoolid){ $query->where('school','in',$schoolid); }) ->when(count($banji)>0,function($query) use($banji){ diff --git a/application/renshi/view/index/create_all1.html b/application/renshi/view/index/create_all1.html deleted file mode 100644 index d8ab4af3..00000000 --- a/application/renshi/view/index/create_all1.html +++ /dev/null @@ -1,195 +0,0 @@ -{extend name="common@create" /} -{block name="mycss"} -{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.css" /} -{/block} -{block name="formaa"} -
- -{/block} -{block name="yanzheng"} -{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.js"} - -{/block} \ No newline at end of file diff --git a/application/renshi/view/index/edit.html b/application/renshi/view/index/edit.html deleted file mode 100644 index ffaf779f..00000000 --- a/application/renshi/view/index/edit.html +++ /dev/null @@ -1,176 +0,0 @@ -{extend name="common@create" /} -{block name="formaa"} - -{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/renshi/view/student/create.html b/application/renshi/view/student/create.html index c0399ab9..045826d4 100644 --- a/application/renshi/view/student/create.html +++ b/application/renshi/view/student/create.html @@ -1,5 +1,8 @@ {extend name="common@create" /} {block name="formaa"} + + +