// protected function getLiList2($data, $needEdit = 0)
{
print_r($data);die();
$parentsArr = [];
foreach ($data as $value) {
$parentsArr[$value['parentId']][] = $value;
}
print_r($parentsArr);die();
return $this->getDepartmentStr2(0, 1, $parentsArr, $needEdit);
}
结果:data
Array
(
[0] => Array
(
[id] => 1
[name] => cms2.0
[content] => cms2.0欢迎您!
[workOrderUserManagementId] => 3
[parentId] => 0
[parents] =>
[level] => 1
[hasChild] => 1
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-30 16:46:47
)
[1] => Array
(
[id] => 2
[name] => 数据处理
[content] =>
[workOrderUserManagementId] => 2
[parentId] => 1
[parents] => 1
[level] => 2
[hasChild] => 0
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-30 16:51:37
)
[2] => Array
(
[id] => 3
[name] => 下载软件
[content] =>
[workOrderUserManagementId] => 3
[parentId] => 1
[parents] => 1
[level] => 2
[hasChild] => 0
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-31 10:11:06
)
)
结果:parentsArr
Array
(
[0] => Array
(
[0] => Array
(
[id] => 1
[name] => cms2.0
[content] => cms2.0欢迎您!
[workOrderUserManagementId] => 3
[parentId] => 0
[parents] =>
[level] => 1
[hasChild] => 1
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-30 16:46:47
)
)
[1] => Array
(
[0] => Array
(
[id] => 2
[name] => 数据处理
[content] =>
[workOrderUserManagementId] => 2
[parentId] => 1
[parents] => 1
[level] => 2
[hasChild] => 0
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-30 16:51:37
)
[1] => Array
(
[id] => 3
[name] => 下载软件
[content] =>
[workOrderUserManagementId] => 3
[parentId] => 1
[parents] => 1
[level] => 2
[hasChild] => 0
[isLast] => 0
[image] =>
[status] => 1
[createTime] => 2021-08-31 10:11:06
)
)
)
|