|
@@ -20,34 +20,24 @@ class Menu extends BaseController{
|
|
|
if($role==false){
|
|
|
return app_show(0,"获取成功",[]);
|
|
|
}
|
|
|
-
|
|
|
- $data= Db::name("view_menu")->where('aid',"in",explode(",",$role['action_conllect']))->where(['status'=>1,"cstatus"=>1])
|
|
|
- ->order("weight desc,id asc,cweight desc,cid asc")->select();
|
|
|
-
|
|
|
+ $action = Db::name("action")->where(['id'=>explode(",",$role['action_conllect']),"status"=>1])->column("id,menuid,action_code");
|
|
|
+ if (empty($action)){
|
|
|
+ return app_show(0,"获取成功",[]);
|
|
|
+ }
|
|
|
+ $MenuAction=[];
|
|
|
+ foreach ($action as $value){
|
|
|
+ $MenuAction[$value['menuid']][]=$value;
|
|
|
+ }
|
|
|
+ $menuid= array_column($action,"menuid");
|
|
|
+ $menuAll =Db::name("admin_menu")->where(["id"=>$menuid,"status"=>1])->column("id,menu_name,menu_img,menu_route,menu_url,pid,is_show,is_private,menu_type");
|
|
|
$list=[];
|
|
|
- $act=[];
|
|
|
- foreach ($data as $value){
|
|
|
- $list[$value["id"]]['menu_name']=$value['menu_name'];
|
|
|
- $list[$value["id"]]['menu_img']=$value['menu_img'];
|
|
|
- $list[$value["id"]]['menu_route']=$value['menu_route'];
|
|
|
- $list[$value["id"]]['status']=$value['status'];
|
|
|
- $temp = [];
|
|
|
- $temp['menu_name']=$value['cname'];
|
|
|
- $temp['menu_img']=$value['cmenu_img'];
|
|
|
- $temp['menu_route']=$value['cmenu_route'];
|
|
|
- $temp['menu_url']=$value['cmenu_url'];
|
|
|
- $temp['menu_url']=$value['cmenu_url'];
|
|
|
- $temp['status']=$value['cstatus'];
|
|
|
- $temp['is_private']=$value['cprivate'];
|
|
|
- $list[$value["id"]]['child'][$value['cid']]=$temp;
|
|
|
- $act[$value['id']][$value['cid']][]=$value['acode'];
|
|
|
- $list[$value["id"]]['child'][$value['cid']]['action']= $act[$value['id']][$value['cid']];
|
|
|
-
|
|
|
+ foreach ($menuAll as $value){
|
|
|
+ $value['action'][]=$MenuAction[$value['id']];
|
|
|
+ makeMenu($value,$list);
|
|
|
}
|
|
|
- array_walk($list,function (&$value){
|
|
|
- $value['child']= array_values($value['child']);
|
|
|
- });
|
|
|
- return app_show(0,"获取成功",array_values($list));
|
|
|
+ $list=MenuTree($list,0);
|
|
|
+
|
|
|
+ return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
/**菜单设置列表
|
|
|
* @return \think\response\Json|void
|
|
@@ -57,13 +47,8 @@ class Menu extends BaseController{
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function MenuAllList(){
|
|
|
- $data = Db::name("admin_menu")->where(['pid'=>0])->order("weight desc,id asc")->select();
|
|
|
- $l=[];
|
|
|
- foreach ($data as $key=>$value){
|
|
|
- $temp = Db::name("admin_menu")->where(['pid'=>$value['id']])->order("weight desc,id asc")->select();
|
|
|
- $value['child']=$temp;
|
|
|
- $l[]=$value;
|
|
|
- }
|
|
|
+ $data = Db::name("admin_menu")->field("id,menu_name,menu_img,menu_route,menu_url,pid,is_show,is_private,menu_type")->order("weight desc,id asc")->select();
|
|
|
+ $l= MenuTree($data,0);
|
|
|
return app_show(0,"获取成功",$l);
|
|
|
}
|
|
|
|
|
@@ -88,6 +73,7 @@ class Menu extends BaseController{
|
|
|
$pid = isset($post['pid']) ?intval($post['pid']) :0;
|
|
|
$private = isset($post['private']) ?intval($post['private']) :0;
|
|
|
$weight = isset($post['weight']) ?floatval($post['weight']) :1;
|
|
|
+ $menu_type = isset($post['menu_type']) ?intval($post['menu_type']) :1;
|
|
|
if($pid!=0 && $route==""){
|
|
|
return error_show(1002,"子级菜单路由不能为空");
|
|
|
}
|
|
@@ -101,6 +87,7 @@ class Menu extends BaseController{
|
|
|
"weight"=>$weight,
|
|
|
"is_show"=>1,
|
|
|
"is_private"=>$private,
|
|
|
+ "menu_type"=>$menu_type,
|
|
|
"status"=>1,
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
@@ -135,6 +122,7 @@ class Menu extends BaseController{
|
|
|
$pid = isset($post['pid']) ?intval($post['pid']) :0;
|
|
|
$weight = isset($post['weight']) ?floatval($post['weight']) :1;
|
|
|
$status = isset($post['is_show']) ? intval($post['is_show']) : 0;
|
|
|
+ $menu_type = isset($post['menu_type']) ?intval($post['menu_type']) :1;
|
|
|
$private = isset($post['private']) ?intval($post['private']) :(isset($menu['is_private']) ?
|
|
|
$menu['is_private'] : 0);
|
|
|
if($pid!=0 && $route==""){
|
|
@@ -149,6 +137,7 @@ class Menu extends BaseController{
|
|
|
"pid"=>$pid,
|
|
|
'is_show'=>$status,
|
|
|
"is_private"=>$private,
|
|
|
+ "menu_type"=>$menu_type,
|
|
|
'status'=>1,
|
|
|
"weight"=>$weight,
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|