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:
root
2026-02-26 18:33:53 +08:00
parent 0942cb1af0
commit ea7f0f8820
3 changed files with 33 additions and 2 deletions
+30
View File
@@ -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();
+1 -1
View File
@@ -106,7 +106,7 @@ export interface ApprovalActionParams {
// 列表查询参数
export interface ApprovalListParams {
type?: 'my' | 'pending' | 'approved'
type?: 'my' | 'pending' | 'approved' | 'cc'
page?: number
pageSize?: number
}
+2 -1
View File
@@ -46,7 +46,7 @@ export default function ApprovalList() {
const { t } = useTranslation()
const navigate = useNavigate()
const [activeTab, setActiveTab] = useState<'my' | 'pending' | 'approved'>('my')
const [activeTab, setActiveTab] = useState<'my' | 'pending' | 'approved' | 'cc'>('my')
const [list, setList] = useState<ApprovalItem[]>([])
const [loading, setLoading] = useState(false)
const [hasMore, setHasMore] = useState(false)
@@ -179,6 +179,7 @@ export default function ApprovalList() {
<Tabs.Tab title="我发起的" key="my" />
<Tabs.Tab title="待我审批" key="pending" />
<Tabs.Tab title="我已审批" key="approved" />
<Tabs.Tab title="抄送我的" key="cc" />
</Tabs>
<PullToRefresh onRefresh={handleRefresh}>