Commit e60207c2 by 李伟康

feat(template-import): 完善失败详情卡片并重构政策确认表格列

为失败详情卡片新增文件大小展示功能,优先使用后端返回的文件大小,兜底使用上传文件的实际尺寸
重构政策确认表格的列配置,调整产品分类列的分组和表头样式
从模板导入页面传递选中文件的大小到失败详情组件
1 parent 91cd1d9e
Pipeline #341 for e60207c2 failed in 0 seconds
...@@ -5,6 +5,8 @@ import type { StoreImportFailVO, StoreImportCheckVO } from '@/api/modules/store' ...@@ -5,6 +5,8 @@ import type { StoreImportFailVO, StoreImportCheckVO } from '@/api/modules/store'
export interface FailDetailCardProps { export interface FailDetailCardProps {
checkResult?: StoreImportCheckVO; checkResult?: StoreImportCheckVO;
/** 上传文件的字节数(兜底:后端可能不返回 fileSize,用 File 对象的 size 字段) */
fileSize?: number;
/** 点击「重新上传」时触发(通常回到 Step 0 并清空文件) */ /** 点击「重新上传」时触发(通常回到 Step 0 并清空文件) */
onReUpload?: () => void; onReUpload?: () => void;
} }
...@@ -32,7 +34,7 @@ function triggerDownloadFailFile(url: string) { ...@@ -32,7 +34,7 @@ function triggerDownloadFailFile(url: string) {
} }
} }
export function FailDetailCard({ checkResult, onReUpload }: FailDetailCardProps) { export function FailDetailCard({ checkResult, fileSize, onReUpload }: FailDetailCardProps) {
const failRows = (checkResult?.failRows ?? 0) as number; const failRows = (checkResult?.failRows ?? 0) as number;
const failFileUrl = checkResult?.failFileUrl ?? null; const failFileUrl = checkResult?.failFileUrl ?? null;
const failures = (checkResult?.failures ?? []) as StoreImportFailVO[]; const failures = (checkResult?.failures ?? []) as StoreImportFailVO[];
...@@ -48,11 +50,13 @@ export function FailDetailCard({ checkResult, onReUpload }: FailDetailCardProps) ...@@ -48,11 +50,13 @@ export function FailDetailCard({ checkResult, onReUpload }: FailDetailCardProps)
* 底部 L1 / L2 通过校验文字(复用 checkResult 的字段,无则从 failures.length 推断) * 底部 L1 / L2 通过校验文字(复用 checkResult 的字段,无则从 failures.length 推断)
*/ */
const l1 = useMemo(() => { const l1 = useMemo(() => {
// 文件大小:优先后端 fileSize,兜底用传入的 File.size(字节)
const rawSize = typeof checkResult?.fileSize === 'number' ? checkResult.fileSize : fileSize;
const size = const size =
typeof checkResult?.fileSize === 'number' typeof rawSize === 'number'
? checkResult.fileSize === 0 ? rawSize === 0
? '0' ? '0'
: `${Math.max(1, Math.round(checkResult.fileSize / 1024))}KB` : `${Math.max(1, Math.round(rawSize / 1024))}KB`
: ''; : '';
const total = typeof checkResult?.totalRows === 'number' ? `${checkResult.totalRows} 行` : ''; const total = typeof checkResult?.totalRows === 'number' ? `${checkResult.totalRows} 行` : '';
const version = checkResult?.templateVersion ? `模板版本${checkResult.templateVersion}` : ''; const version = checkResult?.templateVersion ? `模板版本${checkResult.templateVersion}` : '';
...@@ -62,7 +66,7 @@ export function FailDetailCard({ checkResult, onReUpload }: FailDetailCardProps) ...@@ -62,7 +66,7 @@ export function FailDetailCard({ checkResult, onReUpload }: FailDetailCardProps)
: `格式 .xlsx / ${size}${total ? ' / ' + total : ''}${version ? ' / ' + version : ''}`, : `格式 .xlsx / ${size}${total ? ' / ' + total : ''}${version ? ' / ' + version : ''}`,
]; ];
return parts.filter(Boolean).join(' · '); return parts.filter(Boolean).join(' · ');
}, [checkResult]); }, [checkResult, fileSize]);
const l2 = useMemo(() => { const l2 = useMemo(() => {
const template = checkResult?.templateVersion const template = checkResult?.templateVersion
......
...@@ -144,13 +144,20 @@ export function buildPolicyColumns( ...@@ -144,13 +144,20 @@ export function buildPolicyColumns(
}), }),
render: (v: string) => <SceneTag text={v} />, render: (v: string) => <SceneTag text={v} />,
}, },
],
},
// ------------- 第二组:商务政策(14 列) -------------
{
title: '商务政策',
align: 'center',
children: [
{ {
title: '产品分类', title: '产品分类',
dataIndex: 'productCategory', dataIndex: 'productCategory',
key: 'productCategory', key: 'productCategory',
width: 280, width: 280,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ onCell: () => ({
style: { style: {
...cellStyle, ...cellStyle,
...@@ -161,13 +168,6 @@ export function buildPolicyColumns( ...@@ -161,13 +168,6 @@ export function buildPolicyColumns(
}), }),
render: (v: string) => <CategoryTag text={v} />, render: (v: string) => <CategoryTag text={v} />,
}, },
],
},
// ------------- 第二组:商务政策(14 列) -------------
{
title: '商务政策',
align: 'center',
children: [
// 管理层市场费 1 // 管理层市场费 1
{ {
title: '管理层市场费1计算模式', title: '管理层市场费1计算模式',
......
...@@ -146,7 +146,11 @@ export default function TemplateImport() { ...@@ -146,7 +146,11 @@ export default function TemplateImport() {
{currentStep === 1 && ( {currentStep === 1 && (
<> <>
<ValidationStats checkResult={checkResult ?? undefined} /> <ValidationStats checkResult={checkResult ?? undefined} />
<FailDetailCard checkResult={checkResult ?? undefined} onReUpload={handleReUpload} /> <FailDetailCard
checkResult={checkResult ?? undefined}
fileSize={selectedFile?.size}
onReUpload={handleReUpload}
/>
<ValidationActionBar nextDisabled={failCount > 0} onBack={goPrev} onNextStep={goNext} /> <ValidationActionBar nextDisabled={failCount > 0} onBack={goPrev} onNextStep={goNext} />
</> </>
)} )}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!