1b542228 by yangjianbin

init

1 parent 18c151ab
...@@ -59,9 +59,31 @@ class Perm extends CI_Controller { ...@@ -59,9 +59,31 @@ class Perm extends CI_Controller {
59 59
60 public function organization() 60 public function organization()
61 { 61 {
62 $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"}]'; 62 $res = json_decode(file_get_contents($this->config->item('apiBaseUrl') . 'department/getTree'));
63 $data = json_decode($data, true); 63 $data = $res->data;
64 $arr = array();
65 foreach ($data as $k => $v) {
66 $item = array();
67 $item['id'] = $v->id;
68 $item['name'] = $v->name;
69 $item['pId'] = 0;
70 $item['open'] = true;
71 if (!$v->children || empty($v->children)) {
72 continue;
73 }
74 $arr[] = $item;
75 foreach ($v->children as $kk => $vv) {
76 $item2 = array();
77 $item2['id'] = $v->id;
78 $item2['name'] = $v->name;
79 $item2['pId'] = $v->id;
80 $arr[] = $item2;
81 }
82
83 }
84 // $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"}]';
85 // $data = json_decode($data, true);
64 86
65 $this->output->set_content_type('application/json')->set_output(json_encode($data)); 87 $this->output->set_content_type('application/json')->set_output(json_encode($arr));
66 } 88 }
67 } 89 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!