diff --git a/app/home/controller/Api.php b/app/home/controller/Api.php index 94793af..91504d3 100644 --- a/app/home/controller/Api.php +++ b/app/home/controller/Api.php @@ -91,6 +91,7 @@ class api extends BaseController $res['data'] = []; if($exist){ $where = array(); + $whereOr = array(); $map1 = []; $map2 = []; $map3 = []; @@ -98,11 +99,14 @@ class api extends BaseController $map2[] = ['director_uid', '=', $this->uid]; $map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$this->uid},assist_admin_ids)")]; + $whereOr =[$map1,$map2,$map3]; $where[] = ['delete_time', '=', 0]; - $list = Db::name('ProjectTask')->where($where) - ->where(function ($query) use ($map1, $map2, $map3) { - $query->where($map1)->whereor($map2)->whereor($map3); - }) + $list = Db::name('ProjectTask') + ->where(function ($query) use ($whereOr) { + if (!empty($whereOr)) + $query->whereOr($whereOr); + }) + ->where($where) ->withoutField('content,md_content') ->order('flow_status asc') ->order('id desc') diff --git a/app/home/controller/Index.php b/app/home/controller/Index.php index f6d4bfd..338978f 100644 --- a/app/home/controller/Index.php +++ b/app/home/controller/Index.php @@ -86,7 +86,7 @@ class Index extends BaseController $v = explode(',', $v); $adminMenus = array_merge($adminMenus, $v); } - $menu = Db::name('AdminRule')->where(['menu' => 1, 'status' => 1])->where('id', 'in', $adminMenus)->order('sort asc')->select()->toArray(); + $menu = Db::name('AdminRule')->where(['menu' => 1, 'status' => 1])->where('id', 'in', $adminMenus)->order('sort asc,id asc')->select()->toArray(); $list = list_to_tree($menu); \think\facade\Cache::tag('adminMenu')->set('menu' . $admin['id'], $list); } @@ -198,6 +198,7 @@ class Index extends BaseController $whereProject[] = ['id', 'in', $project_ids]; $projectCount = Db::name('Project')->where($whereProject)->count(); + $whereOr = array(); $map1 = []; $map2 = []; $map3 = []; @@ -207,9 +208,14 @@ class Index extends BaseController $map2[] = ['director_uid', '=', $uid]; $map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$uid},assist_admin_ids)")]; $map4[] = ['project_id', 'in', $project_ids]; - $taskCount = Db::name('ProjectTask')->where([['delete_time', '=', 0]])->where(function ($query) use ($map1, $map2, $map3, $map4) { - $query->where($map1)->whereor($map2)->whereor($map3)->whereor($map4); - })->count(); + + $whereOr =[$map1,$map2,$map3,$map4]; + $taskCount = Db::name('ProjectTask') + ->where(function ($query) use ($whereOr) { + if (!empty($whereOr)) + $query->whereOr($whereOr); + }) + ->where([['delete_time', '=', 0]])->count(); $total[] = array( 'name' => '项目', diff --git a/app/project/model/ProjectDocument.php b/app/project/model/ProjectDocument.php index 0ab5e98..22a3417 100644 --- a/app/project/model/ProjectDocument.php +++ b/app/project/model/ProjectDocument.php @@ -28,10 +28,15 @@ class ProjectDocument extends Model $where[] = ['title|content', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['delete_time', '=', 0]; + + $whereOr =[$map1,$map2]; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; - $list = Db::name('ProjectDocument')->where(function ($query) use ($map1, $map2) { - $query->where($map1)->whereor($map2); - })->where($where) + $list = Db::name('ProjectDocument') + ->where(function ($query) use ($whereOr) { + if (!empty($whereOr)) + $query->whereOr($whereOr); + }) + ->where($where) ->withoutField('content,md_content') ->order('id desc') ->paginate($rows, false, ['query' => $param]) diff --git a/app/project/model/ProjectTask.php b/app/project/model/ProjectTask.php index 39bb513..18961c1 100644 --- a/app/project/model/ProjectTask.php +++ b/app/project/model/ProjectTask.php @@ -44,6 +44,7 @@ class ProjectTask extends Model //列表 function list($param) { $where = array(); + $whereOr = array(); $map1 = []; $map2 = []; $map3 = []; @@ -56,6 +57,7 @@ class ProjectTask extends Model $map2[] = ['director_uid', '=', $param['uid']]; $map3[] = ['', 'exp', Db::raw("FIND_IN_SET({$param['uid']},assist_admin_ids)")]; $map4[] = ['project_id', 'in', $project_ids]; + $whereOr =[$map1,$map2,$map3,$map4]; } if (!empty($param['type'])) { $where[] = ['type', '=', $param['type']]; @@ -76,10 +78,14 @@ class ProjectTask extends Model $where[] = ['title|content', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['delete_time', '=', 0]; + $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; - $list = Db::name('ProjectTask')->where(function ($query) use ($map1, $map2, $map3, $map4) { - $query->where($map1)->whereor($map2)->whereor($map3)->whereor($map4); - })->where($where) + $list = Db::name('ProjectTask') + ->where(function ($query) use ($whereOr) { + if (!empty($whereOr)) + $query->whereOr($whereOr); + }) + ->where($where) ->withoutField('content,md_content') ->order('flow_status asc') ->order('id desc')