easyui递归下拉树

 1  /***** 部门选择下拉框字典2 *****/
 2  function buMen2(){
 3      $department =M('department');//部门表
 4        $org_code =$this->organization_code;
 5      $where['org_code'] = $org_code;
 6      
 7      $data = $department->where($where)->select();
 8 
 9      $res = $this->bumenTree2($department,0);
10        dump($res);die;
11        
12        $res = json_encode($res);
13        return $res; 
14      
15  } 
16 
17 
18 function bumenTree2($db,$dep_poid=0){
19      
20      $where['org_code']=1000;
21      $where['dep_poid']= $dep_poid;
22      
23     $data=$db->where($where)->select();
24 //  dump($data);
25 //  die;
26     $all=array(); 
27      foreach($data as $k=>$v)
28      {
29          $all[$k]['id']=$v['dep_oid'];
30          $all[$k]['text']=$v['dep_name'];
31          $whe['dep_poid']=$v['dep_oid'];
32          $res=$db->where($whe)->count();
33          if($res>0)
34          {
35             $all[$k]['children']=$this->bumenTree2($db,$v['dep_oid']);
36          }
37      } 
38      return $all;
39      
40  }

猜你喜欢

转载自www.cnblogs.com/shenaishiren/p/8954110.html
今日推荐