This commit is contained in:
win10 committed 2020-02-08 17:20:08 +08:00
1 parent ccb37ed51d
commit 56572d0b0a
4 files changed
+165 -99

No files matched your search

+7
View File
@@ -77,6 +77,13 @@ class AuthGroup extends BaseController
$rule = new \app\admin\model\AuthRule;
$ruleList = $rule->srcStatus();
$ruleSelect = array();
$auth = $rule->digui($ruleList,$ruleSelect,0);
// halt($auth);
// $auth = ['a'=>11,12,13];
$list['auth'] = $auth;
// 模板赋值
$this->view->assign('list',$list);
+20
View File
@@ -212,5 +212,25 @@ class AuthRule extends BaseController
return json($data);
}
// 递归权限类别
public function digui($arrAll=array(),$arrSelected=array(),$pid=0)
{
// 声明子权限
$child = array();
// 循环所有权限
foreach ($arrAll as $key => $value) {
# 获取当前子权限
if($value['pid'] == $pid)
{
# 判断当前权限是否被选中
array_search($value['id'], $arrSelected) ? $value['select'] = true : $value['select'] = false;
$child[$value['id']] = $value;
unset($arrAll[$key]);
$child[$value['id']]['child'] = $this->digui($arrAll,$arrSelected,$value['id']);
}
}
return $child;
}
}
+22 -1
View File
@@ -42,7 +42,7 @@ class AuthRule extends Base
}
// 递归权限
// 查询状态正常的类别
public function srcStatus()
{
$data = $this->where('status',1)
@@ -51,4 +51,25 @@ class AuthRule extends Base
->toArray();
return $data;
}
// 递归权限类别
public function digui($arrAll=array(),$arrSelected=array(),$pid=0)
{
// 声明子权限
$child = array();
// 循环所有权限
foreach ($arrAll as $key => $value) {
# 获取当前子权限
if($value['pid'] == $pid)
{
# 判断当前权限是否被选中
array_search($value['id'], $arrSelected) ? $value['select'] = true : $value['select'] = false;
$child[$value['id']] = $value;
unset($arrAll[$key]);
$child[$value['id']]['child'] = $this->digui($arrAll,$arrSelected,$value['id']);
}
}
return $child;
}
}
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more