select(); $count = $role->count(); $res = []; if($role){ $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; } } return json($res); } return View::fetch('role'); } //角色管理 public function role() { // return View::fetch('role'); } //角色添加 public function roleAdd() { if(Request::isAjax()){ $data = Request::param(); $result = AuthGroupModel::create($data); if($result) { $res = ['code'=>1,'msg'=>'添加成功']; } else { $res = ['code'=>0,'msg'=>'添加失败']; } return json($res); } $menus = $this->getMenus(); View::assign('menus',$menus); return View::fetch('roleadd'); } //角色编辑 public function roleEdit() { if(Request::isAjax()){ $data = Request::param(); /* if(!strpos($data['rules'],'1,2,3,4,5')) { $data['rules'] = substr_replace($data['rules'],"1,2,3,4,5,",0,0); } */ $rule = AuthGroupModel::update($data); if($rule){ $res = ['code'=>1,'msg'=>'保存成功']; } else { $res = ['code'=>1,'msg'=>'保存成功']; } return json($res); } $menus = $this->getMenus(); View::assign('menus',$menus); $authGroup = AuthGroupModel::select(); $auth = AuthGroupModel::find(input('id')); $ru = $auth->rules; View::assign(['authGroup'=>$authGroup,'auth'=>$auth,'ru'=>$ru]); return View::fetch('roleedit'); } }