SettleAmountPanel.tsx
2.54 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
import { UButton, UModal } from '@uj/ui';
import type { SettleAmountMap } from '@/api';
import { SETTLE_STATISTICS, SETTLE_STATISTICS_PREVIEW } from '@/features/shared/dictionaries';
import { EMPTY } from '@/features/shared/format';
/**
* 累计结算金额:老系统把 10 个统计项写死在 constants.statisticsTypeList,
* 列表上方只放前 4 个,剩下的靠「查看更多」弹窗展开;接口按 confId 平铺回金额。
* 这里保留同一套顺序与文案,只把「写死的下标取数」换成按 key 取。
*/
function itemsOf(amounts: SettleAmountMap | undefined) {
return SETTLE_STATISTICS.map((item) => ({
key: item.key,
label: item.label,
value:
amounts?.[item.key] === undefined || amounts?.[item.key] === ''
? EMPTY
: String(amounts?.[item.key]),
}));
}
export interface SettleAmountStripProps {
amounts: SettleAmountMap | undefined;
/** 老系统只有「查看更多」一个动作,展开弹窗。 */
onOpenAll: () => void;
}
export function SettleAmountStrip({ amounts, onOpenAll }: SettleAmountStripProps) {
const preview = itemsOf(amounts).slice(0, SETTLE_STATISTICS_PREVIEW);
return (
<div className="uj-points-statistics-card">
<div className="uj-points-statistics-head">
<span>累计结算金额</span>
<UButton type="link" onClick={onOpenAll}>
查看更多
</UButton>
</div>
<div className="uj-points-statistics">
{preview.map((item) => (
<div className="uj-points-statistics-item" key={item.key}>
<div className="uj-points-statistics-label">{item.label}</div>
<div className="uj-points-statistics-value">
{item.value}
<span>元</span>
</div>
</div>
))}
</div>
</div>
);
}
export interface SettleAmountDialogProps {
open: boolean;
amounts: SettleAmountMap | undefined;
onClose: () => void;
}
export function SettleAmountDialog({ open, amounts, onClose }: SettleAmountDialogProps) {
return (
<UModal title="累计结算金额" open={open} footer={null} width={900} onCancel={onClose}>
<div className="uj-points-statistics">
{itemsOf(amounts).map((item) => (
<div className="uj-points-statistics-item" key={item.key}>
<div className="uj-points-statistics-label">{item.label}</div>
<div className="uj-points-statistics-value">
{item.value}
<span>元</span>
</div>
</div>
))}
</div>
</UModal>
);
}