dataLists(new ProjectLists()); } /** * @notes 添加 * @return \think\response\Json * @author likeadmin * @date 2023/11/12 14:30 */ public function add() { $params = (new ProjectValidate())->post()->goCheck('add'); $result = ProjectLogic::add($params,$this->adminId); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(ProjectLogic::getError()); } /** * @notes 编辑 * @return \think\response\Json * @author likeadmin * @date 2023/11/12 14:30 */ public function edit() { $params = (new ProjectValidate())->post()->goCheck('edit'); $result = ProjectLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(ProjectLogic::getError()); } /** * @notes 删除 * @return \think\response\Json * @author likeadmin * @date 2023/11/12 14:30 */ public function delete() { $params = (new ProjectValidate())->post()->goCheck('delete'); ProjectLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取详情 * @return \think\response\Json * @author likeadmin * @date 2023/11/12 14:30 */ public function detail() { $params = (new ProjectValidate())->goCheck('detail'); $result = ProjectLogic::detail($params); return $this->data($result); } //项目合同列表 public function contracts(): \think\response\Json { $params = $this->request->get(['project_id','page_no','page_size']); if(empty($params['project_id'])){ return $this->fail('参数错误'); } $pageNo = empty($params['page_no']) ? 1 : $params['page_no']; $pageSize = empty($params['page_size']) ? 15 : $params['page_size']; $project = Project::where('id',$params['project_id'])->findOrEmpty(); if($project->isEmpty()){ return $this->fail('项目数据不存在'); } $data = Contract::field('id,customer_id,contract_name,contract_code,contract_type,contract_status,business_director,contract_date,amount,amount_daxie') ->where('project_id',$project['id']) ->select()->each(function($item)use($project){ $item['contract_type_text'] = $item->contract_type_text; $item['contract_status_text'] = $item->contract_status_text; $custom = Custom::field('name')->where('id',$item['customer_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['business_director'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['project_code'] = $project['project_code']; $item['custom_name'] = $custom['name']; $item['business_director_name'] = $admin['name']; return $item; })->toArray(); $count = Contract::field('id')->where('project_id',$project['id'])->count(); $result = [ 'count' => $count, 'page_no' => $pageNo, 'page_size' => $pageSize, 'lists' => $data ]; return $this->success('请求成功',$result); } }