From 7775095b0f25d7e29ddc7c87a1066e513203eaae Mon Sep 17 00:00:00 2001 From: zhao Date: Fri, 21 Feb 2020 19:39:08 +0800 Subject: [PATCH] search --- app/admin/controller/Admin.php | 11 +- app/admin/controller/AuthGroup.php | 11 +- view/admin/admin/adminedit.html | 61 -------- view/admin/admin/adminform.html | 57 -------- view/admin/admin/index.html | 35 +++-- view/admin/admin/list.html | 226 ----------------------------- view/admin/auth_group/role.html | 45 ++++-- 7 files changed, 72 insertions(+), 374 deletions(-) delete mode 100644 view/admin/admin/adminedit.html delete mode 100644 view/admin/admin/adminform.html delete mode 100644 view/admin/admin/list.html diff --git a/app/admin/controller/Admin.php b/app/admin/controller/Admin.php index 2aac474..f60e53b 100644 --- a/app/admin/controller/Admin.php +++ b/app/admin/controller/Admin.php @@ -24,23 +24,30 @@ class Admin extends AdminController public function index() { if(Request::isAjax()){ + $data = Request::only(['id','username','mobile','email','auth_group_id']); + $map = array_filter($data); $admins = Db::name('admin') ->alias('a') ->join('auth_group u','a.auth_group_id = u.id') - ->field('a.id as aid,username,mobile,email,title,last_login_ip,a.status as astatus,last_login_time') + ->field('a.id as aid,username,mobile,email,auth_group_id,title,last_login_ip,a.status as astatus,last_login_time') ->where('a.delete_time',0) + ->where($map) ->select(); $count = $admins->count(); - if($admins){ + if($count){ $res = ['code'=>0,'msg'=>'','count'=>$count]; foreach($admins as $k => $v){ $data = ['id'=>$v['aid'],'loginname'=>$v['username'],'telphone'=>$v['mobile'],'email'=>$v['email'],'role'=>$v['title'],'ip'=>$v['last_login_ip'],'check'=>$v['astatus'],'logintime'=>date("Y-m-d",$v['last_login_time'])]; $res['data'][] = $data; } + } else { + $res = ['code'=>-1,'msg'=>'没有查询结果!']; } return json($res); } + $authGroup = Db::name('auth_group')->field('id,title')->select(); + View::assign('authGroup',$authGroup); return View::fetch(); } diff --git a/app/admin/controller/AuthGroup.php b/app/admin/controller/AuthGroup.php index 1767c21..86282fd 100644 --- a/app/admin/controller/AuthGroup.php +++ b/app/admin/controller/AuthGroup.php @@ -23,19 +23,26 @@ class AuthGroup extends AdminController //角色 public function list() { + if(Request::isAjax()){ - $role = Db::name('auth_group')->select(); + $data = Request::only(['id']); + $map = array_filter($data); + $role = Db::name('auth_group')->field('id,title,limits,descr,status')->where('status',1)->where($map)->select(); $count = $role->count(); $res = []; - if($role){ + if($count){ $res = ['code'=>0,'msg'=>'','count'=>$count]; foreach($role as $k => $v){ $data = ['id'=>$v['id'],'rolename'=>$v['title'],'limits'=>$v['limits'],'descr'=>$v['descr'],'check'=>$v['status']]; $res['data'][] = $data; } + } else { + $res = ['code'=>-1,'msg'=>'没有查询结果!']; } return json($res); } + $roles = Db::name('auth_group')->field('id,title')->where('status',1)->select(); + View::assign('roles',$roles); return View::fetch('role'); } diff --git a/view/admin/admin/adminedit.html b/view/admin/admin/adminedit.html deleted file mode 100644 index 1a42838..0000000 --- a/view/admin/admin/adminedit.html +++ /dev/null @@ -1,61 +0,0 @@ - -{extend name="public:base" /} - -{block name="body"} - -
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -{/block} -{block name="js"} - -{/block} \ No newline at end of file diff --git a/view/admin/admin/adminform.html b/view/admin/admin/adminform.html deleted file mode 100644 index f773449..0000000 --- a/view/admin/admin/adminform.html +++ /dev/null @@ -1,57 +0,0 @@ - -{extend name="public:base" /} - -{block name="body"} - -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -{/block} -{block name="js"} - -{/block} \ No newline at end of file diff --git a/view/admin/admin/index.html b/view/admin/admin/index.html index 738eb56..c610711 100644 --- a/view/admin/admin/index.html +++ b/view/admin/admin/index.html @@ -8,13 +8,13 @@
- +
- +
@@ -26,14 +26,11 @@
- + + {volist name="authGroup" id="vo"} + + {/volist}
@@ -94,7 +91,23 @@ //监听搜索 form.on('submit(LAY-user-back-search)', function(data){ var field = data.field; - + $.ajax({ + type:"post", + url:"{:url('admin/admin/index')}", + data:{"id":field.id,"username":field.username,"mobile":field.mobile,"email":field.email,"auth_group_id":field.auth_group_id}, + daType:"json", + success:function (data){ + if (data.code == 0) { + + } else { + layer.open({ + content:data.msg, + icon:5, + anim:6 + }); + } + } + }); //执行重载 table.reload('LAY-user-back-manage', { where: field diff --git a/view/admin/admin/list.html b/view/admin/admin/list.html deleted file mode 100644 index a877812..0000000 --- a/view/admin/admin/list.html +++ /dev/null @@ -1,226 +0,0 @@ -{extend name="public:base" /} - -{block name="body"} -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
-
- -
-
- - -
- -
- - - -
-
-
- -{/block} -{block name="js"} - -{/block} diff --git a/view/admin/auth_group/role.html b/view/admin/auth_group/role.html index 5f1e0bf..4108fa8 100644 --- a/view/admin/auth_group/role.html +++ b/view/admin/auth_group/role.html @@ -10,15 +10,11 @@ 角色筛选
- + + {volist name="roles" id="vo"} + + {/volist}
@@ -55,12 +51,31 @@ //搜索角色 form.on('select(LAY-user-adminrole-type)', function(data){ - //执行重载 - table.reload('LAY-user-back-role', { - where: { - role: data.value - } - }); + console.log(data); + $.ajax({ + type:"post", + url:"{:url('admin/AuthGroup/list')}", + data:{"id":data.value}, + daType:"json", + success:function (data){ + if (data.code == 0) { + + } else { + layer.open({ + content:data.msg, + icon:5, + anim:6 + }); + } + } + }); + //执行重载 + table.reload('LAY-user-back-role', { + where: { + id: data.value + } + }); + }); //监听角色审核