init
Showing
2 changed files
with
35 additions
and
2 deletions
| ... | @@ -176,8 +176,12 @@ class Perm extends CI_Controller { | ... | @@ -176,8 +176,12 @@ class Perm extends CI_Controller { |
| 176 | $this->output->set_content_type('application/json')->set_output(json_encode($arr)); | 176 | $this->output->set_content_type('application/json')->set_output(json_encode($arr)); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | public function menu() | 179 | public function menu($id) |
| 180 | { | 180 | { |
| 181 | |||
| 182 | $role = json_decode(file_get_contents($this->config->item('apiBaseUrl') . 'system/role/get/'.$id)); | ||
| 183 | $role = $role->data->menuOutputVOS; | ||
| 184 | |||
| 181 | // echo $this->config->item('apiBaseUrl') . 'system/menu/getAllMenu'; | 185 | // echo $this->config->item('apiBaseUrl') . 'system/menu/getAllMenu'; |
| 182 | $res = json_decode(file_get_contents($this->config->item('apiBaseUrl') . 'system/menu/getAllMenuTree')); | 186 | $res = json_decode(file_get_contents($this->config->item('apiBaseUrl') . 'system/menu/getAllMenuTree')); |
| 183 | // var_dump($res->data); | 187 | // var_dump($res->data); |
| ... | @@ -279,6 +283,35 @@ class Perm extends CI_Controller { | ... | @@ -279,6 +283,35 @@ class Perm extends CI_Controller { |
| 279 | // $data = '[{"id":1,"pId":0,"name":"父节点1 (5人)","open":true},{"id":11,"pId":1,"name":"叶子节点 1-1"},{"id":12,"pId":1,"name":"叶子节点 1-2"},{"id":13,"pId":1,"name":"叶子节点 1-3"},{"id":2,"pId":0,"name":"父节点 2","open":true},{"id":21,"pId":2,"name":"叶子节点 2-1"},{"id":22,"pId":2,"name":"叶子节点 2-2"},{"id":23,"pId":2,"name":"叶子节点 2-3"},{"id":3,"pId":0,"name":"父节点 3","open":true},{"id":31,"pId":3,"name":"叶子节点 3-1"},{"id":32,"pId":3,"name":"叶子节点 3-2"},{"id":33,"pId":3,"name":"叶子节点 3-3"}]'; | 283 | // $data = '[{"id":1,"pId":0,"name":"父节点1 (5人)","open":true},{"id":11,"pId":1,"name":"叶子节点 1-1"},{"id":12,"pId":1,"name":"叶子节点 1-2"},{"id":13,"pId":1,"name":"叶子节点 1-3"},{"id":2,"pId":0,"name":"父节点 2","open":true},{"id":21,"pId":2,"name":"叶子节点 2-1"},{"id":22,"pId":2,"name":"叶子节点 2-2"},{"id":23,"pId":2,"name":"叶子节点 2-3"},{"id":3,"pId":0,"name":"父节点 3","open":true},{"id":31,"pId":3,"name":"叶子节点 3-1"},{"id":32,"pId":3,"name":"叶子节点 3-2"},{"id":33,"pId":3,"name":"叶子节点 3-3"}]'; |
| 280 | // $data = json_decode($data, true); | 284 | // $data = json_decode($data, true); |
| 281 | 285 | ||
| 286 | $arr2 = array(); | ||
| 287 | foreach ($role as $k => $v) { | ||
| 288 | $r = array(); | ||
| 289 | $r['id'] = $v->id; | ||
| 290 | $r['name'] = $v->name; | ||
| 291 | $r['pId'] = 0; | ||
| 292 | $arr2[] = $r; | ||
| 293 | if (!$v->children || empty($v->children)) { | ||
| 294 | continue; | ||
| 295 | } | ||
| 296 | foreach ($v->children as $k2 => $v2) { | ||
| 297 | $r2 = array(); | ||
| 298 | $r2['id'] = $v2->id; | ||
| 299 | $r2['name'] = $v2->name; | ||
| 300 | $r2['pId'] = $v->id; | ||
| 301 | $arr[] = $r2; | ||
| 302 | } | ||
| 303 | |||
| 304 | } | ||
| 305 | |||
| 306 | foreach ($arr as $k => $v) { | ||
| 307 | foreach ($arr2 as $k2 => $v2) { | ||
| 308 | if($v2->checked == true){ | ||
| 309 | $v['checked'] = true; | ||
| 310 | break; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | |||
| 282 | $this->output->set_content_type('application/json')->set_output(json_encode($arr)); | 315 | $this->output->set_content_type('application/json')->set_output(json_encode($arr)); |
| 283 | } | 316 | } |
| 284 | 317 | ... | ... |
| ... | @@ -47,7 +47,7 @@ | ... | @@ -47,7 +47,7 @@ |
| 47 | async: { | 47 | async: { |
| 48 | enable: true, | 48 | enable: true, |
| 49 | // url: '<?//=site_url('/perm/organization')?>//', | 49 | // url: '<?//=site_url('/perm/organization')?>//', |
| 50 | url: '<?=site_url('/perm/menu')?>', | 50 | url: '<?=site_url('/perm/menu'.$id)?>', |
| 51 | autoParam:["id"] | 51 | autoParam:["id"] |
| 52 | }, | 52 | }, |
| 53 | check: { | 53 | check: { | ... | ... |
-
Please register or sign in to post a comment