更新菜单

This commit is contained in:
mkm 2023-11-09 14:31:24 +08:00
parent a05b316e02
commit 138e50c86c
2 changed files with 28 additions and 10 deletions

View File

@ -53,6 +53,18 @@ class MenuController extends BaseAdminController
return $this->dataLists(new MenuLists());
}
/**
* 根据id获取模块菜单
*/
public function model_menu_lists()
{
$id=$this->request->param('id',0);
if($id==0){
return $this->fail('缺少参数');
}
$list=MenuLogic::getModelList($id);
return $this->success('操作成功', $list);
}
/**
* @notes 菜单详情

View File

@ -63,16 +63,22 @@ class MenuLogic extends BaseLogic
return linear_to_tree($menu, 'children');
}
// public static function getPidMyList($pid){
// $where = [];
// $where[] = ['type', 'in', ['M', 'C']];
// $where[] = ['is_disable', '=', 0];
// $where[] = ['pid', '=', $pid];
// $menu = SystemMenu::where($where)
// ->order(['sort' => 'desc', 'id' => 'asc'])
// ->select();
// }
public static function getModelList($id){
$where = [];
$where[] = ['is_disable', '=', 0];
$where[] = ['id', '=', $id];
$model_name = SystemMenu::where($where)->value('paths');
if($model_name){
unset($where[1]);
$where[] = ['type', 'in', ['M', 'C']];
$where[] = ['model_name', '=', $model_name];
$menu = SystemMenu::where($where)
->order(['sort' => 'desc', 'id' => 'asc'])
->select();
return linear_to_tree($menu, 'children','id','pid',$id);
}
return [];
}
/**
* @notes 添加菜单