From 3a92ef5564dc9702cf50addac966aba0d7b83066 Mon Sep 17 00:00:00 2001 From: Karson Date: Fri, 22 Dec 2017 18:42:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=9E=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=20=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=90=8E=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=AF=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=E9=A6=96=E9=A1=B5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/auth/Admin.php | 13 +++++++----- application/admin/controller/auth/Group.php | 7 ++++--- public/assets/js/backend/index.js | 22 +++++++++++---------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/application/admin/controller/auth/Admin.php b/application/admin/controller/auth/Admin.php index 05e69f0b..73d3bf55 100644 --- a/application/admin/controller/auth/Admin.php +++ b/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) diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index 2b63a02c..97f8f533 100644 --- a/application/admin/controller/auth/Group.php +++ b/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 = []; diff --git a/public/assets/js/backend/index.js b/public/assets/js/backend/index.js index 649849d1..2ad6aa96 100755 --- a/public/assets/js/backend/index.js +++ b/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); } /**