mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
feat 新增部门负责人标识并排第一位
This commit is contained in:
parent
6e68100f86
commit
0b1f433fe4
@ -707,7 +707,14 @@ class UsersController extends AbstractController
|
||||
$query->where("department", "")->orWhere("department", ",,");
|
||||
});
|
||||
} else {
|
||||
$builder->where("department", "like", "%,{$keys['department']},%");
|
||||
// 关联user_departments表中owner_userid查询出负责人,重新排序,部门负责人始终在前面
|
||||
$builder->where(function($query) use ($keys) {
|
||||
$query->where("department", "like", "%,{$keys['department']},%")
|
||||
->orWhereIn('userid', function ($query) use ($keys) {
|
||||
$query->select('owner_userid')->from('user_departments')->where("id", "=", trim($keys['department'], ','))
|
||||
->orderByRaw("FIELD(owner_userid,{$keys['department']}) DESC");
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if ($getCheckinMac && isset($keys['checkin_mac'])) {
|
||||
@ -719,11 +726,16 @@ class UsersController extends AbstractController
|
||||
$builder->whereNull('disable_at');
|
||||
$builder->where('bot', 0);
|
||||
}
|
||||
$list = $builder->orderByDesc('userid')->paginate(Base::getPaginate(50, 20));
|
||||
$builder = $keys['department'] == '0' ? $builder->orderByDesc('userid') : $builder;
|
||||
$list = $builder->paginate(Base::getPaginate(50, 20));
|
||||
//
|
||||
if ($getCheckinMac) {
|
||||
if ($getCheckinMac || isset($keys['department'])) {
|
||||
$list->transform(function (User $user) {
|
||||
$user->checkin_macs = UserCheckinMac::select(['id', 'mac', 'remark'])->whereUserid($user->userid)->orderBy('id')->get();
|
||||
// 当为部门负责人时,字段identity值为['dm'],表示部门负责人
|
||||
if ($user->isDepartmentOwner()) {
|
||||
$user->identity = ['dm'];
|
||||
}
|
||||
return $user;
|
||||
});
|
||||
}
|
||||
|
||||
@ -149,6 +149,15 @@ class User extends AbstractModel
|
||||
return implode(', ', $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为部门负责人
|
||||
*/
|
||||
public function isDepartmentOwner()
|
||||
{
|
||||
return UserDepartment::where('owner_userid', $this->userid)->exists();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取机器人所有者
|
||||
* @return int|mixed
|
||||
|
||||
@ -342,6 +342,13 @@ export default {
|
||||
}
|
||||
}))
|
||||
}
|
||||
if (identity.includes("dm")) {
|
||||
arr.push(h('Tag', {
|
||||
props: {
|
||||
color: 'blue'
|
||||
}
|
||||
}, this.$L('负责人')))
|
||||
}
|
||||
if (identity.includes("ldap")) {
|
||||
arr.push(h('Tag', {
|
||||
props: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user