创建角色js
This commit is contained in:
1 parent
9b3511851c
commit
bd00d57337
13 files changed
+508
-830
No files matched your search
@@ -26,6 +26,12 @@
|
||||
http://www.xiaoshongshu.cn
|
||||
帐号 test1 密码 123456
|
||||
|
||||
## 更新内容
|
||||
更新版本号 学生成绩统计系统v2.0 xadmin前端版
|
||||
更换前端显示,重新整理后端代码。
|
||||
升级提示
|
||||
修改 cj_system_base 表 title字段名冲突,修改为 webtitle
|
||||
|
||||
|
||||
## 更详细信息请查阅官方手册
|
||||
https://www.kancloud.cn/llblax/abcd/789222
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
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