feat: 实现默认审批人和抄送人功能

- 后端新增 getDefaultApprovers 接口,从审批流程配置中获取默认审批人和抄送人
- 前端申请页面加载时自动获取并显示默认审批人和抄送人
- 添加默认审批流程配置:1个审批人(闫继光) + 2个抄送人(孟启、程丽敏)
- 移除后端 support 目录下的自定义 Db 和 Model 类,使用 Webman 官方实现
- 前端选择页面优化:优先从 sessionStorage 恢复,否则加载后端默认配置

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-25 18:54:38 +08:00
parent e3e2843835
commit 3968e94195
10 changed files with 184 additions and 117 deletions
@@ -457,4 +457,71 @@ class BusinessTripService
return $businessTrip->fresh(['itineraries', 'approvalOrder']);
});
}
/**
* 获取默认审批人和抄送人
* 从审批流程配置表中获取
*/
public function getDefaultApprovers(int $userId): array
{
// 获取出差审批流程
$flow = ApprovalFlow::where('business_type', 'business_trip')
->where('status', 1)
->first();
if (!$flow) {
return [
'approvers' => [],
'cc_users' => [],
];
}
// 获取流程节点
$nodes = ApprovalNode::where('flow_id', $flow->id)
->orderBy('order')
->get();
$approvers = [];
$ccUsers = [];
foreach ($nodes as $node) {
$nodeApprovers = $node->approvers ?? [];
if (empty($nodeApprovers)) {
continue;
}
// 根据节点类型获取用户信息
$users = User::whereIn('id', $nodeApprovers)
->where('status', 1)
->get();
$userList = [];
foreach ($nodeApprovers as $userId) {
$user = $users->firstWhere('id', $userId);
if ($user) {
$userList[] = [
'id' => $user->id,
'name' => $user->name,
'avatar' => $user->avatar,
'position' => $user->position,
];
}
}
// 审批节点(approver, and_approve, or_approve)作为审批人
if ($node->isApprovalNode()) {
$approvers = array_merge($approvers, $userList);
}
// 通知节点(notify)作为抄送人
elseif ($node->type === ApprovalNode::TYPE_NOTIFY) {
$ccUsers = array_merge($ccUsers, $userList);
}
}
return [
'approvers' => $approvers,
'cc_users' => $ccUsers,
];
}
}