创建角色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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,5 +7,20 @@ use app\common\model\Base;
|
||||
|
||||
class AuthGroup extends Base
|
||||
{
|
||||
// 状态获取器
|
||||
// 查询所有角色
|
||||
public function search($src)
|
||||
{
|
||||
// 整理变量
|
||||
$searchval = $src['searchval'];
|
||||
|
||||
// 查询数据
|
||||
$data = $this
|
||||
->order([$src['field'] =>$src['order']])
|
||||
->when(strlen($searchval)>0,function($query) use($searchval){
|
||||
$query->where('title','like','%'.$searchval.'%');
|
||||
})
|
||||
->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,56 +15,26 @@ class AuthRule extends Base
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 子菜单数据模型关联
|
||||
public function authCid()
|
||||
{
|
||||
return $this->hasMany('AuthRule','pid','id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// // 顶级权限列表
|
||||
// public function getRule($pid = 0)
|
||||
// {
|
||||
// return $this
|
||||
// ->where('pid',$pid)
|
||||
// ->where('status',1)
|
||||
// ->field('id,title')
|
||||
// ->order(['paixu'])
|
||||
// ->select();
|
||||
// }
|
||||
|
||||
|
||||
// // 是否是菜单获取器
|
||||
// public function getIsmenuAttr($value)
|
||||
// {
|
||||
// $arr = array('0'=>'否','1'=>'是');
|
||||
|
||||
// return $arr[$value];
|
||||
// }
|
||||
|
||||
|
||||
// // 父级菜单名获取器
|
||||
// public function getPidAttr($value)
|
||||
// {
|
||||
|
||||
// return $this->where('id',$value)->value('title');
|
||||
// }
|
||||
|
||||
|
||||
// // 获取二级菜单
|
||||
// public function getMymenuAttr($value)
|
||||
// {
|
||||
// return $this
|
||||
// ->where('pid',$this->getAttr('id'))
|
||||
// ->where('status&ismenu',1)
|
||||
// ->field('title,url,name')
|
||||
// ->order(['paixu'])
|
||||
// ->select();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// 获取全部权限列表
|
||||
public function all()
|
||||
{
|
||||
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');
|
||||
}])
|
||||
->field('id,title,pid,paixu')
|
||||
->order(['paixu'])
|
||||
->select();
|
||||
}
|
||||
}
|
||||
Loaded 3 of 13 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user