function getChildrenPriv($pid) { $where['pid'] = $pid; $list = M("menu")->where($where)->select(); $return = array(); $i = 0; foreach ($list as $key => $v) { $return[$i]['text'] = $v['name']; $return[$i]['leaf'] = false; $return[$i]['value'] = "number_" . $v['id']; $return[$i]['expanded'] = false; $return[$i]['id'] = "root\\/" . "number_{$pid}\\/" . "number_" . $v['id']; if ($j = getChildrenPriv($v['id'])) { $return[$i]['children'] = $j; } $i++; } return $return; }
/** * 角色权限分配 */ public function role_priv() { $where['pid'] = isset($_GET['pid']) ? intval($_GET['pid']) : 0; $list = M("menu")->where($where)->select(); $return = array(); $i = 0; foreach ($list as $key => $v) { $return[$i]['text'] = $v['name']; $return[$i]['leaf'] = false; $return[$i]['checkable'] = true; $return[$i]['value'] = "number_" . $v['id']; $return[$i]['expanded'] = false; $return[$i]['id'] = "root\\/" . "number_" . $v['id']; $return[$i]['children'] = getChildrenPriv($v['id']); $i++; } echo json_encode($return); }