SubmitConfirmCard.tsx
6.9 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import { useMemo } from 'react';
import { InfoCircleFilled, ExclamationCircleOutlined } from '@ant-design/icons';
import { UCard, UCheckbox, UTag } from '@uj/ui';
import type { StoreImportCheckVO } from '@/api/modules/store';
import { useAppStore } from '@/store/useAppStore';
export interface SubmitConfirmInfo {
storeName: string;
storeMerchantNo: string;
categoryCount: number;
sceneCount: number;
totalRows: number;
operatingCost: string;
operatingCostDetail: string;
approvalChain: string;
approvalChainTag: string;
approvalChainDesc: string;
expectedApprover: string;
}
const labelStyle: React.CSSProperties = {
width: 120,
flex: 'none',
fontSize: 13,
color: '#8A94A6',
};
const valueStyle: React.CSSProperties = {
fontSize: 13,
color: '#1A202C',
fontWeight: 500,
};
const descStyle: React.CSSProperties = {
fontSize: 12,
color: '#9CA3AF',
marginLeft: 6,
};
function buildInfoFromCheckResult(vo: StoreImportCheckVO): SubmitConfirmInfo {
const preview = vo.previewRows ?? [];
const first = preview[0];
const deco = Math.round(first?.costDecoration ?? 0);
const monthly = Math.round(first?.costMonthly ?? 0);
const labor = Math.round(first?.costLabor ?? 0);
const total = deco + monthly + labor;
const approvalRole = vo.nextRoleName ?? '-';
return {
storeName: vo.storeName ?? '-',
storeMerchantNo: vo.merchantNo ?? '-',
categoryCount: vo.distinctProductCategoryCount ?? 6,
sceneCount: vo.distinctBusinessSceneCount ?? 2,
totalRows: vo.productCategoryRowCount ?? vo.totalRows ?? 12,
operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` : '-',
operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`,
approvalChain: approvalRole,
approvalChainTag: '两级审批',
approvalChainDesc: '提交后直接进入两级审批,无中间节点',
expectedApprover: `${approvalRole}`,
};
}
export interface SubmitConfirmCardProps {
info?: SubmitConfirmInfo;
checkResult?: StoreImportCheckVO;
checked?: boolean;
onCheckedChange?: (checked: boolean) => void;
}
export function SubmitConfirmCard({
info,
checkResult,
checked = true,
onCheckedChange,
}: SubmitConfirmCardProps) {
const { currentUser } = useAppStore();
const userName = currentUser.name ?? '管理员';
const fallbackInfo: SubmitConfirmInfo = useMemo(
() => buildInfoFromCheckResult(checkResult ?? ({} as StoreImportCheckVO)),
[checkResult, userName],
);
const finalInfo: SubmitConfirmInfo = info ?? fallbackInfo;
/**
* 红框两处「共 N 行」的取值:
* - 只要存在校验失败(failRows>0)→ 本次提交的都是通过行 → 显示 passRows(通过行数,例如 11)
* - 全通过(failRows=0)→ 显示 productCategoryRowCount / totalRows(总解析行数,例如 12)
* - 不再依赖 onlyPass 字段(父组件可能不传),直接按业务结果决定
*/
const displayRows =
checkResult &&
typeof checkResult.failRows === 'number' &&
checkResult.failRows > 0 &&
typeof checkResult.passRows === 'number'
? checkResult.passRows
: finalInfo.totalRows;
const infoRows: Array<{
label: string;
value: React.ReactNode;
desc?: string;
extra?: React.ReactNode;
}> = [
{
label: '门店名称',
value: finalInfo.storeName,
},
{
label: '门店商户号',
value: finalInfo.storeMerchantNo,
},
{
label: '产品分类',
value: `${finalInfo.categoryCount} 个`,
desc: `(${finalInfo.sceneCount} 个业务场景,共 ${displayRows} 行)`,
},
{
label: '运营成本合计',
value: <span style={{ color: '#2B5CE6', fontWeight: 600 }}>{finalInfo.operatingCost}</span>,
desc: finalInfo.operatingCostDetail,
},
{
label: '触发审批链',
value: finalInfo.approvalChain,
extra: (
<UTag color="processing" bordered={false} style={{ marginLeft: 6 }}>
{finalInfo.approvalChainTag}
</UTag>
),
desc: finalInfo.approvalChainDesc,
},
{
label: '预计审批人',
value: finalInfo.expectedApprover,
},
];
return (
<UCard
styles={{ body: { padding: '20px 24px' } }}
style={{ marginBottom: 20, border: '1px solid #E5E7EB', borderRadius: 10 }}
title={
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#2B5CE6', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600 }}>提交确认</span>
</div>
}
>
{checkResult && (checkResult.failRows ?? 0) > 0 && (
<div
style={{
padding: '10px 14px',
borderRadius: 8,
background: '#FFF7ED',
border: '1px solid #FED7AA',
display: 'flex',
alignItems: 'flex-start',
gap: 8,
marginBottom: 16,
}}
>
<ExclamationCircleOutlined
style={{ color: '#EA580C', fontSize: 16, marginTop: 1, flex: 'none' }}
/>
<div style={{ flex: 1, fontSize: 12, lineHeight: '20px' }}>
<span style={{ color: '#9A3412', fontWeight: 600 }}>
本次存在校验失败数据:共 {checkResult.failRows} 行失败。
</span>
<span style={{ color: '#7C2D12', marginLeft: 4 }}>
本次将只提交「通过 {checkResult.passRows ?? 0} 行(listingIds 共{' '}
{checkResult.listingIds?.length ?? 0}{' '}
条)」进入审批,失败行需要您下载明细后修正再上传。
</span>
</div>
</div>
)}
<div
style={{
padding: '14px 16px',
background: '#F9FAFB',
borderRadius: 8,
marginBottom: 18,
}}
>
<UCheckbox
checked={checked}
onChange={(e) => onCheckedChange?.(e.target.checked)}
style={{ fontSize: 13, fontWeight: 500 }}
>
<span style={{ color: '#374151' }}>
我已确认该门店 {finalInfo.sceneCount} 个业务场景共 {displayRows} 行数据准确无误
</span>
</UCheckbox>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
提交后如需调整,请在该门店「待审批」状态下撤回。
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
{infoRows.map((r) => (
<div key={r.label} style={{ display: 'flex', alignItems: 'flex-start' }}>
<span style={labelStyle}>{r.label}</span>
<div style={{ flex: 1, display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
<span style={valueStyle}>{r.value}</span>
{r.extra}
{r.desc && <span style={descStyle}>{r.desc}</span>}
</div>
</div>
))}
</div>
</UCard>
);
}