fix: 客户检索分页查询
This commit is contained in:
@@ -831,9 +831,10 @@ class Work extends Common
|
||||
$user_id = $param['user_id'];
|
||||
$currPage = isset($param['currPage']) ? $param['currPage'] : 1;
|
||||
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 10;
|
||||
$project_name = isset($param['project_name']) ? $param['project_name'] : '';
|
||||
|
||||
$user = new User();
|
||||
$project_work = $this->GetProjectListPaginated($user_id, $currPage, $pageSize);
|
||||
$project_work = $this->GetProjectListPaginated($user_id, $currPage, $pageSize, $project_name);
|
||||
|
||||
for ($i = 0; $i < count($project_work['list']); $i++) {
|
||||
$involve_manager = $project_work['list'][$i]['involve_manager'];
|
||||
@@ -849,7 +850,7 @@ class Work extends Common
|
||||
}
|
||||
|
||||
//获取参与的客户项目列表 - 分页版本
|
||||
public function GetProjectListPaginated($user_id, $currPage, $pageSize)
|
||||
public function GetProjectListPaginated($user_id, $currPage, $pageSize, $project_name = '')
|
||||
{
|
||||
//判断登录用户的角色,如果是管理员,就获取所有的项目信息
|
||||
$user_info = db('system_user')->where('id', $user_id)->find();
|
||||
@@ -859,6 +860,11 @@ class Work extends Common
|
||||
->where('p.project_state', '<', 10) //未关闭的项目
|
||||
->field('p.*, s.desp as project_state_name,1 as project_types');
|
||||
|
||||
// 添加项目名称模糊查询
|
||||
if (!empty($project_name)) {
|
||||
$query->where('p.project_name', 'like', '%' . $project_name . '%');
|
||||
}
|
||||
|
||||
if (1 != $user_info['user_role']) {
|
||||
$query->where(function ($query) use ($user_id) {
|
||||
$query->where('p.involve_manager', $user_id)
|
||||
@@ -877,6 +883,11 @@ class Work extends Common
|
||||
->join('project_state s', 's.id =p.project_state', 'left')
|
||||
->where('p.project_state', '<', 10);
|
||||
|
||||
// 添加项目名称模糊查询到总数查询
|
||||
if (!empty($project_name)) {
|
||||
$totalQuery->where('p.project_name', 'like', '%' . $project_name . '%');
|
||||
}
|
||||
|
||||
if (1 != $user_info['user_role']) {
|
||||
$totalQuery->where(function ($query) use ($user_id) {
|
||||
$query->where('p.involve_manager', $user_id)
|
||||
|
||||
Reference in New Issue
Block a user