ValidationStats.tsx
2.13 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
102
103
104
105
106
107
108
109
110
111
112
113
import { UCard } from '@uj/ui';
export interface StatItem {
label: string;
value: string | number;
desc: string;
tone: 'primary' | 'success' | 'warning' | 'default';
}
interface StatCardProps {
item: StatItem;
}
const toneMap: Record<StatItem['tone'], { border: string; accent: string }> = {
primary: {
border: '1px solid #C7D2FE',
accent: '#4F46E5',
},
success: {
border: '1px solid #86EFAC',
accent: '#16A34A',
},
warning: {
border: '1px solid #FCD34D',
accent: '#CA8A04',
},
default: {
border: '1px solid #E5E7EB',
accent: '#6B7280',
},
};
function StatCard({ item }: StatCardProps) {
const tone = toneMap[item.tone];
return (
<UCard
styles={{ body: { padding: '18px 20px' } }}
style={{
borderLeft: `3px solid ${tone.accent}`,
border: tone.border,
borderRadius: 10,
background: '#fff',
}}
>
<div
style={{
fontSize: 13,
color: '#6B7280',
marginBottom: 10,
fontWeight: 500,
}}
>
{item.label}
</div>
<div
style={{
fontSize: 26,
fontWeight: 700,
color: '#1A202C',
marginBottom: 8,
lineHeight: 1.2,
}}
>
{item.value}
</div>
<div
style={{
fontSize: 12,
color: '#9CA3AF',
lineHeight: 1.5,
}}
>
{item.desc}
</div>
</UCard>
);
}
export interface ValidationStatsProps {
stats?: StatItem[];
}
const defaultStats: StatItem[] = [
{
label: '解析总行数',
value: '13',
desc: '1 家门店 · 2 个业务场景 · 12 行',
tone: 'primary',
},
{
label: '校验通过',
value: '12',
desc: '可提交审批',
tone: 'success',
},
];
export function ValidationStats({ stats = defaultStats }: ValidationStatsProps) {
return (
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(4, 1fr)',
gap: 16,
marginBottom: 20,
}}
>
{stats.map((s) => (
<StatCard key={s.label} item={s} />
))}
</div>
);
}