|
@@ -195,27 +195,45 @@ class Action extends BaseController
|
|
|
//11获取素有菜单列表数据
|
|
|
public function index()
|
|
|
{
|
|
|
- $post = $this->request->filter('trim')->post();
|
|
|
-
|
|
|
- $where = [["status", "=", 1], ["is_del", "=", 0], ["level", ">=", $post["level"] ?? 1], ['menu_type', "=", 2]];
|
|
|
- $data = Db::name("admin_menu")->where($where)->order("weight desc")->column("id,menu_name,menu_img,menu_route,menu_url,pid,level,is_show,is_private,menu_type,status");
|
|
|
+ $post = $this->request->post();
|
|
|
+ $data = Db::name("admin_menu")
|
|
|
+ ->where(["pid" => 0, "status" => 1, "is_del" => 0])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
$result = [];
|
|
|
if (empty($data)) {
|
|
|
- return json_show(0, "获取成功", $result);
|
|
|
+ return app_show(0, "获取成功", $result);
|
|
|
+ }
|
|
|
+ foreach ($data as $key => $val) {
|
|
|
+ $val["child"] = [];
|
|
|
+ $result[$val['id']] = $val;
|
|
|
}
|
|
|
- $list = [];
|
|
|
- $menu = [];
|
|
|
- foreach ($data as $k => $value) {
|
|
|
- $action = Db::name("action")
|
|
|
+
|
|
|
+ $child = Db::name("admin_menu")
|
|
|
+ ->where([["pid", "<>", 0], ['status', "=", 1], ["is_del", "=", 0]])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ foreach ($child as $k => $value) {
|
|
|
+ // $act = PasAction::all(['menuid'=>$value['id'],"status"=>1]);
|
|
|
+ $act = Db::name("action")
|
|
|
->alias("a")
|
|
|
- ->leftJoin("action_list b", "a.action_code=b.action_code")
|
|
|
- ->where(["menuid" => $value['id'], "a.status" => 1, "a.is_del" => 0, "b.is_del" => 0])
|
|
|
- ->column("a.id,a.action_code,b.action_name");
|
|
|
- if ($value['menu_type'] == 2) $value['action'] = $action;
|
|
|
- $list[] = $value;
|
|
|
+ ->leftJoin("action_list l", "a.action_code=l.action_code")
|
|
|
+ ->field("a.*,action_name")
|
|
|
+ ->where(['a.menuid' => $value['id'], "a.status" => 1])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ $act_data = Db::name("action_field")
|
|
|
+ ->where(['menuid' => $value['id'], "status" => 1])
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ $value['action'] = $act;
|
|
|
+ $value['action_data'] = $act_data;
|
|
|
+ if (array_key_exists($value['pid'], $result)) {
|
|
|
+ $result[$value['pid']]["child"][] = $value;
|
|
|
+ }
|
|
|
}
|
|
|
- menuAction($list, $menu);
|
|
|
- return json_show(0, "获取成功", array_values($menu));
|
|
|
+
|
|
|
+ return json_show(0, "获取成功", array_values($result));
|
|
|
}
|
|
|
|
|
|
|