['check_date'], '%like%' => ['check_name', 'check_user', 'check_company', 'check_area'], ]; } /** * @notes 获取安全检查列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/19 16:10 */ public function lists(): array { return SafetyCheck::where($this->searchWhere) ->field(['id', 'org_id', 'dept_id', 'project_id', 'check_name', 'check_date', 'check_user', 'check_company', 'check_area', 'check_item', 'check_result', 'modify_company', 'resp_user', 'risk_level', 'safety_hazard', 'modify_term', 'remark', 'file', 'check_nature', 'quality_hazard', 'sub_table']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); $item['org_name'] = $org['name']; $item['dept_name'] = $dept['name']; $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; return $item; }) ->toArray(); } /** * @notes 获取安全检查数量 * @return int * @author likeadmin * @date 2023/12/19 16:10 */ public function count(): int { return SafetyCheck::where($this->searchWhere)->count(); } }