diff --git a/application/system/controller/Category.php b/application/system/controller/Category.php index 7ef55f62..272ab01e 100644 --- a/application/system/controller/Category.php +++ b/application/system/controller/Category.php @@ -36,17 +36,21 @@ class Category extends Base 'limit'=>'10', 'field'=>'id', 'order'=>'asc', - 'xingzhi'=>'' + 'pid'=>'', + 'searchval'=>'' ],'POST'); // 实例化 $cg = new CG; - // 获取记录总数 - $cnt = $cg->count(); - // 查询要显示的数据 $data = $cg->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); // 重组返回内容 $data = [ @@ -56,7 +60,6 @@ class Category extends Base 'data'=>$data, //获取到的数据结果 ]; - return json($data); } @@ -66,7 +69,13 @@ class Category extends Base public function create() { // 设置页面标题 - $list['title'] = '添加类别'; + $list['set'] = array( + 'webtitle'=>'添加类别', + 'butname'=>'添加', + 'formpost'=>'POST', + 'url'=>'/category', + ); + // 模板赋值 $this->assign('list',$list); diff --git a/application/system/controller/School.php b/application/system/controller/School.php index cfce7da2..4d3cba05 100644 --- a/application/system/controller/School.php +++ b/application/system/controller/School.php @@ -33,7 +33,7 @@ class School extends Base 'limit'=>'10', 'field'=>'update_time', 'order'=>'asc', - 'xingzhi'=>[], + 'xingzhi'=>array(), 'searchval'=>'' ],'POST'); @@ -41,17 +41,20 @@ class School extends Base // 实例化 $sch = new sch; - // 获取记录总数 - $cnt = $sch->count(); - // 查询要显示的数据 $data = $sch->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); // 重组返回内容 $data = [ 'code'=> 0 , // ajax请求次数,作为标识符 'msg'=>"", // 获取到的结果数(每页显示数量) - 'count'=>$cnt, // 符合条件的总数据量 + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; diff --git a/application/system/model/Category.php b/application/system/model/Category.php index 99d24af4..f15645ab 100644 --- a/application/system/model/Category.php +++ b/application/system/model/Category.php @@ -27,7 +27,8 @@ class Category extends Base public function search($src) { // 整理变量 - // $xingzhi = $src['xingzhi']; + $pid = $src['pid']; + $searchval = $src['searchval']; // 查询数据 $data = $this @@ -35,12 +36,12 @@ class Category extends Base // ->when(strlen($src['xingzhi'])>0,function($query) use($xingzhi){ // $query->where('xingzhi','in',$xingzhi); // }) - // ->when(strlen($search)>0,function($query) use($search){ - // $query->where('title|jiancheng','like',$search); - // }) - // ->when(strlen($search)>0,function($query) use($search){ - // $query->where('title|jiancheng','like',$search); - // }) + ->when(strlen($pid)>0,function($query) use($pid){ + $query->whereOr('pid','in',$pid); + }) + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title','like','%'.$searchval.'%'); + }) ->with( [ 'glPid'=>function($query){ @@ -48,10 +49,7 @@ class Category extends Base } ] ) - ->page($src['page'],$src['limit']) ->select(); - - return $data; } } diff --git a/application/system/model/School.php b/application/system/model/School.php index 5b675c12..943b5a8c 100644 --- a/application/system/model/School.php +++ b/application/system/model/School.php @@ -64,7 +64,6 @@ class School extends Base }, ] ) - ->page($src['page'],$src['limit']) ->withCount( [ 'dwTeacher'=>function($query){ @@ -73,8 +72,6 @@ class School extends Base ] ) ->select(); - - return $data; } } diff --git a/application/system/view/category/create.html b/application/system/view/category/create.html index c309e56f..c035522e 100644 --- a/application/system/view/category/create.html +++ b/application/system/view/category/create.html @@ -4,7 +4,7 @@
- -
- -
-
-
- -
- -
-
-
- +
- {php} $category = getCategory(101);{/php} - {volist name="category" id="vo"}
-
- -
- {php} $category = getCategory(102);{/php} - -
-
-
- -
- {php} $category = getCategory(103);{/php} - -
-
+ autocomplete="off" class="layui-input" value="" placeholder="数字1-999">
diff --git a/application/system/view/category/index.html b/application/system/view/category/index.html index 06f34584..b2a2fd06 100644 --- a/application/system/view/category/index.html +++ b/application/system/view/category/index.html @@ -18,18 +18,18 @@
+ autocomplete="off" class="layui-input">
- -
- {php} $category = getCategory(101);{/php} - {volist name="category" id="vo"} - + +
+ + {php} $pid = getCategory(0);{/php} + {volist name="pid" id="vo"} + {/volist}
-
{/block} @@ -75,9 +75,14 @@