feat: 添加"抄送我的"审批列表选项
后端修改:
- ApprovalService::getList 添加 'cc' 类型查询
- 从 form_data.cc_users 中查找包含当前用户的订单
- 兼容两种数据格式:[{id:29}] 或 [29]
前端修改:
- 添加"抄送我的"标签页
- 更新类型定义支持 'cc' 类型
- approvalListParams 类型添加 'cc' 选项
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,36 @@ class ApprovalService
|
||||
$query->whereIn('id', $approvedOrderIds)
|
||||
->whereIn('status', [ApprovalOrder::STATUS_APPROVED, ApprovalOrder::STATUS_REJECTED, ApprovalOrder::STATUS_CANCELLED]);
|
||||
break;
|
||||
case 'cc':
|
||||
// 获取抄送给我的订单
|
||||
$allOrders = ApprovalOrder::where('status', '!=', ApprovalOrder::STATUS_DRAFT)->get();
|
||||
$ccOrderIds = [];
|
||||
|
||||
foreach ($allOrders as $order) {
|
||||
$formData = $order->form_data ?? [];
|
||||
$ccUsers = $formData['cc_users'] ?? [];
|
||||
|
||||
// 兼容两种格式:[{id:29, name:'...'}] 或 [29] 或 [{id:29}]
|
||||
if (!empty($ccUsers)) {
|
||||
if (is_array($ccUsers[0] ?? null) && isset($ccUsers[0]['id'])) {
|
||||
// 对象数组格式: [{id:29, name:'...'}]
|
||||
$ccUserIds = array_column($ccUsers, 'id');
|
||||
} else if (is_numeric($ccUsers[0] ?? null)) {
|
||||
// ID数组格式: [29, 30]
|
||||
$ccUserIds = $ccUsers;
|
||||
} else {
|
||||
$ccUserIds = [];
|
||||
}
|
||||
|
||||
if (in_array($userId, $ccUserIds)) {
|
||||
$ccOrderIds[] = $order->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_log("🔍 Debug 'cc' query: userId={$userId}, ccOrderIds=" . json_encode($ccOrderIds));
|
||||
$query->whereIn('id', $ccOrderIds);
|
||||
break;
|
||||
}
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
Reference in New Issue
Block a user