Browse Source

菜单空url不展示,除父菜单外

sugangqiang 2 years ago
parent
commit
020ceff279
1 changed files with 7 additions and 2 deletions
  1. 7 2
      app/common/api/MenuApi.php

+ 7 - 2
app/common/api/MenuApi.php

@@ -16,7 +16,12 @@ class MenuApi {
     public static function getMenuListByRoleid($roleid) {
         $role = Role::find($roleid);
         $menu_ids = $role->sysRelation->column("menuid");
-        $menus = Menu::where("id", "in", $menu_ids)->where("ismenu", 1)->where("status", 1)->order("levels asc,num asc")->select()->toArray();
+        $where[] = ["status", "=", 1];
+        $where[] = ["ismenu", "=", 1];
+        $where[] = ["new_url", "<>", ""];
+        $where[] = ["id", "in", $menu_ids];
+        $whr[] = ["levels", "=", 1];
+        $menus = Menu::whereOr([$where, $whr])->order("levels asc,num asc")->select()->toArray();
         return self::buildMenu($menus);
     }
 
@@ -107,7 +112,7 @@ class MenuApi {
         $menus[] = ["type" => [3], "code" => "hxjh", "pcode" => "0", "name" => "海峡计划", "url" => "", "icon" => "fa-plane"];
         $menus[] = ["type" => [3], "code" => "hxjhsb", "pcode" => "hxjh", "name" => "海峡计划申报", "url" => "", "icon" => "fa-pencil"];
         foreach ($menus as $key => $menu) {
-            if (!in_array($type, $menu["type"]))
+            if (!in_array($type, $menu["type"]) || ($menu["pcode"]) != "0" && $menu["url"] == "")
                 unset($menus[$key]);
         }
         return self::buildMenu($menus);