thinkphp5 3级分类列表
public function buildList($parent_id = 0,$level = 1) { $list = []; foreach ( $this->data as $key => $val ) { if ( $val['parent_id'] == $parent_id ) { $v['id'] = $val['id']; $v['parent_id'] = $val['parent_id']; $v['name'] = $val['name']; $v['module'] = $val['module']; $v['filename'] = $val['filename']; $v['icon'] = $val['icon']; $v['is_show'] = $val['is_show']; $v['sort'] = $val['sort']; $v['level'] = $level; $children = $this->buildList($v['id'],$level + 1); if(empty($children)) { $v['has_children'] = false; } else { $v['has_children'] = true; } $list[] = $v; $list = array_merge($list,$children); } } return $list; } css:? .taxons-list { border-right: 1px solid #f3f3f3; border-bottom: 1px solid #f3f3f3; } .taxons-list li { height: 45px; line-height: 45px; border-left: 1px solid #f3f3f3; border-top: 1px solid #f3f3f3; } .taxons-list li a { font-size: 14px; } .taxons-list .taxon-no { width: 5%; } .taxons-list .taxon-name { width: 50%; } .taxons-list .taxon-name img { vertical-align: middle; cursor: pointer; } .taxons-list .taxon-name .line-verticle { display: block; width: 15px; height: 40px; position: relative; float: left; } .taxons-list .taxon-name .line-verticle:before { content: ''; position: absolute; top: 0; left: 0; width: 1px; height: 25px; background: #dddddd; } .taxons-list .taxon-name .line-verticle:after { content: ''; position: absolute; top: 25px; left: 0; width: 15px; height: 1px; background: #dddddd; } .taxons-list .taxon-name .line-more { width: 30px; } .taxons-list .taxon-name .line-more:before { content: ''; position: absolute; top: 0; left: 0; width: 1px; height: 25px; background: #dddddd; } .taxons-list .taxon-name .line-more:after { content: ''; position: absolute; top: 25px; left: 0; width: 30px; height: 1px; background: #dddddd; } .taxons-list .taxon-module { width: 10%; } .taxons-list .taxon-show { width: 10%; } .taxons-list .taxon-sort { width: 10%; } .taxons-list .taxon-operate { width: 10%; } .taxons-list .pull-left { border-right: 1px solid #d9d9d9; padding-left: 5px; } .taxons-list .taxon-header { background: #f3f3f3; } .taxons-list .taxon-hide { display: none; } html:
|