update 用户首页
This commit is contained in:
parent
ad17a2ddd0
commit
153a7c9dd7
|
@ -40,12 +40,9 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||||
*/
|
*/
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
$allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end', 'company_id', 'province', 'city', 'area', 'street', 'village'];
|
return [
|
||||||
if (empty($this->params['company_id'])) {
|
'=' => ['keyword', 'create_time_start', 'create_time_end', 'province', 'city', 'area', 'street', 'village']
|
||||||
unset($allowSearch['company_id']);
|
];
|
||||||
unset($this->params['company_id']);
|
|
||||||
}
|
|
||||||
return array_intersect(array_keys($this->params), $allowSearch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,31 +57,16 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||||
*/
|
*/
|
||||||
public function lists(): array
|
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";
|
$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'])
|
->append(['role_name'])
|
||||||
->with(['company'])
|
->with(['company'])
|
||||||
->withAttr('role_name', function ($value, $data){
|
->withAttr('role_name', function ($value, $data){
|
||||||
$role = UserRole::where('id', $data['group_id'])->find();
|
$role = UserRole::where('id', $data['group_id'])->find();
|
||||||
return $role? $role['name']: "无";
|
return $role? $role['name']: "无";
|
||||||
})
|
})
|
||||||
->where($where)
|
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->field($field)
|
->field($field)
|
||||||
->order('id desc')
|
->order('id desc')
|
||||||
|
@ -111,7 +93,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return User::withSearch($this->setSearch(), $this->params)->count();
|
return User::where($this->searchWhere)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue