作者 lyh

gx

@@ -29,23 +29,6 @@ class NavController extends BaseController @@ -29,23 +29,6 @@ class NavController extends BaseController
29 * @time :2023/12/4 15:00 29 * @time :2023/12/4 15:00
30 */ 30 */
31 public function index(BNav $nav,BNavGroup $navGroup){ 31 public function index(BNav $nav,BNavGroup $navGroup){
32 -// $this->map['project_id'] = $this->user['project_id'];  
33 -// $lists = $nav->list($this->map,$this->order = ['sort','id']);  
34 -// //获取菜单组排序字段  
35 -// $groupInfo = $navGroup->read(['id'=>$this->param['group_id']]);  
36 -// if(!empty($groupInfo['sort_list'])){  
37 -// $sort_list = json_decode($groupInfo['sort_list']);  
38 -// $data = $this->findDetailsList($sort_list,$lists);  
39 -// }else{  
40 -// $data = array();  
41 -// foreach ($lists as $v){  
42 -// $v = (array)$v;  
43 -// if ($v['pid'] == 0) {  
44 -// $v['sub'] = _get_child($v['id'], $lists);  
45 -// $data[] = $v;  
46 -// }  
47 -// }  
48 -// }  
49 $this->map['project_id'] = $this->user['project_id']; 32 $this->map['project_id'] = $this->user['project_id'];
50 $lists = $nav->list($this->map,$this->order = ['sort','id']); 33 $lists = $nav->list($this->map,$this->order = ['sort','id']);
51 $data = array(); 34 $data = array();
@@ -68,6 +51,13 @@ class NavController extends BaseController @@ -68,6 +51,13 @@ class NavController extends BaseController
68 $this->response('success',Code::SUCCESS,$data); 51 $this->response('success',Code::SUCCESS,$data);
69 } 52 }
70 53
  54 + /**
  55 + * @remark :排序
  56 + * @name :findDetailsLists
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/12/20 20:29
  60 + */
71 public function findDetailsLists($sort_list, $detailsList) 61 public function findDetailsLists($sort_list, $detailsList)
72 { 62 {
73 $result = []; 63 $result = [];
@@ -82,14 +72,20 @@ class NavController extends BaseController @@ -82,14 +72,20 @@ class NavController extends BaseController
82 $result[] = $detailsList[$val['id']]; 72 $result[] = $detailsList[$val['id']];
83 unset($detailsList[$val['id']]); 73 unset($detailsList[$val['id']]);
84 } 74 }
85 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);  
86 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(1111111111, true) . PHP_EOL, FILE_APPEND);  
87 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($detailsList, true) . PHP_EOL, FILE_APPEND);  
88 $result = array_merge($result, $detailsList); 75 $result = array_merge($result, $detailsList);
89 - 76 + $result = $this->getSonList($result);
90 return $this->success($result); 77 return $this->success($result);
91 } 78 }
92 79
  80 + public function getSonList($result){
  81 + foreach ($result as $k => $v){
  82 + if(!empty($v['sub'])){
  83 + $this->getSonList($v['sub']);
  84 + }
  85 + $result[$k] = array_values($v);
  86 + }
  87 + return $result;
  88 + }
93 89
94 /** 90 /**
95 * @remark :根据id组装数据 91 * @remark :根据id组装数据