dataLists(new BuildReportLists()); } /** * @notes 添加施工汇报 * @return \think\response\Json * @author likeadmin * @date 2023/12/22 16:08 */ public function add() { $params = (new BuildReportValidate())->post()->goCheck('add'); $result = BuildReportLogic::add($params, $this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(BuildReportLogic::getError()); } /** * @notes 获取施工汇报详情 * @return \think\response\Json * @author likeadmin * @date 2023/12/22 16:08 */ public function detail() { $params = (new BuildReportValidate())->goCheck('detail'); $result = BuildReportLogic::detail($params); return $this->data($result); } public function personDetails(): \think\response\Json { $params = $this->request->get(['report_id', 'page_no', 'page_size']); if (empty($params['report_id'])) { return $this->fail('缺少必要参数'); } $pageNo = empty($params['page_no']) ? 1 : $params['page_no']; $pageSize = empty($params['page_size']) ? 15 : $params['page_size']; $reportInfo = BuildReport::field('plan_id')->where('id', $params['report_id'])->findOrEmpty(); if ($reportInfo->isEmpty()) { return $this->fail('施工汇报数据不存在'); } $planInfo = BuildPlan::field('price,unit')->where('id', $reportInfo['plan_id'])->findOrEmpty(); $data = BuildReportDetail::field('person_id,work_num')->where('report_id', $params['report_id']) ->page($pageNo, $pageSize)->order('id desc') ->select()->each(function ($item) use ($planInfo) { $person = ProjectPersonnel::field('name,idcard,work_type,remark')->where('id', $item['person_id'])->findOrEmpty(); $item['person_name'] = $person['name']; $item['person_idcard'] = $person['idcard']; $item['remark'] = $person['remark']; $item['person_work_type_text'] = $person->work_type_text; $item['price'] = $planInfo['price']; $item['unit'] = $planInfo['unit']; $item['amount'] = $item['price'] * $item['work_num']; return $item; }) ->toArray(); $count = BuildReportDetail::field('id')->where('report_id', $params['report_id'])->count(); $result = [ 'count' => $count, 'page_no' => $pageNo, 'page_size' => $pageSize, 'lists' => $data ]; return $this->success('请求成功', $result); } }