diff --git a/application/admin/controller/AuthRule.php b/application/admin/controller/AuthRule.php index b5213beb..d03072e8 100644 --- a/application/admin/controller/AuthRule.php +++ b/application/admin/controller/AuthRule.php @@ -12,15 +12,11 @@ class AuthRule extends Base // 显示权限列表 public function index() { - - // 设置数据总数 - $list['count'] = AR::count(); - // 设置页面标题 - $list['title'] = '权限列表'; - + // 设置要给模板赋值的信息 + $list['webtitle'] = '权限列表'; // 模板赋值 - $this->assign('list', $list); + $this->assign('list',$list); // 渲染模板 return $this->fetch(); @@ -30,50 +26,33 @@ class AuthRule extends Base // 获取权限信息列表 public function ajaxData() { + // 获取参数 + $src = $this->request + ->only([ + 'page'=>'1' + ,'limit'=>'10' + ,'field'=>'id' + ,'order'=>'asc' + ,'searchval'=>'' + ],'POST'); - // 获取DT的传值 - $getdt = request()->param(); - - //得到排序的方式 - $order = $getdt['order'][0]['dir']; - //得到排序字段的下标 - $order_column = $getdt['order'][0]['column']; - //根据排序字段的下标得到排序字段 - $order_field = $getdt['columns'][$order_column]['data']; - //得到limit参数 - $limit_start = $getdt['start']; - $limit_length = $getdt['length']; - //得到搜索的关键词 - $search = $getdt['search']['value']; - - - // 获取记录集总数 - $cnt = AR::count(); - //查询数据 - $data =AR::field('id,title,name,condition,paixu,ismenu,font,status,pid') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->all(); - - - // 如果需要查询 - if($search){ - $data = AR::field('id,title,name,condition,paixu,ismenu,font,status,pid') - ->order([$order_field=>$order]) - ->limit($limit_start,$limit_length) - ->where('title|name|pid','like','%'.$search.'%') - ->all(); - } - - $datacnt = $data->count(); - - - + // 实例化 + $ar = new AR; + // 查询要显示的数据 + $data = $ar->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 = [ - 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 - 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) - 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'code'=> 0 , // ajax请求次数,作为标识符 + 'msg'=>"", // 获取到的结果数(每页显示数量) + 'count'=>$cnt, // 符合条件的总数据量 'data'=>$data, //获取到的数据结果 ]; diff --git a/application/admin/model/AuthRule.php b/application/admin/model/AuthRule.php index 9cfab476..f004ae00 100644 --- a/application/admin/model/AuthRule.php +++ b/application/admin/model/AuthRule.php @@ -22,19 +22,22 @@ class AuthRule extends Base } - // 获取全部权限列表 - public function all() + // 查询所有角色 + public function search($src) { - return $this - ->where('status',1) - ->where('pid',0) - ->with(['authCid'=>function($query){ - $query->with(['authCid'=>function($q){ - $q->field('id,title,pid,paixu'); - }])->field('id,title,pid,paixu'); + // 整理变量 + $searchval = $src['searchval']; + + // 查询数据 + $data = $this + ->order([$src['field'] =>$src['order']]) + ->when(strlen($searchval)>0,function($query) use($searchval){ + $query->where('title','like','%'.$searchval.'%'); + }) + ->with(['authPid'=>function($query){ + $query->field('id,title'); }]) - ->field('id,title,pid,paixu') - ->order(['paixu']) ->select(); + return $data; } } diff --git a/application/admin/view/auth_group/create.html b/application/admin/view/auth_group/create.html index 13dc5e88..855b624b 100644 --- a/application/admin/view/auth_group/create.html +++ b/application/admin/view/auth_group/create.html @@ -58,7 +58,7 @@ {$list.set.butname} - + {/block} {block name="myjs"} diff --git a/application/admin/view/auth_rule/create.html b/application/admin/view/auth_rule/create.html index 9f510017..c309e56f 100644 --- a/application/admin/view/auth_rule/create.html +++ b/application/admin/view/auth_rule/create.html @@ -1,113 +1,111 @@ {extend name="common@create" /} -{block name="formaa"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- - {php} $authrulemod = new app\admin\model\AuthRule; $pid = $authrulemod->getRule();{/php} - - -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
- - -
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
+ +{block name="form"} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {php} $category = getCategory(101);{/php} + +
+
+
+ +
+ {php} $category = getCategory(102);{/php} + +
+
+
+ +
+ {php} $category = getCategory(103);{/php} + +
+
+
+ +
+ +
+
+
+ +
+
{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/admin/view/auth_rule/edit.html b/application/admin/view/auth_rule/edit.html deleted file mode 100644 index ea45ceb5..00000000 --- a/application/admin/view/auth_rule/edit.html +++ /dev/null @@ -1,113 +0,0 @@ -{extend name="common@create" /} -{block name="formaa"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- - {php} $authrulemod = new app\admin\model\AuthRule; $pid = $authrulemod->getRule();{/php} - - -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- - -
-
- - -
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/admin/view/auth_rule/index.html b/application/admin/view/auth_rule/index.html index 8669c96e..18d91e85 100644 --- a/application/admin/view/auth_rule/index.html +++ b/application/admin/view/auth_rule/index.html @@ -1,130 +1,154 @@ + {extend name="common@list" /} -{block name="topnav"} - +{block name="jsset"} + {/block} -{block name="bouttons"} -
- - - - - 批量删除 - - - - - 添加权限 - - - - 共有数据:{$list.count} 条 - +{block name="nav"} + + 管理员管理 + 权限管理 + 权限列表 + +{/block} +{block name="search"} + {/block} -{block name="tables"} - - - - - - - - - - - - - - - - - -
名称规则表达式父级规则排序是否是菜单 菜单字体状态操作
- - +{block name="table"} +
{/block} {block name="myjs"} - + + + + {/block} \ No newline at end of file diff --git a/application/system/model/Category.php b/application/system/model/Category.php index f15645ab..d12f74fe 100644 --- a/application/system/model/Category.php +++ b/application/system/model/Category.php @@ -33,9 +33,6 @@ class Category extends Base // 查询数据 $data = $this ->order([$src['field'] =>$src['order']]) - // ->when(strlen($src['xingzhi'])>0,function($query) use($xingzhi){ - // $query->where('xingzhi','in',$xingzhi); - // }) ->when(strlen($pid)>0,function($query) use($pid){ $query->whereOr('pid','in',$pid); }) diff --git a/application/system/view/category/edit1.html b/application/system/view/category/edit1.html deleted file mode 100644 index 47a8ea8f..00000000 --- a/application/system/view/category/edit1.html +++ /dev/null @@ -1,68 +0,0 @@ -{extend name="common@create" /} -{block name="formaa"} - -
-
- -
- -
-
-
- -
- - {php} $ctp = getCategory();{/php} - - -
-
-
- -
- -
-
-
-
- -
-
-
-{/block} -{block name="yanzheng"} - -{/block} \ No newline at end of file diff --git a/application/system/view/category/index1.html b/application/system/view/category/index1.html deleted file mode 100644 index f2c1ab80..00000000 --- a/application/system/view/category/index1.html +++ /dev/null @@ -1,122 +0,0 @@ -{extend name="common@list" /} -{block name="topnav"} - -{/block} -{block name="bouttons"} -
- - - - - 批量删除 - - - - - 添加类别 - - - - 共有数据:{$list.count} 条 - -
-{/block} -{block name="tables"} - - - - - - - - - - - - - -
名称父级类别排序状态操作
- - -{/block} -{block name="myjs"} - -{/block} \ No newline at end of file diff --git a/database/migrations/20181010075553_auth_rule.php b/database/migrations/20181010075553_auth_rule.php index d45a65bf..71fc80bd 100644 --- a/database/migrations/20181010075553_auth_rule.php +++ b/database/migrations/20181010075553_auth_rule.php @@ -35,7 +35,6 @@ class AuthRule extends Migrator $table ->addColumn('name','string',['limit'=>80,'null'=>false,'comment'=>'规则唯一标识']) ->addColumn('title','string',['limit'=>80,'null'=>false,'comment'=>'规则中文名']) - ->addColumn('type','boolean',['default'=>false,'null'=>true,'comment'=>'']) ->addColumn('status','boolean',['default'=>true,'null'=>false,'comment'=>'规则状态']) ->addColumn('condition','string',['limit'=>100,'null'=>true,'comment'=>'规则表达式']) ->addColumn('paixu','integer',['limit'=>11,'default'=>999,'null'=>false,'comment'=>'排序'])