diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index 683af7e..1ef2ed7 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -50,6 +50,8 @@ class Login 'login_num' => $admin['login_num'] + 1, ]; Db::name('admin')->where(['id' => $admin['id']])->update($data); + $group_access=Db::name('admin_group_access')->where(['uid' => $admin['id']])->find(); + $admin['group_access']=$group_access['group_id']; $session_admin = get_config('app.session_admin'); Session::set($session_admin, $admin); $token = make_token(); diff --git a/app/admin/controller/nk/Article.php b/app/admin/controller/nk/Article.php index 22d2126..f7ccc9f 100644 --- a/app/admin/controller/nk/Article.php +++ b/app/admin/controller/nk/Article.php @@ -23,9 +23,7 @@ class Article extends BaseController public function index($params) { - $where=[ - 'status'=>1 - ]; + $where[]=['status','=',1]; if (isset($params['keywords'])){ $where[]=['title','like','%'.$params['keywords'].'%']; } @@ -75,6 +73,7 @@ class Article extends BaseController ->where($map) ->page($params['page']) ->limit($params['limit']) + ->order('id desc') ->field('id,title,user_id,county,township,village,image,view_time') ->select(); diff --git a/app/admin/controller/nk/Classroom.php b/app/admin/controller/nk/Classroom.php new file mode 100644 index 0000000..0a9db1a --- /dev/null +++ b/app/admin/controller/nk/Classroom.php @@ -0,0 +1,86 @@ +adminInfo = get_login_admin(); + $this->category_id=298; + $this->url=[ + '/admin/nk.classroom/index?category_id='.$this->category_id, + '/admin/nk.classroom/add', + '/admin/nk.classroom/edit', + '/admin/nk.classroom/del', + '/admin/nk.classroom/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + 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); + 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() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/Education.php b/app/admin/controller/nk/Education.php new file mode 100644 index 0000000..ab8935b --- /dev/null +++ b/app/admin/controller/nk/Education.php @@ -0,0 +1,86 @@ +adminInfo = get_login_admin(); + $this->category_id=299; + $this->url=[ + '/admin/nk.education/index?category_id='.$this->category_id, + '/admin/nk.education/add', + '/admin/nk.education/edit', + '/admin/nk.education/del', + '/admin/nk.education/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + 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); + 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() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/Profile.php b/app/admin/controller/nk/Profile.php new file mode 100644 index 0000000..9eb4668 --- /dev/null +++ b/app/admin/controller/nk/Profile.php @@ -0,0 +1,86 @@ +adminInfo = get_login_admin(); + $this->category_id=296; + $this->url=[ + '/admin/nk.profile/index?category_id='.$this->category_id, + '/admin/nk.profile/add', + '/admin/nk.profile/edit', + '/admin/nk.profile/del', + '/admin/nk.profile/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + 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); + 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() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/System.php b/app/admin/controller/nk/System.php new file mode 100644 index 0000000..4196e30 --- /dev/null +++ b/app/admin/controller/nk/System.php @@ -0,0 +1,86 @@ +adminInfo = get_login_admin(); + $this->category_id=297; + $this->url=[ + '/admin/nk.system/index?category_id='.$this->category_id, + '/admin/nk.system/add', + '/admin/nk.system/edit', + '/admin/nk.system/del', + '/admin/nk.system/read', + ]; + } + /** + * 查看 + */ + public function index() + { + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + /** + * 添加 + */ + 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); + 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() + { + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + + } + /** + * 修改 + */ + public function del() + { + $params= get_params(); + (new Article())->del($params); + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/User.php b/app/admin/controller/nk/User.php index 20b9dd1..bb2387c 100644 --- a/app/admin/controller/nk/User.php +++ b/app/admin/controller/nk/User.php @@ -36,17 +36,14 @@ class User extends BaseController if (request()->isAjax()) { $mmm = []; $post = get_params(); - if (!empty($post['filter'])) { - $a = json_decode($post['filter'], true); - foreach ($a as $k => $v) { - if ($k == 'name') { - $mmm[] = ['m.name', 'LIKE', '%' . $v . '%']; - } - if ($k == 'phone') { - $mmm[] = ['m.phone', 'LIKE', '%' . $v . '%']; - } - } + if (!empty($post['keywords'])) { + $mmm[] = ['m.name', 'LIKE', '%' . $post['keywords'] . '%']; } + if (!empty($post['phone'])) { + + $mmm[] = ['m.phone', 'LIKE', '%' . $post['phone'] . '%']; + } + //权限组信息 if ($this->adminInfo['position_id'] != 1) { $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['id'])->find(); @@ -65,17 +62,18 @@ class User extends BaseController $mmm['area_id'] = $post['area_id']; } if (isset($post['street_id']) && !empty($post['street_id'])) { - $mmm['street_id'] = $post['street_id'][0]['street_code']; + $mmm['street_id'] = $post['street_id']; } if (isset($post['village_id']) && !empty($post['village_id'])) { - $mmm['village_id'] = $post['village_id'][0]['village_id']; + $mmm['village_id'] = $post['village_id']; } if (isset($post['brigade_id']) && !empty($post['brigade_id'])) { - $mmm['brigade_id'] = $post['brigade_id'][0]['id']; + $mmm['brigade_id'] = $post['brigade_id']; } } //权限组信息 $total = Db::table('fa_szxc_information_usermsg') + ->alias('m') ->where($mmm) ->count(); $list = Db::table('fa_szxc_information_usermsg') @@ -177,6 +175,18 @@ class User extends BaseController //种植信息 $planting = Db::table('fa_szxc_information_planting')->where('user_id', $params['id']) ->find(); + $strlen = strlen($planting['breed_msg']); + if ($strlen != 0 || $strlen > 10) { + $planting['breed_msg'] = json_decode($planting['breed_msg'], true); + } + $strlen1 = strlen($planting['crops_msg']); + if ($strlen1 != 0 || $strlen1 > 10) { + $planting['crops_msg'] = json_decode($planting['crops_msg'], true); + } + $strlen2 = strlen($planting['tools_msg']); + if ($strlen2 != 0 || $strlen2 > 10) { + $planting['tools_msg'] = json_decode($planting['tools_msg'], true); + } //保险信息 $insurancearr = Db::table('fa_szxc_information_insurance')->where('user_id', $params['id'])->find(); //健康信息 @@ -243,6 +253,7 @@ class User extends BaseController public function postedit() { $params = get_params(); + halt($params); if ($params['type'] == 1) { unset($params['type']); $res = Db::table('fa_szxc_information_usermsg')->where('user_id', $params['user_id'])->update($params); @@ -255,10 +266,10 @@ class User extends BaseController if ($params['type'] == 2) { halt($params); unset($params['type']); - $find=Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find(); - if($find){ + $find = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find(); + if ($find) { $res = Db::table('fa_szxc_information_insurance')->where('id', $find['id'])->update($params); - }else{ + } else { $res = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->insert($params); } if ($res) { @@ -269,10 +280,10 @@ class User extends BaseController } if ($params['type'] == 3) { unset($params['type']); - $find=Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find(); - if($find){ + $find = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find(); + if ($find) { $res = Db::table('fa_szxc_information_insurance')->where('id', $find['id'])->update($params); - }else{ + } else { $res = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->insert($params); } if ($res) { @@ -283,10 +294,10 @@ class User extends BaseController } if ($params['type'] == 4) { unset($params['type']); - $find=Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->find(); - if($find){ + $find = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->find(); + if ($find) { $res = Db::table('fa_szxc_information_healthy')->where('id', $find['id'])->update($params); - }else{ + } else { $res = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->insert($params); } if ($res) { @@ -607,23 +618,25 @@ class User extends BaseController } } //权限组信息 + $groupwhere[] = ['id', 'in', 2, 4]; 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) { - $auth_range = [['name' => '村级', 'value' => '1']]; - } - if ($user_address['auth_range'] == 2) { - $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2']]; - } - if ($user_address['auth_range'] == 3) { - $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3']]; - } - if ($user_address['auth_range'] == 4) { - $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']]; - } + // $www['admin_id'] = $this->adminInfo['id']; + // $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + // if ($user_address) { + if ($this->adminInfo['group_access'] == 2) { + $auth_range = [['name' => '村级', 'value' => '1']]; + $groupwhere[] = ['id', 'in', 2]; } + if ($this->adminInfo['group_access'] == 4) { + $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2']]; + } + // if ($user_address['auth_range'] == 3) { + // $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3']]; + // } + // if ($user_address['auth_range'] == 4) { + // $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']]; + // } + // } } else { $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']]; } @@ -633,13 +646,12 @@ class User extends BaseController $brigade = Db::table('fa_geo_brigade') ->limit(30) ->select(); - //后端权限 - $groupdata = Db::table('fa_auth_group') - ->where('id', '<>', 1) + $groupdata = Db::name('admin_group') + ->where($groupwhere) ->limit(30) ->select(); - $groupdata[] = ['id' => 0, 'name' => '无后台权限']; + $groupdata[] = ['id' => 0, 'title' => '无后台权限']; //前端权限 $user_group = Db::table('fa_user_group') ->limit(30) @@ -657,6 +669,92 @@ class User extends BaseController return view(); } + public function tongji() + { + $post = get_params(); + $where = []; + //权限组信息 + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['user_id'])->find(); + if ($find) { + if ($find['auth_range'] == 1) { + $where['village_id'] = $find['village_id']; + } elseif ($find['auth_range'] == 2) { + $where['street_id'] = $find['street_id']; + } elseif ($find['auth_range'] == 3) { + $where['area_id'] = $find['area_id']; + } + } + + if ($post['village_id'] != '') { + $where['village_id'] = $post['village_id']; + } + if ($post['brigade_id'] != '') { + $where['brigade_id'] = $post['brigade_id']; + } + if ($post['street_id'] != '') { + $where['street_id'] = $post['street_id']; + } + $where['area_id'] = $post['area_id']; + // 大于60岁人数 + $old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count(); + // 儿童人数 + $children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count(); + // 未婚男 + $unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count(); + // 未婚女 + $unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count(); + + $land_area_num = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.land_area'); + + $sum_218 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=218')->sum('p.land_area'); + $sum_217 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=217')->sum('p.land_area'); + $sum_216 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=216')->sum('p.land_area'); + $sum_215 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=215')->sum('p.land_area'); + $sum_214 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=214')->sum('p.land_area'); + $sum_70 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=70')->sum('p.land_area'); + $sum_69 = Db::table('fa_szxc_information_useraddress') + ->alias('u') + ->where($where) + ->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.land_area'); + $result = [ + 'old_num' => $old_num, + 'children_num' => $children_num, + 'unmarried_man_num' => $unmarried_man_num, + 'unmarried_woman_num' => $unmarried_woman_num, + 'land_area_num' => $land_area_num, + 'sum_218' => $sum_218, + 'sum_217' => $sum_217, + 'sum_216' => $sum_216, + 'sum_215' => $sum_215, + 'sum_214' => $sum_214, + 'sum_70' => $sum_70, + 'sum_69' => $sum_69, + + ]; + $result = ['total' => 0, 'data' => $result]; + return table_assign(0, '', $result); + } /** * 修改 */ diff --git a/app/admin/view/nk/article/index.html b/app/admin/view/nk/article/index.html index 01497d7..65b9c11 100644 --- a/app/admin/view/nk/article/index.html +++ b/app/admin/view/nk/article/index.html @@ -5,7 +5,7 @@
- +
@@ -21,7 +21,7 @@ @@ -53,6 +53,22 @@ field: 'id', title: '编号', align: 'center', + width:120, + },{ + field: 'area', + title: '区县', + align: 'center', + width:120, + },{ + field: 'street', + title: '乡镇', + align: 'center', + width:120, + },{ + field: 'village', + title: '街道/村', + align: 'center', + width:120, },{ field: 'title', title: '文章标题', @@ -60,18 +76,6 @@ field: 'nickname', title: '用户', align: 'center', - },{ - field: 'area', - title: '区县', - align: 'center', - },{ - field: 'street', - title: '乡镇', - align: 'center', - },{ - field: 'village', - title: '街道/村', - align: 'center', },{ field: 'view_time', title: '发布时间', diff --git a/app/admin/view/nk/user/auths.html b/app/admin/view/nk/user/auths.html index 6e7f8de..f72951e 100644 --- a/app/admin/view/nk/user/auths.html +++ b/app/admin/view/nk/user/auths.html @@ -32,11 +32,19 @@
+ {if {:session('gougu_admin')['group_access']==1} + {else /} + {volist name='street' id='vo'} + {if $address.area_id==$vo.code} + + {/if} + {/volist} + {/if}
@@ -54,7 +62,7 @@
- {volist name='brigade' id='vo'} {/volist} @@ -64,9 +72,9 @@
- {volist name='groupdata' id='vo'} - + {/volist}
@@ -74,7 +82,7 @@
- {volist name='user_group' id='vo'} {/volist} @@ -94,6 +102,7 @@ {block name="script"} {/block} diff --git a/app/admin/view/nk/user/edit.html b/app/admin/view/nk/user/edit.html index 1343292..bb68706 100644 --- a/app/admin/view/nk/user/edit.html +++ b/app/admin/view/nk/user/edit.html @@ -186,19 +186,21 @@
-
-
- 农作物名称 -
-
- 数量 -
-
- 面积 -
+ {volist name="planting.crops_msg" id="vo"} +
+
+ 农作物名称 +
+
+ 数量 +
+
+ 面积 +
+ {/volist} - +
@@ -496,9 +498,27 @@ {block name="script"} - - {/block} @@ -38,8 +108,10 @@ {block name="script"} + {/block}