From 153a7c9dd7bb3a86bf623d0ea761c9367466ac11 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 24 Jan 2024 09:21:15 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=94=A8=E6=88=B7=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/lists/user/UserLists.php | 28 +++++---------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/app/adminapi/lists/user/UserLists.php b/app/adminapi/lists/user/UserLists.php index 4e504e5d..128a6720 100644 --- a/app/adminapi/lists/user/UserLists.php +++ b/app/adminapi/lists/user/UserLists.php @@ -40,12 +40,9 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function setSearch(): array { - $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end', 'company_id', 'province', 'city', 'area', 'street', 'village']; - if (empty($this->params['company_id'])) { - unset($allowSearch['company_id']); - unset($this->params['company_id']); - } - return array_intersect(array_keys($this->params), $allowSearch); + return [ + '=' => ['keyword', 'create_time_start', 'create_time_end', 'province', 'city', 'area', 'street', 'village'] + ]; } @@ -60,31 +57,16 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function lists(): array { - $where = []; - if(isset($this->params['company_id']) && $this->params['company_id'] > 0){ - $where[] = ['company_id', '=', $this->params['company_id']]; - }else{ - if($this->adminInfo['root']!=1){ - if($this->adminInfo['role_id'][0]==8){ - $where[]=['area_manager','=',$this->adminInfo['admin_id']]; - }else{ - $company_id=Db::name('company')->where('admin_id',$this->adminInfo['admin_id'])->value('id'); - $where[]=['company_id','=',$company_id]; - } - - } - } $field = "id,id contract,sn,nickname,sex,avatar,account,mobile,channel,create_time,admin_id,company_id,street,street as street_name,is_contract,group_id,invite_code"; - $lists = User::withSearch($this->setSearch(), $this->params) + $lists = User::where($this->searchWhere) ->append(['role_name']) ->with(['company']) ->withAttr('role_name', function ($value, $data){ $role = UserRole::where('id', $data['group_id'])->find(); return $role? $role['name']: "无"; }) - ->where($where) ->limit($this->limitOffset, $this->limitLength) ->field($field) ->order('id desc') @@ -111,7 +93,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface */ public function count(): int { - return User::withSearch($this->setSearch(), $this->params)->count(); + return User::where($this->searchWhere)->count(); }