From 5cdf54c4f51b6c9eac18193314a36688333c3eb8 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Mon, 22 Apr 2019 22:13:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E8=8D=A3=E8=AA=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/AuthGroup.php | 2 +- application/admin/controller/AuthRule.php | 2 +- application/admin/controller/Index.php | 2 +- application/kaoshi/controller/Index.php | 2 +- application/renshi/controller/Index.php | 2 +- application/renshi/controller/Student.php | 2 +- application/renshi/model/Student.php | 4 +- application/rongyu/controller/DwRongyu.php | 90 ++++++------ application/rongyu/model/DwRongyu.php | 43 +++--- application/rongyu/view/dw_rongyu/create.html | 134 ++++++++++++------ application/rongyu/view/dw_rongyu/index.html | 18 +-- application/system/controller/Category.php | 7 +- application/system/controller/School.php | 2 +- application/teach/controller/Banji.php | 2 +- application/teach/controller/Subject.php | 2 +- application/teach/controller/Xueqi.php | 2 +- 16 files changed, 180 insertions(+), 136 deletions(-) diff --git a/application/admin/controller/AuthGroup.php b/application/admin/controller/AuthGroup.php index 716f34c9..eb9b3798 100644 --- a/application/admin/controller/AuthGroup.php +++ b/application/admin/controller/AuthGroup.php @@ -47,7 +47,7 @@ class AuthGroup extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/admin/controller/AuthRule.php b/application/admin/controller/AuthRule.php index 1bfe66fe..921c9799 100644 --- a/application/admin/controller/AuthRule.php +++ b/application/admin/controller/AuthRule.php @@ -45,7 +45,7 @@ class AuthRule extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 1748f7b7..ea1a66aa 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -48,7 +48,7 @@ class Index extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/kaoshi/controller/Index.php b/application/kaoshi/controller/Index.php index 6822fce4..08c0f8bc 100644 --- a/application/kaoshi/controller/Index.php +++ b/application/kaoshi/controller/Index.php @@ -50,7 +50,7 @@ class Index extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php index 814f0243..f5a82079 100644 --- a/application/renshi/controller/Index.php +++ b/application/renshi/controller/Index.php @@ -58,7 +58,7 @@ class Index extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/renshi/controller/Student.php b/application/renshi/controller/Student.php index 8528d1b1..c0b89f2e 100644 --- a/application/renshi/controller/Student.php +++ b/application/renshi/controller/Student.php @@ -67,7 +67,7 @@ class Student extends Base $cnt = $data->count(); // 获取当前页数据 $limit_start = $src['page'] * $src['limit'] - $src['limit']; - $limit_length = $src['limit']-1; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); // 重组返回内容 diff --git a/application/renshi/model/Student.php b/application/renshi/model/Student.php index 5e25fc73..e6d0f3fd 100644 --- a/application/renshi/model/Student.php +++ b/application/renshi/model/Student.php @@ -57,8 +57,8 @@ class Student extends Base $searchval = $src['searchval']; - - $data = $this->order([$src['field'] =>$src['order']]) + $data = $this + ->order([$src['field'] =>$src['order']]) ->when(count($school)>0,function($query) use($school){ $query->where('school','in',$school); }) diff --git a/application/rongyu/controller/DwRongyu.php b/application/rongyu/controller/DwRongyu.php index ebf9b001..85950566 100644 --- a/application/rongyu/controller/DwRongyu.php +++ b/application/rongyu/controller/DwRongyu.php @@ -33,55 +33,41 @@ class DwRongyu extends Base */ public function ajaxData() { - // 获取DT的传值 - $getdt = request()->param(); + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1', + 'limit'=>'10', + 'field'=>'update_time', + 'order'=>'asc', + 'fzschool'=>array(), + 'hjschool'=>array(), + 'category'=>array(), + 'searchval'=>'' + ],'POST'); - //得到排序的方式 - $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']; - - //得到搜索的关键词 - $search = [ - 'hjschool'=>$getdt['hjschool'], - 'fzschool'=>$getdt['fzschool'], - 'category'=>$getdt['category'], - 'search'=>$getdt['search']['value'], - 'order'=>$order, - 'order_field'=>$order_field - ]; // 实例化 - $dwry = new dwry(); - - // 获取荣誉总数 - $cnt = $dwry->select()->count(); - - // 查询数据 - $data = $dwry->search($search); - $datacnt = $data->count(); + $dwry = new dwry; + // 查询要显示的数据 + $data = $dwry->search($src); + // 获取符合条件记录总数 + $cnt = $data->count(); // 获取当前页数据 + $limit_start = $src['page'] * $src['limit'] - $src['limit']; + $limit_length = $src['limit']; $data = $data->slice($limit_start,$limit_length); - - + // 重组返回内容 $data = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$datacnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; + return json($data); } @@ -93,13 +79,18 @@ class DwRongyu extends Base public function create() { // 设置页面标题 - $list['title'] = '添加单位荣誉'; + $list['set'] = array( + 'webtitle'=>'添加单位荣誉', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/dwry', + ); + // 模板赋值 $this->assign('list',$list); - // 渲染 - return $this->fetch(); + return $this->fetch('create'); } /** @@ -226,7 +217,7 @@ class DwRongyu extends Base public function edit($id) { // 获取学生信息 - $list = dwry::where('id',$id) + $list['data'] = dwry::where('id',$id) ->field('id,title,category,hjschool,fzshijian,fzschool,jiangxiang,url') ->with([ 'cyDwry'=>function($query){ @@ -238,9 +229,20 @@ class DwRongyu extends Base ]) ->find(); - $this->assign('list',$list); + // 设置页面标题 + $list['set'] = array( + 'webtitle'=>'编辑单位荣誉', + 'butname'=>'修改', + 'formpost'=>'PUT', + 'url'=>'/dwry/'.$id, + ); + + + // 模板赋值 + $this->assign('list',$list); + // 渲染 + return $this->fetch('create'); - return $this->fetch(); } /** diff --git a/application/rongyu/model/DwRongyu.php b/application/rongyu/model/DwRongyu.php index e3eccee1..b9350c61 100644 --- a/application/rongyu/model/DwRongyu.php +++ b/application/rongyu/model/DwRongyu.php @@ -8,29 +8,30 @@ use app\common\model\Base; class DwRongyu extends Base { //搜索单位获奖荣誉 - public function search($search) + public function search($src) { - // 获取参数 - $hjschool = $search['hjschool']; - $fzschool = $search['fzschool']; - $category = $search['category']; - $order_field = $search['order_field']; - $order = $search['order']; - $category = $search['category']; - $search = $search['search']; + // 整理变量 + // 获取参数 + $hjschool = $src['hjschool']; + $fzschool = $src['fzschool']; + $category = $src['category']; + $searchval = $src['searchval']; - $data = $this->order([$order_field =>$order]) - ->when(strlen($hjschool)>0,function($query) use($hjschool){ - $query->where('hjschool','in',$hjschool); + + // 查询数据 + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(count($hjschool)>0,function($query) use($hjschool){ + $query->where('hjschool','in',$hjschool); }) - ->when(strlen($fzschool)>0,function($query) use($fzschool){ - $query->where('fzschool','in',$fzschool); + ->when(count($fzschool)>0,function($query) use($fzschool){ + $query->where('fzschool','in',$fzschool); }) - ->when(strlen($category)>0,function($query) use($category){ - $query->where('category','in',$category); + ->when(count($category)>0,function($query) use($category){ + $query->where('category','in',$category); }) - ->when(strlen($search)>0,function($query) use($search){ - $query->where('title','like',$search); + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title|jiancheng','like','%'.$searchval.'%'); }) ->with( [ @@ -49,10 +50,8 @@ class DwRongyu extends Base ] ) ->append(['jibie']) - ->select(); - - - return $data; + ->select(); + return $data; } diff --git a/application/rongyu/view/dw_rongyu/create.html b/application/rongyu/view/dw_rongyu/create.html index c309e56f..6b3bac07 100644 --- a/application/rongyu/view/dw_rongyu/create.html +++ b/application/rongyu/view/dw_rongyu/create.html @@ -4,35 +4,41 @@
-
- +
+
+ +
+
-
-