['except' => []] ]; //获取部门 public function get_department() { $department = get_department(); return to_assign(0, '', $department); } //获取部门树形节点列表 public function get_department_tree() { $department = get_department(); $list = get_tree($department, 0, 2); $data['trees'] = $list; $this->apiSuccess('获取成功', $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.name,a.nickname,a.sex,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(); $this->apiSuccess('获取成功', $employee); } //获取报销类型 public function get_expense_cate() { $expense_cate = Db::name('ExpenseCate')->where(['status' => 1])->field(['id', 'title'])->select()->toArray(); $this->apiSuccess('获取成功', $expense_cate); } //获取开票主体 public function get_invoice_subject() { $subject = Db::name('InvoiceSubject')->where(['status' => 1])->order('id desc')->select()->toArray(); $this->apiSuccess('获取成功', $subject); } //获取待办事项 public function get_todo_subject() { $this->uid = JWT_UID; $subject = [ 'approve'=>Db::name('Approve')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")]])->count(), 'expenses'=>Db::name('Expense')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count(), 'invoice'=>Db::name('Invoice')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count(), 'income'=>Db::name('Invoice')->where([['is_cash', '<', 2],['admin_id','=',$this->uid],['check_status', '=', 5],['delete_time', '=', 0]])->count(), 'contract'=>Db::name('Contract')->where([['', 'exp', Db::raw("FIND_IN_SET('{$this->uid}',check_admin_ids)")],['delete_time', '=', 0]])->count(), 'task'=>$handle['task'] = Db::name('ProjectTask')->where([['director_uid', '=', $this->uid],['flow_status', '<', 3],['delete_time', '=', 0]])->count() ]; $this->apiSuccess('获取成功', $subject); } //获取待办任务 public function get_task_list() { $this->uid = JWT_UID; $where = array(); $whereOr = array(); $map1 = []; $map2 = []; $map3 = []; $map1[] = ['admin_id', '=', $this->uid]; $map2[] = ['director_uid', '=', $this->uid]; $map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$this->uid},assist_admin_ids)")]; if($this->isAuthProject($this->uid)==0){ $whereOr =[$map1,$map2,$map3]; } $where[] = ['delete_time', '=', 0]; $list = Db::name('ProjectTask') ->where(function ($query) use ($whereOr) { if (!empty($whereOr)) $query->whereOr($whereOr); }) ->where($where) ->withoutField('content,md_content') ->order('flow_status asc') ->order('id desc') ->limit(8) ->select()->toArray(); foreach ($list as $key => &$val) { $val['director_name'] = Db::name('Admin')->where(['id' => $val['director_uid']])->value('name'); if($val['end_time']>0){ $val['end_time'] = date('Y-m-d', $val['end_time']); } else{ $val['end_time'] = '-'; } $val['flow_name'] = \app\project\model\ProjectTask::$FlowStatus[(int) $val['flow_status']]; } $res['data'] = $list; $this->apiSuccess('获取成功', $res); } private function isAuthProject($uid) { if($uid == 1){ return 1; } $map = []; $map[] = ['name', '=', 'project_admin']; $map[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',uids)")]; $count = Db::name('DataAuth')->where($map)->count(); return $count; } }