Browse Source

菜单优化

wufeng 2 years ago
parent
commit
8d77e4cf73
2 changed files with 28 additions and 11 deletions
  1. 27 10
      app/admin/controller/Menu.php
  2. 1 1
      app/admin/controller/User.php

+ 27 - 10
app/admin/controller/Menu.php

@@ -60,21 +60,38 @@ class Menu extends Base
 //    }
     public function list()
     {
-        $uid = $this->uid;
-        if ($uid == '') {
-            return error_show(101, '未找到用户信息');
-        }
-        $role = $this->checkRole();
+        $post = $this->request->filter('trim')->post();
+//        $uid = $this->uid;
+//        if ($uid == '') {
+//            return error_show(101, '未找到用户信息');
+//        }
 
-        if (empty($role)) {
-            return app_show(0, "获取成功", []);
-        }
+        //相关权限等以后重新梳理
+//        $role = $this->checkRole();
+
+        if ($this->level == 1) {
+            //超管,获取所有
+            $role['action_conllect'] = Db::name('action')
+                ->field('id')
+                ->where(['is_del' => 0, 'status' => 1])
+                ->buildSql();
+        } else $role['action_conllect'] = Db::name('user_role')
+            ->alias('a')
+            ->field('b.action_conllect')
+            ->leftJoin('role_action b', 'b.role_id=a.roleid')
+            ->where(['a.uid' => $this->uid, 'a.is_del' => 0, 'a.companyNo' => $post['relaComNo']])
+            ->buildSql();
+
+//        if (empty($role['action_conllect'])) {
+//            return app_show(0, "获取成功", []);
+//        }
 
-        $where=[['status','=',1],['cstatus','=',1],['is_display','=',1]];
-        if(!empty($role['action_conllect'])) $where[]=['aid','in',$role['action_conllect']];
+        $where = [['status', '=', 1], ['cstatus', '=', 1], ['is_display', '=', 1]];
+//        if (!empty($role['action_conllect'])) $where[] = ['aid', 'in', $role['action_conllect']];
 
         $data = Db::name("view_menu")
             ->where($where)
+            ->where('aid in '.$role['action_conllect'])
             ->order("weight desc,id asc,cweight desc,cid asc")
             ->select()
             ->toArray();

+ 1 - 1
app/admin/controller/User.php

@@ -438,7 +438,7 @@ class User extends Base
                 $roledata = [
                     "uid" => $post['id'],
                     "roleid" => $post['roleid'],
-                    "nickname" => $post['nickname'],
+//                    "nickname" => $post['nickname'],
                     "companyNo" => $post['companyNo'],
                     "company_type" => $company_type,
                     "is_main" => $is_main,