From 738210732f19d722387ba3c5cbb77d96b626e896 Mon Sep 17 00:00:00 2001 From: weiz Date: Tue, 12 Dec 2023 17:35:47 +0800 Subject: [PATCH 1/2] update --- .../custom/CustomerDemandController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/adminapi/controller/custom/CustomerDemandController.php b/app/adminapi/controller/custom/CustomerDemandController.php index 8fef292e7..91f445072 100644 --- a/app/adminapi/controller/custom/CustomerDemandController.php +++ b/app/adminapi/controller/custom/CustomerDemandController.php @@ -110,13 +110,15 @@ class CustomerDemandController extends BaseAdminController //根据项目id获取客户需求列表 public function getListByProjectId(): \think\response\Json { - $project_id = $this->request->get('project_id'); - if(empty($project_id)){ + $params = $this->request->get(['project_id','page_size','page_no']); + if(empty($params['project_id'])){ return $this->fail('缺少必要参数'); } - $data = CustomerDemand::where('project_id',$project_id) + $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']) + ->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']); @@ -126,7 +128,14 @@ class CustomerDemandController extends BaseAdminController $item['custom_name'] = $custom['name']; return $item; })->toArray(); - return $this->success('请求成功',$data); + $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); } } \ No newline at end of file From eacfc0f08e5ccaa54e32276facbb16a23c40749c Mon Sep 17 00:00:00 2001 From: weiz Date: Tue, 12 Dec 2023 17:46:53 +0800 Subject: [PATCH 2/2] update --- app/adminapi/controller/custom/CustomerDemandController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/adminapi/controller/custom/CustomerDemandController.php b/app/adminapi/controller/custom/CustomerDemandController.php index 91f445072..e6020a300 100644 --- a/app/adminapi/controller/custom/CustomerDemandController.php +++ b/app/adminapi/controller/custom/CustomerDemandController.php @@ -122,9 +122,10 @@ class CustomerDemandController extends BaseAdminController ->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(); + $project = Project::field('name,project_code,custom_id')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $item['project_name'] = $project['name']; + $item['project_code'] = $project['project_code']; $item['custom_name'] = $custom['name']; return $item; })->toArray();