|
@@ -7,7 +7,7 @@ namespace app\bug\controller;
|
|
|
use app\bug\model\WorkAction;
|
|
|
use app\bug\model\WorkUser;
|
|
|
use app\user\model\Account;
|
|
|
-use think\App;
|
|
|
+use app\user\model\AccountCompany;use think\App;
|
|
|
use think\facade\Validate;
|
|
|
class WorkRole extends Base{
|
|
|
public function __construct(App $app) {
|
|
@@ -190,16 +190,59 @@ class WorkRole extends Base{
|
|
|
return success('获取成功',$info);
|
|
|
}
|
|
|
|
|
|
+// public function WorkRoleList(){
|
|
|
+// $param = $this->request->param(['role_id'=>'','companyNo'=>'','status'=>'','apply_id'=>'','work_id'=>'',
|
|
|
+// 'belong'=>'','account_id'=>'','page'=>1,'size'=>15],'post','trim');
|
|
|
+// $where=[];
|
|
|
+// if($param['companyNo']!='')$where[]=['workRole.companyNo','=',$param['companyNo']];
|
|
|
+// if($param['belong']!='')$where[]=['workRole.belong','=',$param['belong']];
|
|
|
+// if($param['role_name']!='')$where[]=['role_id','=',$param['role_id']];
|
|
|
+// if($param['status']!='')$where[]=['workUser.status','=',$param['status']];
|
|
|
+// if($param['apply_id']!='')$where[]=['workUser.apply_id','=',$param['apply_id']];
|
|
|
+// $list =WorkUser::with(['account'])->withJoin(['workRole'],'left')->where($where)->order('workUser.id desc')
|
|
|
+// ->paginate(['list_rows'=>$param['size'],'page'=>$param['page']]);
|
|
|
+//
|
|
|
+// return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
|
|
|
+// }
|
|
|
+//
|
|
|
public function WorkRoleList(){
|
|
|
- $param = $this->request->param(['role_name'=>'','companyNo'=>'','work_id'=>'','belong'=>'','account_id'=>'','page'=>1,
|
|
|
- 'size'=>15],'post','trim');
|
|
|
- $where=[];
|
|
|
- if($param['companyNo']!='')$where[]=['workRole.companyNo','=',$param['companyNo']];
|
|
|
- if($param['belong']!='')$where[]=['workRole.belong','=',$param['belong']];
|
|
|
- if($param['role_name']!='')$where[]=['workRole.role_name','like',"%{$param['role_name']}%"];
|
|
|
- if($param['work_id']!='')$where[]=['work_id','=',$param['work_id']];
|
|
|
- $list =WorkUser::with(["account"])->withJoin(["workRole"],"left")->where($where)->order('workUser.id desc')
|
|
|
+ $param = $this->request->param(['companyNo'=>'','status'=>'','apply_id'=>'',
|
|
|
+ 'belong'=>'','account_id'=>'','page'=>1,'size'=>15],'post','trim');
|
|
|
+ $where=[["is_del","=",0]];
|
|
|
+ $workWhere=[['status','=',1]];
|
|
|
+ if($param['companyNo']!='')$where[]=['companyNo','=',$param['companyNo']];
|
|
|
+ if($param['belong']!=''){
|
|
|
+ $workWhere[]=["belong","=",$param['belong']];
|
|
|
+ }
|
|
|
+ if($param['apply_id']!=''){
|
|
|
+ $workWhere[]=['apply_id','=',$param['apply_id']];
|
|
|
+ }
|
|
|
+ $uidArr = WorkUser::with(['workRole'])->where($workWhere)->column('account_id');
|
|
|
+ if($param['status']!==''){
|
|
|
+ if($param['status']==1){
|
|
|
+ $where[]=['account_id','in',$uidArr];
|
|
|
+ }else{
|
|
|
+ $where[]=['account_id','not in',$uidArr];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $list =AccountCompany::with(["accountInfo"])->where($where)->order('id desc')
|
|
|
->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');
|
|
|
+ foreach ($list->items() as &$item){
|
|
|
+ $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();
|
|
|
+ }
|
|
|
+ }
|
|
|
return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
|
|
|
}
|
|
|
}
|