[更新]修改系统菜单选择排序

This commit is contained in:
Anyon 2017-09-12 15:52:06 +08:00
parent ce578f6bda
commit 3b91c084d9
2 changed files with 2 additions and 2 deletions

View File

@ -83,7 +83,7 @@ class Menu extends BasicAdmin
{ {
if ($this->request->isGet()) { if ($this->request->isGet()) {
// 上级菜单处理 // 上级菜单处理
$_menus = Db::name($this->table)->where(['status' => '1'])->order('sort desc,id desc')->select(); $_menus = Db::name($this->table)->where(['status' => '1'])->order('sort asc,id asc')->select();
$_menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1']; $_menus[] = ['title' => '顶级菜单', 'id' => '0', 'pid' => '-1'];
$menus = ToolsService::arr2table($_menus); $menus = ToolsService::arr2table($_menus);
foreach ($menus as $key => &$menu) { foreach ($menus as $key => &$menu) {

View File

@ -118,7 +118,7 @@ class ToolsService
* @param string $ppath * @param string $ppath
* @return array * @return array
*/ */
public static function arr2table($list, $id = 'id', $pid = 'pid', $path = 'path', $ppath = '') public static function arr2table(array $list, $id = 'id', $pid = 'pid', $path = 'path', $ppath = '')
{ {
$tree = []; $tree = [];
foreach (self::arr2tree($list, $id, $pid) as $attr) { foreach (self::arr2tree($list, $id, $pid) as $attr) {