|
...
|
...
|
@@ -36,6 +36,11 @@ class NavController extends BaseController |
|
|
|
if(!empty($groupInfo['sort_list'])){
|
|
|
|
$sort_list = json_decode($groupInfo['sort_list']);
|
|
|
|
$result = $this->findDetailsList($sort_list,$lists);
|
|
|
|
$detailsList = $result['detailsList'];
|
|
|
|
if(!empty($detailsList)){
|
|
|
|
//写入
|
|
|
|
|
|
|
|
}
|
|
|
|
$data = $result['result'];
|
|
|
|
}else{
|
|
|
|
$data = array();
|
|
...
|
...
|
@@ -82,6 +87,55 @@ class NavController extends BaseController |
|
|
|
return ['result'=>$result,'detailsList'=>$detailsList];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :setDetails
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/21 9:09
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name : setDetails
|
|
|
|
* @author : lyh
|
|
|
|
* @method : post
|
|
|
|
* @time : 2023/12/21 9:09
|
|
|
|
*/
|
|
|
|
public function setDetails($details, &$result)
|
|
|
|
{
|
|
|
|
foreach ($details as $k => $v) {
|
|
|
|
if ($v['pid'] == 0) {// 一级菜单
|
|
|
|
$result[] = $v;
|
|
|
|
} else {
|
|
|
|
$parentIndex = $this->findParentIndex($result, $v['pid']);
|
|
|
|
if ($parentIndex !== null) {
|
|
|
|
// Add the current element under its parent
|
|
|
|
$result[$parentIndex]['sub'][] = $v;
|
|
|
|
} else {
|
|
|
|
// Handle case where parent is not found
|
|
|
|
// You can throw an exception, log a message, or handle it as per your requirement.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find the index of the parent element in $result based on 'id'.
|
|
|
|
*
|
|
|
|
* @param array $result
|
|
|
|
* @param int $parentId
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
private function findParentIndex($result, $parentId)
|
|
|
|
{
|
|
|
|
foreach ($result as $index => $item) {
|
|
|
|
if ($item['id'] == $parentId) {
|
|
|
|
return $index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|