角色组排序优化

pull/8/head
pppscn 2018-11-27 21:17:58 +08:00
parent 55c22c31a7
commit bc71a3e2d1
2 changed files with 3 additions and 2 deletions

View File

@ -254,7 +254,7 @@ class Group extends Backend
if (($pid || $parentGroupModel) && (!$id || $currentGroupModel)) if (($pid || $parentGroupModel) && (!$id || $currentGroupModel))
{ {
$id = $id ? $id : NULL; $id = $id ? $id : NULL;
$ruleList = collection(model('AuthRule')->order('weigh', 'desc')->select())->toArray(); $ruleList = collection(model('AuthRule')->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
//读取父类角色所有节点列表 //读取父类角色所有节点列表
$parentRuleList = []; $parentRuleList = [];
if (in_array('*', explode(',', $parentGroupModel->rules))) if (in_array('*', explode(',', $parentGroupModel->rules)))

View File

@ -27,7 +27,7 @@ class Rule extends Backend
parent::_initialize(); parent::_initialize();
$this->model = model('AuthRule'); $this->model = model('AuthRule');
// 必须将结果集转换为数组 // 必须将结果集转换为数组
$ruleList = collection($this->model->order('weigh', 'desc')->select())->toArray(); $ruleList = collection($this->model->order('weigh', 'desc')->order('id', 'asc')->select())->toArray();
foreach ($ruleList as $k => &$v) foreach ($ruleList as $k => &$v)
{ {
$v['title'] = __($v['title']); $v['title'] = __($v['title']);
@ -43,6 +43,7 @@ class Rule extends Backend
continue; continue;
$ruledata[$v['id']] = $v['title']; $ruledata[$v['id']] = $v['title'];
} }
unset($v);
$this->view->assign('ruledata', $ruledata); $this->view->assign('ruledata', $ruledata);
} }