diff --git a/app/adminapi/controller/supervision_connect/SupervisionProjectCaseReviewController.php b/app/adminapi/controller/supervision_connect/SupervisionProjectCaseReviewController.php new file mode 100644 index 000000000..a4cecad4f --- /dev/null +++ b/app/adminapi/controller/supervision_connect/SupervisionProjectCaseReviewController.php @@ -0,0 +1,108 @@ +dataLists(new SupervisionProjectCaseReviewLists()); + } + + + /** + * @notes 添加工程监理--项目方案评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function add() + { + $params = (new SupervisionProjectCaseReviewValidate())->post()->goCheck('add'); + $result = SupervisionProjectCaseReviewLogic::add($params,$this->adminId); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SupervisionProjectCaseReviewLogic::getError()); + } + + + /** + * @notes 编辑工程监理--项目方案评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function edit() + { + $params = (new SupervisionProjectCaseReviewValidate())->post()->goCheck('edit'); + $result = SupervisionProjectCaseReviewLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SupervisionProjectCaseReviewLogic::getError()); + } + + + /** + * @notes 删除工程监理--项目方案评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function delete() + { + $params = (new SupervisionProjectCaseReviewValidate())->post()->goCheck('delete'); + SupervisionProjectCaseReviewLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取工程监理--项目方案评审详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function detail() + { + $params = (new SupervisionProjectCaseReviewValidate())->goCheck('detail'); + $result = SupervisionProjectCaseReviewLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/supervision_connect/SupervisionProjectCaseReviewLists.php b/app/adminapi/lists/supervision_connect/SupervisionProjectCaseReviewLists.php new file mode 100644 index 000000000..d1e36a309 --- /dev/null +++ b/app/adminapi/lists/supervision_connect/SupervisionProjectCaseReviewLists.php @@ -0,0 +1,83 @@ + ['project_id', 'review_type'], + '%like%' => ['case_name'], + ]; + } + + + /** + * @notes 获取工程监理--项目方案评审列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function lists(): array + { + return SupervisionProjectCaseReview::withoutField('update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['project_manager'] = $project['project_manager']; + $data['review_type_text'] = $data->review_type_text; + }) + ->toArray(); + } + + + /** + * @notes 获取工程监理--项目方案评审数量 + * @return int + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function count(): int + { + return SupervisionProjectCaseReview::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/supervision_connect/SupervisionProjectCaseReviewLogic.php b/app/adminapi/logic/supervision_connect/SupervisionProjectCaseReviewLogic.php new file mode 100644 index 000000000..624ec0538 --- /dev/null +++ b/app/adminapi/logic/supervision_connect/SupervisionProjectCaseReviewLogic.php @@ -0,0 +1,125 @@ + $params['project_id'], + 'review_type' => $params['review_type'], + 'case_name' => $params['case_name'], + 'review_content' => $params['review_content'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'create_user' => $admin_id + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑工程监理--项目方案评审 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SupervisionProjectCaseReview::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'review_type' => $params['review_type'], + 'case_name' => $params['case_name'], + 'review_content' => $params['review_content'], + 'remark' => $params['remark'], + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'update_time' => time() + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除工程监理--项目方案评审 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public static function delete(array $params): bool + { + return SupervisionProjectCaseReview::destroy($params['id']); + } + + + /** + * @notes 获取工程监理--项目方案评审详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public static function detail($params): array + { + $data = SupervisionProjectCaseReview::withoutField('update_time,delete_time')->findOrEmpty($params['id']); + $project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty(); + $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); + $data['project_name'] = $project['project_name']; + $data['project_manager'] = $project['project_manager']; + $data['create_user_name'] = $create_user['name']; + $data['review_type_text'] = $data->review_type_text; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/supervision_connect/SupervisionProjectCaseReviewValidate.php b/app/adminapi/validate/supervision_connect/SupervisionProjectCaseReviewValidate.php new file mode 100644 index 000000000..4174aa18b --- /dev/null +++ b/app/adminapi/validate/supervision_connect/SupervisionProjectCaseReviewValidate.php @@ -0,0 +1,140 @@ + 'require|checkData', + 'project_id' => 'require|checkProject', + 'review_type' => 'require|checkReviewType', + 'case_name' => 'require', + 'review_content' => 'require', + 'annex' => 'checkAnnex' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_id' => '项目id', + 'review_type' => '专项审批类型', + 'case_name' => '方案名称', + 'review_content' => '评审内容', + 'remark' => '备注', + 'create_user' => '创建人', + ]; + + + /** + * @notes 添加场景 + * @return SupervisionProjectCaseReviewValidate + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function sceneAdd() + { + return $this->remove('id',true); + } + + + /** + * @notes 编辑场景 + * @return SupervisionProjectCaseReviewValidate + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function sceneEdit() + {} + + + /** + * @notes 删除场景 + * @return SupervisionProjectCaseReviewValidate + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SupervisionProjectCaseReviewValidate + * @author likeadmin + * @date 2024/03/04 17:27 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = SupervisionProjectCaseReview::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + + public function checkProject($value): bool|string + { + $data = SupervisionProject::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '项目信息不存在'; + } + return true; + } + + public function checkReviewType($value){ + $dict = DictData::where('type_value','supervision_planning_approval_type')->column('value'); + if(!in_array($value,$dict)){ + return '专项审批类型审批数据值无效'; + } + return true; + } + + public function checkAnnex($value): bool|string + { + if(!empty($value) && $value != '' && !is_array($value)){ + return '附件格式错误'; + } + return true; + } + +} \ No newline at end of file diff --git a/app/common/model/supervision_connect/SupervisionProjectCaseReview.php b/app/common/model/supervision_connect/SupervisionProjectCaseReview.php new file mode 100644 index 000000000..c6951f4ad --- /dev/null +++ b/app/common/model/supervision_connect/SupervisionProjectCaseReview.php @@ -0,0 +1,42 @@ +column('name','value'); + return !empty($data['review_type']) ? $dict[$data['review_type']] : ''; + } +} \ No newline at end of file