user search
This commit is contained in:
parent
a85faacba8
commit
34ada257ea
@ -26,15 +26,19 @@ class User extends AdminController
|
|||||||
public function list()
|
public function list()
|
||||||
{
|
{
|
||||||
if(Request::isAjax()){
|
if(Request::isAjax()){
|
||||||
$user = Db::name('user')->where(['delete_time'=>0])->select();
|
$data = Request::only(['id','name','email','sex']);
|
||||||
|
$map = array_filter($data);
|
||||||
|
$user = Db::name('user')->where(['delete_time'=>0])->where($map)->order('id desc')->select();
|
||||||
$count = $user->count();
|
$count = $user->count();
|
||||||
$res = [];
|
$res = [];
|
||||||
if($user){
|
if($count){
|
||||||
$res = ['code'=>0,'msg'=>'','count'=>$count];
|
|
||||||
foreach($user as $k => $v){
|
foreach($user as $k => $v){
|
||||||
$data = ['id'=>$v['id'],'username'=>$v['name'],'avatar'=>$v['user_img'],'phone'=>$v['phone'],'email'=>$v['email'],'sex'=>$v['sex'],'ip'=>$v['last_login_ip'],'jointime'=>date("Y-m-d",$v['create_time']),'check'=>$v['status'],'auth'=>$v['auth']];
|
$data = ['id'=>$v['id'],'username'=>$v['name'],'avatar'=>$v['user_img'],'phone'=>$v['phone'],'email'=>$v['email'],'sex'=>$v['sex'],'ip'=>$v['last_login_ip'],'jointime'=>date("Y-m-d",$v['create_time']),'check'=>$v['status'],'auth'=>$v['auth']];
|
||||||
$res['data'][] = $data;
|
//$res['data'][] = $data;
|
||||||
|
$res = ['code'=>0,'msg'=>'','count'=>$count,'data'=>[$data]];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$res = ['code'=>-1,'msg'=>'没有查询结果!'];
|
||||||
}
|
}
|
||||||
return json($res);
|
return json($res);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">用户名</label>
|
<label class="layui-form-label">用户名</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="username" placeholder="请输入" autocomplete="off" class="layui-input">
|
<input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
@ -96,6 +96,27 @@
|
|||||||
//监听搜索
|
//监听搜索
|
||||||
form.on('submit(LAY-user-front-search)', function(data){
|
form.on('submit(LAY-user-front-search)', function(data){
|
||||||
var field = data.field;
|
var field = data.field;
|
||||||
|
console.log(field);
|
||||||
|
|
||||||
|
//提交 Ajax 成功后,静态更新表格中的数据
|
||||||
|
$.ajax({
|
||||||
|
type:"post",
|
||||||
|
url:"{:url('admin/user/list')}",
|
||||||
|
data:{"id":field.id,"name":field.name,"email":field.email,"sex":field.sex},
|
||||||
|
daType:"json",
|
||||||
|
success:function (data){
|
||||||
|
if (data.code == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
tiele:'搜索失败',
|
||||||
|
content:data.msg,
|
||||||
|
icon:5,
|
||||||
|
anim:6
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//执行重载
|
//执行重载
|
||||||
table.reload('LAY-user-manage', {
|
table.reload('LAY-user-manage', {
|
||||||
|
Loading…
Reference in New Issue
Block a user