['happen_date'], '%like%' => ['type', 'device_accident'], ]; } /** * @notes 获取质量事故列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2023/12/21 14:03 */ public function lists(): array { return QualityAccident::where($this->searchWhere) ->field(['id', 'org_id', 'dept_id', 'project_id', 'happen_date', 'type', 'device_accident', 'contractor_user', 'our_company_user', 'not_our_company_user', 'content', 'remark', 'file', 'add_user', 'update_user']) ->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/21 14:03 */ public function count(): int { return QualityAccident::where($this->searchWhere)->count(); } }