|
@@ -215,9 +215,9 @@ class WorkRole extends Base{
|
|
|
$workWhere[]=["belong","=",$param['belong']];
|
|
|
}
|
|
|
if($param['apply_id']!=''){
|
|
|
- $workWhere[]=['apply_id','=',$param['apply_id']];
|
|
|
+ $workWhere[]=['workUser.apply_id','=',$param['apply_id']];
|
|
|
}
|
|
|
- $uidArr = WorkUser::with(['workRole'])->where($workWhere)->column('account_id');
|
|
|
+ $uidArr = WorkUser::withJoin(['workRole'],"left")->where($workWhere)->column('account_id');
|
|
|
if($param['status']!==''){
|
|
|
if($param['status']==1){
|
|
|
$where[]=['account_id','in',$uidArr];
|
|
@@ -227,20 +227,24 @@ class WorkRole extends Base{
|
|
|
}
|
|
|
|
|
|
|
|
|
- $list =AccountCompany::with(["accountInfo"])->where($where)->order('id desc')
|
|
|
+ $list =AccountCompany::with(["accountInfo"=>["userInfo","accountItem"=>["itemName"]]])->where($where)->order('id asc')
|
|
|
->paginate(['list_rows'=>$param['size'],'page'=>$param['page']]);
|
|
|
- $uidArr = WorkUser::with(['workRole'])->where(['account_id'=>array_unique(array_column($list->items(),"account_id"))])
|
|
|
- ->column("role_name,role_id,workUser.status,workUser.apply_name",'account_id');
|
|
|
+// $uidArr = WorkUser::with(['workRole'])->where(['account_id'=>array_unique(array_column($list->items(),"account_id"))])
|
|
|
+// ->column("role_id,status,apply_name",'account_id');
|
|
|
foreach ($list->items() as &$item){
|
|
|
+ $uidArr = WorkUser::withJoin(['workRole'],'left')
|
|
|
+ ->where(['account_id'=>$item['account_id'],'companyNo'=>$item['companyNo'],"belong"=>$param['belong']])
|
|
|
+ ->field("work_user.*,workRole.role_name")
|
|
|
+ ->findOrEmpty();
|
|
|
$item['role_name'] ='';
|
|
|
$item['status'] =0;
|
|
|
$item['apply_name'] = '';
|
|
|
$item['usedNum']=0;
|
|
|
- if(isset($uidArr[$item['account_id']])){
|
|
|
- $item['role_name'] = $uidArr[$item['account_id']]['role_name']??'';
|
|
|
- $item['status'] = $uidArr[$item['account_id']]['status']??0;
|
|
|
- $item['apply_name'] = $uidArr[$item['account_id']]['apply_name']??'';
|
|
|
- $item['usedNum'] = WorkUser::where(['role_id'=>$uidArr[$item['account_id']]['role_id']])->count();
|
|
|
+ if($uidArr->isEmpty()==false){
|
|
|
+ $item['role_name'] = $uidArr->role_name??'';
|
|
|
+ $item['status'] = $uidArr->status??0;
|
|
|
+ $item['apply_name'] = $uidArr->apply_name??'';
|
|
|
+ $item['usedNum'] = WorkUser::where(['role_id'=>$uidArr->role_id])->count();
|
|
|
}
|
|
|
}
|
|
|
return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
|