123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- declare(strict_types = 1);
- namespace app\admin\controller;
- use app\admin\BaseController;
- use think\facade\Db;
- class Contract extends BaseController{
- //获取部门树形节点列表
- public function get_department_tree(){
- $login_admin = get_admin(get_login_admin('id'));
- $where = array();
- if($login_admin['permission'] != 1){
- $where = [
- ['unit_name', '=', $login_admin['unit_name']],
- ];
- }
- $department = Db::name('Department')->where($where)->where(['status' => 1])->select()->toArray();
- $list = get_tree($department, 0, 2);
- $data['trees'] = $list;
- return json($data);
- }
- //获取子部门所有员工
- public function get_employee($did = 0)
- {
- $did = get_params('did');
- if($did == 1){
- $department = $did;
- }
- else{
- $department = get_department_son($did);
- }
- $employee = Db::name('admin')
- ->field('a.id,a.did,a.position_id,a.mobile,a.nickname,a.status,a.thumb,a.username,d.title as department')
- ->alias('a')
- ->join('Department d', 'a.did = d.id')
- ->where(['a.status' => 1])
- ->where('a.id', ">", 1)
- ->where('a.did', "in", $department)
- ->select();
- // halt($employee);
- return to_assign(0, '', $employee);
- }
-
- }
|