|
@@ -101,28 +101,26 @@ class WorkTypeMode extends Base
|
|
|
*/
|
|
|
public function getRolesUser($id,$orgId,$work=-1){
|
|
|
$roles = $this->getRoles($id,$orgId);
|
|
|
-
|
|
|
-
|
|
|
foreach ($roles as $k=>$v){
|
|
|
$children = model('Roles')->getChildrenIds($v['id'],$orgId);
|
|
|
- $user = [];
|
|
|
- $map = [];
|
|
|
- if($children){
|
|
|
- $map[] = ['u.del','=',0];
|
|
|
- $map[] = ['u.enable','=',1];
|
|
|
- $map[] = ['ur.roles_id','in',$children];
|
|
|
- if($work >= 0){
|
|
|
- $map[] = ['u.work','=',$work];
|
|
|
- }
|
|
|
- $user = Db::name('user_roles')
|
|
|
- ->alias('ur')
|
|
|
- ->join('user u','u.id = ur.user_id')
|
|
|
- ->where($map)
|
|
|
- ->field('u.id,u.real_name')
|
|
|
- ->select();
|
|
|
+ $children = $children?$children:[]; // 项目角色覆盖,无下级角色,取用户时添加本角色
|
|
|
+ $children[] = $v['id'];
|
|
|
|
|
|
+ $map = [];
|
|
|
|
|
|
+ $map[] = ['u.del','=',0];
|
|
|
+ $map[] = ['u.enable','=',1];
|
|
|
+ $map[] = ['ur.roles_id','in',$children];
|
|
|
+ if($work >= 0){
|
|
|
+ $map[] = ['u.work','=',$work];
|
|
|
}
|
|
|
+ $user = Db::name('user_roles')
|
|
|
+ ->alias('ur')
|
|
|
+ ->join('user u','u.id = ur.user_id')
|
|
|
+ ->where($map)
|
|
|
+ ->field('u.id,u.real_name')
|
|
|
+ ->select();
|
|
|
+
|
|
|
$roles[$k]['user'] = $user?$user:[];
|
|
|
}
|
|
|
return $roles;
|