dataLists(new CustomerDemandLists()); } /** * @notes 添加客户需求 * @return \think\response\Json * @author likeadmin * @date 2023/11/24 21:18 */ public function add() { $params = (new CustomerDemandValidate())->post()->goCheck('add'); $result = CustomerDemandLogic::add($params); if (true === $result) { return $this->success('添加成功', [], 1, 1); } return $this->fail(CustomerDemandLogic::getError()); } /** * @notes 编辑客户需求 * @return \think\response\Json * @author likeadmin * @date 2023/11/24 21:18 */ public function edit() { $params = (new CustomerDemandValidate())->post()->goCheck('edit'); $result = CustomerDemandLogic::edit($params); if (true === $result) { return $this->success('编辑成功', [], 1, 1); } return $this->fail(CustomerDemandLogic::getError()); } /** * @notes 删除客户需求 * @return \think\response\Json * @author likeadmin * @date 2023/11/24 21:18 */ public function delete() { $params = (new CustomerDemandValidate())->post()->goCheck('delete'); CustomerDemandLogic::delete($params); return $this->success('删除成功', [], 1, 1); } /** * @notes 获取客户需求详情 * @return \think\response\Json * @author likeadmin * @date 2023/11/24 21:18 */ public function detail() { $params = (new CustomerDemandValidate())->goCheck('detail'); $result = CustomerDemandLogic::detail($params); return $this->data($result); } //根据项目id获取客户需求列表 public function getListByProjectId(): \think\response\Json { $params = $this->request->get(['project_id','page_size','page_no']); if(empty($params['project_id'])){ return $this->fail('缺少必要参数'); } $pageSize = !empty($params['page_size']) ? $params['page_size'] : 15; $pageNo = !empty($params['page_size']) ? $params['page_no'] : 1; $data = CustomerDemand::where('project_id',$params['project_id']) ->field(['id', 'project_id', 'theme', 'supplier', 'supplier_contacts', 'importance', 'recording_time', 'demand_content', 'annex']) ->order(['id' => 'desc'])->page($pageNo,$pageSize) ->select()->each(function($item){ $item['importance_text'] = $item->importance_text; $item['recording_time'] = date('Y-m-d H:i:s',$item['recording_time']); $project = Project::field('name,custom_id')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['custom_name'] = $custom['name']; return $item; })->toArray(); $count = CustomerDemand::field('id')->where('project_id',$params['project_id'])->count(); $result = [ 'count' => $count, 'page_no' => $pageNo, 'page_size' => $pageSize, 'lists' => $data ]; return $this->success('请求成功',$result); } }