Browse Source

PC端权限

lizhen_gitee 8 months ago
parent
commit
5700586ed2

+ 23 - 0
application/common/library/Authcompany.php

@@ -542,6 +542,29 @@ class Authcompany extends \fast\Authpc
      * @param string $fixedPage 默认页
      * @return array
      */
+    public function getmenu(){
+        // 读取管理员当前拥有的权限节点
+        $userRule = $this->getRuleList();
+
+        // 必须将结果集转换为数组
+        $ruleList = collection(\app\admin\model\PcAuthRule::where('status', 'normal')
+            ->where('type', 'NEQ',3)
+            ->order('weigh', 'desc')
+            ->select())->toArray();
+
+        foreach ($ruleList as $k => &$v) {
+            if (!in_array($v['name'], $userRule)) {
+                unset($ruleList[$k]);
+                continue;
+            }
+        }
+dump($ruleList);
+        Tree::instance()->init($ruleList);
+        $menu = Tree::instance()->getTreeMenu(Tree::instance()->getTreeArray(0), 'name');
+
+        return $menu;
+
+    }
     public function getSidebar($params = [], $fixedPage = 'dashboard')
     {
         // 边栏开始

+ 17 - 0
application/company/controller/Index.php

@@ -24,6 +24,23 @@ class Index extends Apic
 
     }
 
+    /**
+     * 后台首页
+     */
+    public function index()
+    {
+        $menu = $this->auth->getmenu();
+        dump($menu);
+        //左侧菜单
+       /* list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
+
+        ], 'dashboard');
+        dump($menulist);
+        dump($navlist);
+        dump($fixedmenu);
+        dump($referermenu);*/
+    }
+
     //员工账号+密码登录
     public function login()
     {