场景:后台的目录菜单有若干个子菜单,层级可能有4级或者更多
例如$infos = 如下结构
调用:$infos = $this->recurseCategory($infos);
Array
(
[0] => Array
(
[title] => xxxxxx系统
[note] => xxxxxxxxxx旗下的美吉科技常规测序业务的一个管理系统,主要服务于一代测序
包含以下几个大模块:
生产环节:
1.客户下单
2.样品制备
3.反应
商务环节:
1.待生成发货的列表
2.订单开票(月结、预付)
3.发票冲销、核销、退票
4.回款
[category_id] => 1
[path] =>
[level] => 1
[parent_id] => 0
)
[1] => Array
(
[category_id] => 2
[title] => 生产管理
[note] => 生产/实验室人员录入订单,包括:
1.质粒/已纯化订单录入
2.菌液订单录入
3.PCR订单录入
4.加测订单录入
5.备用样品订单录入
6.备用引物管理
7.订单审核
8.问题订单列表
9.订单查询
10.摆样管理
11.补货查询管理
[parent_id] => 1
[path] => ,1,
[level] => 2
)
[2] => Array
(
[category_id] => 3
[title] => 订单管理
[note] => 生产/实验室人员录入订单,包括:
1.质粒/已纯化订单录入
2.菌液订单录入
3.PCR订单录入
4.加测订单录入
5.备用样品订单录入
6.备用引物管理
7.订单审核
8.问题订单列表
9.订单查询
10.摆样管理
11.补货查询管理
[parent_id] => 2
[path] => ,1,2,
[level] => 3
)
[3] => Array
(
[category_id] => 4
[title] => 质粒/已纯化订单录入
[note] => 质粒/已纯化订单录入:
1.选择客户,课题组,手机,电话,email
2.批量导入样品和引物
3.录入样品和引物
4.清空复制(样品名称、载体名称、片段长度、鉴定情况、样品情况、测序要求、通用引物、自备引物、已送引物、合成引物、问题待测)
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[4] => Array
(
[category_id] => 5
[title] => 菌液订单录入
[note] => 菌液订单录入:
1.选择客户,课题组,手机,电话,email
2.批量导入样品和引物
3.录入样品和引物
4.清空复制(样品名称、载体名称、片段长度、鉴定情况、样品情况、测序要求、通用引物、自备引物、已送引物、合成引物、问题待测)
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[5] => Array
(
[category_id] => 6
[title] => 样品自备
[note] => 订单的下一个环节就是样品制备环节:
主要作用:
1.把录入的订单的样品/引物放到对应的摆样板上(96孔),分为样品板和引物板(样品板分为:质粒板,菌液板,PCR板子,引物板分为:通用引物板,长期引物板,备用引物板,合成引物板,普通引物板)
2.对应的样品进行检测
[parent_id] => 2
[path] => ,1,2,
[level] => 3
)
[6] => Array
(
[category_id] => 7
[title] => PCR订单录入
[note] => PCR订单录入
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[7] => Array
(
[category_id] => 8
[title] => 加测订单录入
[note] => 加测订单录入
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[8] => Array
(
[category_id] => 9
[title] => 备用样品订单录入
[note] => 备用样品订单录入
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[9] => Array
(
[category_id] => 10
[title] => 备用引物管理
[note] => 备用引物管理
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[10] => Array
(
[category_id] => 11
[title] => 订单审核
[note] => 订单审核
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[11] => Array
(
[category_id] => 12
[title] => 问题订单列表
[note] => 问题订单列表
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[12] => Array
(
[category_id] => 13
[title] => 订单查询
[note] => 订单查询
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[13] => Array
(
[category_id] => 14
[title] => 摆样管理
[note] => 摆样管理
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[14] => Array
(
[category_id] => 15
[title] => 补货查询及处理
[note] => 补货查询及处理
[parent_id] => 3
[path] => ,1,2,3,
[level] => 4
)
[15] => Array
(
[category_id] => 16
[title] => 质粒样品
[note] => 质粒样品
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[16] => Array
(
[category_id] => 17
[title] => 菌液样品
[note] => 菌液样品
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[17] => Array
(
[category_id] => 18
[title] => PCR样品
[note] => PCR样品
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[18] => Array
(
[category_id] => 19
[title] => 菌液制备配置
[note] => 菌液制备配置
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[19] => Array
(
[category_id] => 20
[title] => PCR制备配置
[note] => PCR制备配置
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[20] => Array
(
[category_id] => 21
[title] => 胶图列表
[note] => 胶图列表
[parent_id] => 6
[path] => ,1,2,6,
[level] => 4
)
[21] => Array
(
[category_id] => 22
[title] => 反应管理
[note] => 反应管理
[parent_id] => 2
[path] => ,1,2,
[level] => 3
)
[22] => Array
(
[category_id] => 23
[title] => 3730机器列表
[note] => 3730机器列表
[parent_id] => 22
[path] => ,1,2,22,
[level] => 4
)
[23] => Array
(
[category_id] => 24
[title] => 实验准备
[note] => 实验准备
[parent_id] => 22
[path] => ,1,2,22,
[level] => 4
)
[24] => Array
(
[category_id] => 25
[title] => 引物稀释
[note] => 引物稀释
[parent_id] => 22
[path] => ,1,2,22,
[level] => 4
)
[25] => Array
(
[category_id] => 26
[title] => 反应板
[note] => 反应板
[parent_id] => 22
[path] => ,1,2,22,
[level] => 4
)
[26] => Array
(
[category_id] => 27
[title] => 反应结果变更审核
[note] => 反应结果变更审核
[parent_id] => 22
[path] => ,1,2,22,
[level] => 4
)
[27] => Array
(
[category_id] => 28
[title] => 商务管理
[note] => 商务管理
[parent_id] => 1
[path] => ,1,
[level] => 2
)
/**
* 递归代码
*
* @param array
* @param int
*
* @return array
**/
private function recurseCategory(&$params, $parent_id = 0)
{
$infos = array();
$i = 0;
foreach ($params as &$val) {
if ($val['parent_id'] == $parent_id) {
$infos[$i] = $val;
$category_id = $val['category_id'];
unset($val);
$subs = $this->recurseCategory($params, $category_id);
if (!empty($subs)) {
$infos[$i]['subs'] = $subs;
}
$i ++;
}
}
return $infos;
}