Contract.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare(strict_types = 1);
  3. namespace app\admin\controller;
  4. use app\admin\BaseController;
  5. use think\facade\Db;
  6. class Contract extends BaseController{
  7. //获取部门树形节点列表
  8. public function get_department_tree(){
  9. $login_admin = get_admin(get_login_admin('id'));
  10. $where = array();
  11. if($login_admin['permission'] != 1){
  12. $where = [
  13. ['unit_name', '=', $login_admin['unit_name']],
  14. ];
  15. }
  16. $department = Db::name('Department')->where($where)->where(['status' => 1])->select()->toArray();
  17. $list = get_tree($department, 0, 2);
  18. $data['trees'] = $list;
  19. return json($data);
  20. }
  21. //获取子部门所有员工
  22. public function get_employee($did = 0)
  23. {
  24. $did = get_params('did');
  25. if($did == 1){
  26. $department = $did;
  27. }
  28. else{
  29. $department = get_department_son($did);
  30. }
  31. $employee = Db::name('admin')
  32. ->field('a.id,a.did,a.position_id,a.mobile,a.nickname,a.status,a.thumb,a.username,d.title as department')
  33. ->alias('a')
  34. ->join('Department d', 'a.did = d.id')
  35. ->where(['a.status' => 1])
  36. ->where('a.id', ">", 1)
  37. ->where('a.did', "in", $department)
  38. ->select();
  39. // halt($employee);
  40. return to_assign(0, '', $employee);
  41. }
  42. }