ApprovalDetailDialog.tsx
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { useQuery } from '@tanstack/react-query';
import { Skeleton, UTimeline, UText, UModal, UTitle } from '@uj/ui';
import { withdrawApi, type ApprovalLogItem } from '@/api';
import { APPROVAL_OPERATION, APPROVAL_STATUS, statusMeta } from '@/features/shared/dictionaries';
import { dateTimeOr, numberOr, textOr } from '@/features/shared/format';
import { DetailGrid, type DetailValue } from '@/features/shared/DetailCell';
export interface ApprovalDetailDialogProps {
open: boolean;
id?: string;
onClose: () => void;
}
/**
* 时间线一项:老系统先把「付款审核」的结果清空(那一步的结果由后面的 OA 审批给出),
* 再按结果文案给圆点颜色,颜色表在这里一次说清。
*/
function timelineItem(item: ApprovalLogItem) {
const result = Number(item.operationType) === 1 ? '' : textOr(item.operationResult, '');
const color =
result === '审批中'
? 'orange'
: result === '通过'
? 'green'
: result === '不通过' || result === '审批驳回'
? 'red'
: 'gray';
return {
color,
children: (
<div>
<div>
{APPROVAL_OPERATION[Number(item.operationType)] ?? textOr(item.operationType)}
{result ? (
<UText className="uj-points-strong" style={{ marginLeft: 8 }}>
{result}
</UText>
) : null}
</div>
<UText type="secondary">{textOr(item.operationNote, '')}</UText>
</div>
),
};
}
/**
* 批次查看弹窗:字段与顺序逐字对齐老系统 approveView.vue(订单信息 5 项、付款信息 4 项、操作记录时间线)。
* 详情与操作记录是两个接口,老系统先取详情再取记录,这里并行取。
*/
export function ApprovalDetailDialog({ open, id, onClose }: ApprovalDetailDialogProps) {
const detail = useQuery({
queryKey: ['points', 'approval', id ?? ''],
queryFn: () => withdrawApi.approvalDetail(String(id)),
enabled: open && !!id,
});
const logs = useQuery({
queryKey: ['points', 'approval-log', id ?? ''],
queryFn: () => withdrawApi.approvalLog(String(id)),
enabled: open && !!id,
});
const row = detail.data;
const orderCells: DetailValue[] = row
? [
{ label: '批次号', value: textOr(row.batchNo) },
{ label: '客户数量', value: numberOr(row.customerCount) },
{ label: '积分总额', value: numberOr(row.pointTotal) },
{ label: '付款总额/元', value: numberOr(row.paymentTotal) },
{ label: '状态', tag: statusMeta(APPROVAL_STATUS, row.status) },
]
: [];
const paymentCells: DetailValue[] = row
? [
{ label: '付款渠道', value: textOr(row.paymentChannel) },
{ label: '付款主体', value: textOr(row.paymentSubject) },
{ label: '代征主体', value: textOr(row.channelAccount?.levyName) },
{ label: '渠道到账时间', value: dateTimeOr(row.channelSettleTime) },
]
: [];
return (
<UModal title="详细信息" open={open} footer={null} width={900} onCancel={onClose}>
{detail.isPending ? (
<Skeleton variant="detail" />
) : (
<div className="uj-points-detail">
<UTitle level={5}>订单信息</UTitle>
<DetailGrid cells={orderCells} />
<UTitle level={5}>付款信息</UTitle>
<DetailGrid cells={paymentCells} />
{logs.data?.length ? (
<>
<UTitle level={5}>操作记录</UTitle>
<UTimeline items={logs.data.map(timelineItem)} />
</>
) : null}
</div>
)}
</UModal>
);
}