This commit is contained in:
yaooo 2023-12-12 17:49:16 +08:00
commit e4c18b2b93

View File

@ -110,23 +110,33 @@ 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']);
$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();
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);
}
}