adminInfo = get_login_admin(); $this->category_id=165; $this->url=[ '/admin/nk.feedback/index?category_id='.$this->category_id, '/admin/nk.feedback/add', '/admin/nk.feedback/edit', '/admin/nk.feedback/del', '/admin/nk.feedback/read', ]; } /** * 查看 */ public function index() { if (request()->isAjax()) { $params = get_params(); $where[]= ['status','=',1]; if (isset($params['keywords']) && !empty($params['keywords'])){ $where[]=['title','like','%'.$params['keywords'].'%']; } if($this->adminInfo['position_id'] != 1){ //不是超级管理员 $www['admin_id'] = $this->adminInfo['id']; $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); if ($user_address) { if ($user_address['auth_range'] == 1) { $where[]= ['county','=',$user_address['area_id']]; $where[] =['township','=', $user_address['street_id']]; $where[] =['village','=', $user_address['village_id']]; } elseif ($user_address['auth_range'] == 2) { $where[]= ['county','=',$user_address['area_id']]; $where[] =['township','=', $user_address['street_id']]; } } } $category_id =$params['category_id']; if($category_id){ $map[] = ['category_id','in',$category_id]; }else{ $map = []; } $total = Db::table('fa_article') ->where($where) ->where($map) ->count(); $list = Db::table('fa_article') ->withAttr('nickname',function ($value,$data){ return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name'); }) ->withAttr('area',function ($value,$data){ return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name'); }) ->withAttr('street',function ($value,$data){ return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name'); }) ->withAttr('village',function ($value,$data){ return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name'); }) ->where($where) ->where($map) ->page($params['page']) ->limit($params['limit']) ->order('id desc') ->field('id,title,user_id,content,is_solve,county,township,village,image,view_time') ->select(); $result = ['total' => $total, 'data' => $list]; return table_assign(0, '', $result); } View::assign('url', $this->url); return view(); } /** * 添加 */ public function add() { if (request()->isAjax()) { $params= get_params(); $params['category_id']=$this->category_id; (new Article())->add($params); }else{ View::assign('editor', get_system_config('other','editor')); View::assign('url', $this->url); // 获取用户信息 $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); View::assign('users', $this->users); $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) ->field('area_id id,area_code code,area_name name') ->select(); View::assign('street', $street); return view('nk/article/add'); } } /** * 修改 */ public function edit() { $params= get_params(); (new Article())->edit($params); return view('nk/article/edit',['url'=>$this->url]); } /** * 查看信息 */ public function read() { $param= get_params(); $id = isset($param['id']) ? $param['id'] : 0; $detail = Db::table('fa_article')->where('id',$id)->find(); if ($detail) { $detail['comment'] = Db::table('fa_article_comment') ->where('vote_id',$id) ->withAttr('user_info',function ($value,$data){ return Db::table('fa_szxc_information_usermsg')->where('user_id', $data['user_id'])->value('name'); }) ->select(); View::assign('detail', $detail); View::assign('admin_id', $this->adminInfo['id']); return view(); }else{ throw new \think\exception\HttpException(404, '找不到页面'); } } /** * 修改 */ public function del() { $params= get_params(); (new Article())->del($params); } }