['project_id', 'traffic'], '%like%' => ['trip_apply_code', 'origin_address', 'target_address'], ]; } /** * @notes 获取出差申请列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/01/17 09:22 */ public function lists(): array { return ProjectTripApply::where($this->searchWhere) ->field(['id', 'project_id', 'trip_apply_code', 'origin_address', 'target_address', 'traffic', 'start_date', 'end_date', 'reason', 'days', 'remark']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $manager = ProjectManagerAppointment::field('project_manager')->where('project_id',$data['project_id'])->findOrEmpty(); $data['traffic_text'] = $data->traffic_text; $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; if($manager->isEmpty()){ $data['project_manager'] = ''; }else{ $admin = Admin::field('name')->where('id',$manager['project_manager'])->findOrEmpty(); $data['project_manager'] = $admin['name']; } return $data; }) ->toArray(); } /** * @notes 获取出差申请数量 * @return int * @author likeadmin * @date 2024/01/17 09:22 */ public function count(): int { return ProjectTripApply::where($this->searchWhere)->count(); } }