['name','leader','mobile'], '=' => ['status'] ]; } /** * @notes 获取管理列表 * @return array * @author heshihu * @date 2022/2/21 17:11 */ public function lists(): array { $params = $this->request->param(); $where = []; if(isset($params['org_name']) && $params['org_name'] != ''){ $orgs = Orgs::where('name','like','%'.$params['org_name'].'%')->column('id'); $where[] = ['org_id','in',$orgs]; } return Dept::where($this->searchWhere)->where($where) ->field('id,name,org_id,leader,mobile,status,sort,create_time') ->limit($this->limitOffset, $this->limitLength) ->order(['sort' => 'desc', 'id' => 'desc']) ->select()->each(function($item){ $org = Orgs::where('id',$item['org_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['leader'])->findOrEmpty(); $item['org_name'] = $org->isEmpty() ? '' : $org['name']; $item['leader'] = $admin['name']; return $item; }) ->toArray(); } /** * @notes 获取数量 * @return int * @author 段誉 * @date 2022/5/26 9:48 */ public function count(): int { $params = $this->request->param(); $where = []; if(isset($params['org_name']) && $params['org_name'] != ''){ $orgs = Orgs::where('name','like','%'.$params['org_name'].'%')->column('id'); $where[] = ['org_id','in',$orgs]; } return Dept::where($this->searchWhere)->where($where)->count(); } }