Procházet zdrojové kódy

修复非超级管理员添加分组的错误
修复登录后默认不是控制台首页的BUG

Karson před 7 roky
rodič
revize
3a92ef5564

+ 8 - 5
application/admin/controller/auth/Admin.php

@@ -30,7 +30,6 @@ class Admin extends Backend
         $this->childrenGroupIds = $this->auth->getChildrenGroupIds($this->auth->isSuperAdmin() ? true : false);
 
         $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
-        $groupIds = $this->auth->getGroupIds();
         Tree::instance()->init($groupList);
         $result = [];
         if ($this->auth->isSuperAdmin())
@@ -39,9 +38,10 @@ class Admin extends Backend
         }
         else
         {
-            foreach ($groupIds as $m => $n)
+            $groups = $this->auth->getGroups();
+            foreach ($groups as $m => $n)
             {
-                $result = array_merge($result, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n)));
+                $result = array_merge($result, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));
             }
         }
         $groupName = [];
@@ -61,7 +61,6 @@ class Admin extends Backend
     {
         if ($this->request->isAjax())
         {
-
             $childrenGroupIds = $this->childrenGroupIds;
             $groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
                     ->column('id,name');
@@ -75,7 +74,11 @@ class Admin extends Backend
                 if (isset($groupName[$v['group_id']]))
                     $adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
             }
-
+            $groups = $this->auth->getGroups();
+            foreach ($groups as $m => $n)
+            {
+                $adminGroupName[$this->auth->id][$n['id']] = $n['name'];
+            }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
             $total = $this->model
                     ->where($where)

+ 4 - 3
application/admin/controller/auth/Group.php

@@ -31,7 +31,7 @@ class Group extends Backend
         $this->childrenGroupIds = $this->auth->getChildrenGroupIds(true);
 
         $groupList = collection(AuthGroup::where('id', 'in', $this->childrenGroupIds)->select())->toArray();
-        $groupIds = $this->auth->getGroupIds();
+
         Tree::instance()->init($groupList);
         $result = [];
         if ($this->auth->isSuperAdmin())
@@ -40,9 +40,10 @@ class Group extends Backend
         }
         else
         {
-            foreach ($groupIds as $m => $n)
+            $groups = $this->auth->getGroups();
+            foreach ($groups as $m => $n)
             {
-                $result = array_merge($result, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n)));
+                $result = array_merge($result, Tree::instance()->getTreeList(Tree::instance()->getTreeArray($n['pid'])));
             }
         }
         $groupName = [];

+ 12 - 10
public/assets/js/backend/index.js

@@ -180,23 +180,25 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
 
             //绑定tabs事件,如果需要点击强制刷新iframe,则请将iframeForceRefresh置为true
             $('#nav').addtabs({iframeHeight: "100%", iframeForceRefresh: false});
-
-            var addtabs = localStorage.getItem("addtabs");
             if ($("ul.sidebar-menu li.active a").size() > 0) {
                 $("ul.sidebar-menu li.active a").trigger("click");
             } else {
                 $("ul.sidebar-menu li a[url!='javascript:;']:first").trigger("click");
             }
-            if (addtabs) {
-                var active = $("ul.sidebar-menu li a[addtabs=" + $(addtabs).attr("addtabs") + "]");
-                if (active.size() > 0) {
-                    active.trigger("click");
+            //如果是刷新操作则直接返回刷新前的页面
+            var addtabs = Config.referer ? localStorage.getItem("addtabs") : null;
+            if (Config.referer) {
+                if (Config.referer === $(addtabs).attr("url")) {
+                    var active = $("ul.sidebar-menu li a[addtabs=" + $(addtabs).attr("addtabs") + "]");
+                    if (active.size() > 0) {
+                        active.trigger("click");
+                    } else {
+                        $(addtabs).appendTo(document.body).addClass("hide").trigger("click");
+                    }
                 } else {
-                    $(addtabs).appendTo(document.body).addClass("hide").trigger("click");
+                    //刷新页面后跳到到刷新前的页面
+                    Backend.api.addtabs(Config.referer);
                 }
-            } else if (Config.referer) {
-                //刷新页面后跳到到刷新前的页面
-                Backend.api.addtabs(Config.referer);
             }
 
             /**