创建角色js
This commit is contained in:
1 parent
9b3511851c
commit
bd00d57337
13 files changed
+508
-830
No files matched your search
@@ -14,68 +14,48 @@ class AuthGroup extends Base
|
||||
public function index()
|
||||
{
|
||||
|
||||
// 设置数据总数
|
||||
$list['count'] = AG::count();
|
||||
// 设置页面标题
|
||||
$list['title'] = '角色列表';
|
||||
|
||||
// 设置要给模板赋值的信息
|
||||
$list['webtitle'] = '角色列表';
|
||||
|
||||
// 模板赋值
|
||||
$this->assign('list', $list);
|
||||
$this->assign('list',$list);
|
||||
|
||||
// 渲染模板
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 获取角色列表
|
||||
public function ajaxData()
|
||||
{
|
||||
|
||||
// 获取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'];
|
||||
// 获取参数
|
||||
$src = $this->request
|
||||
->only([
|
||||
'page'=>'1',
|
||||
'limit'=>'10',
|
||||
'field'=>'id',
|
||||
'order'=>'asc',
|
||||
'searchval'=>''
|
||||
],'POST');
|
||||
|
||||
|
||||
// 获取记录集总数
|
||||
$cnt = AG::count();
|
||||
//查询数据
|
||||
$data = AG::field('id,title,miaoshu,status')
|
||||
->order([$order_field=>$order])
|
||||
->limit($limit_start,$limit_length)
|
||||
->all();
|
||||
|
||||
|
||||
// 如果需要查询
|
||||
if($search){
|
||||
$data = AG::field('id,title,miaoshu,status')
|
||||
->order([$order_field=>$order])
|
||||
->limit($limit_start,$limit_length)
|
||||
->where('title|miaoshu','like','%'.$search.'%')
|
||||
->all();
|
||||
}
|
||||
|
||||
$datacnt = $data->count();
|
||||
|
||||
|
||||
|
||||
// 实例化
|
||||
$ag = new AG;
|
||||
|
||||
// 查询要显示的数据
|
||||
$data = $ag->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, //获取到的数据结果
|
||||
];
|
||||
|
||||
@@ -83,12 +63,17 @@ class AuthGroup extends Base
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 创建角色
|
||||
public function create()
|
||||
{
|
||||
// 设置页面标题
|
||||
$list['title'] = '添加角色';
|
||||
$list['set'] = array(
|
||||
'webtitle'=>'添加角色',
|
||||
'butname'=>'添加',
|
||||
'formpost'=>'POST',
|
||||
'url'=>'/authgroup',
|
||||
);
|
||||
|
||||
|
||||
// 模板赋值
|
||||
$this->assign('list',$list);
|
||||
@@ -96,7 +81,6 @@ class AuthGroup extends Base
|
||||
// 渲染
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 保存角色信息
|
||||
@@ -236,4 +220,6 @@ class AuthGroup extends Base
|
||||
// 返回信息
|
||||
return json($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user