Commit bf6ff2d8 by chenwq

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-store into v1.0.0

2 parents 6ba335c3 b6d3c81e
Pipeline #309 for bf6ff2d8 failed in 0 seconds
...@@ -27,6 +27,220 @@ export interface ImportSubmitPayload { ...@@ -27,6 +27,220 @@ export interface ImportSubmitPayload {
[key: string]: unknown; [key: string]: unknown;
} }
/** 校验失败明细行 */
export interface StoreImportFailVO {
rowIndex?: number;
storeName: string;
merchantNo: string;
productCategory: string;
/** 校验层级编码:L3-单元格级 L4-业务级 L5-重复上架级 */
levelCode: string;
/** 校验层级文案:如「L4 业务级」 */
levelLabel: string;
/** 失败原因 */
reason: string;
}
/** 导入行(产品分类明细) */
export interface StoreImportRowDTO {
/** 门店名称(营业执照全称) */
storeName: string;
merchantNo: string;
/** 业务场景(展示用 label,落库为 baseSceneCode) */
businessScene: string;
/** 业务场景编码(D+ baseSceneCode,如 110102) */
businessSceneCode: string;
/** 产品分类(系统字典标准名,可多级以「-」分隔) */
productCategory: string;
/** 产品分类 ID(D+ dj_car_life_goods_category_configuration.category_type) */
productCategoryId: number;
/** 产品分类层级(D+ dj_car_life_goods_category_configuration.level,1 起) */
productCategoryLevel: number;
marketFee1CalcMode: string;
marketFee1CalcWay: string;
marketFee1Value: number;
/** 数值单位:RATIO-比例 AMOUNT-金额(由计算方式推导) */
marketFee1Unit: string;
marketFee2CalcMode: string;
marketFee2CalcWay: string;
marketFee2Value: number;
marketFee2Unit: string;
/** 一线阳光是否开启线上积分:1-是 0-否 */
sunshine1OnlinePoint: number;
sunshine1CalcMode: string;
sunshine1CalcWay: string;
sunshine1Value: number;
sunshine1Unit: string;
sunshine2OnlinePoint: number;
sunshine2CalcMode: string;
sunshine2CalcWay: string;
sunshine2Value: number;
sunshine2Unit: string;
/** 装修、设备总投入 */
costDecoration: number;
/** 当月产生(房租、水电、耗材等) */
costMonthly: number;
/** 人工成本 */
costLabor: number;
}
/** POST /store/import/check 响应 data */
export interface StoreImportCheckVO {
templateVersion: string;
/** 解析总行数 */
totalRows: number;
/** 校验通过行数 */
passRows: number;
/** 校验失败行数 */
failRows: number;
storeName: string;
merchantNo: string;
/** 所属组织(完整层级路径 label,例如「优加主体 / 线上运营部」) */
orgPath: string;
/** 业务场景(多个以「/」分隔,label,例如「售后会员权益升级 / 售前延保」) */
businessScene: string;
/** 产品分类(去重后的 label,多个以「/」分隔,例如「太阳膜-原厂/车衣-原厂/精品-小桌板」) */
productCategories: string;
/** 校验失败明细 */
failures: StoreImportFailVO[];
/** 导入行(产品分类明细) */
previewRows: StoreImportRowDTO[];
/** 导入失败明细文件下载地址(全部成功时为 null) */
failFileUrl: string | null;
/** 下一个待审批角色名称,如「优加商务经理」 */
nextRoleName: string;
/** 去重后的产品分类数,例如 6(2 个业务场景 × 6 个分类 → 6) */
distinctProductCategoryCount: number;
/** 去重后的业务场景数,例如 2 */
distinctBusinessSceneCount: number;
/** 产品分类总行数,例如 12 */
productCategoryRowCount: number;
/** 本次落库 / 提交的上架记录 ID(按业务场景拆分,一条 = 一个场景) */
listingIds: number[];
/** 是否已落库(导入成功为 true;仅校验失败为 false) */
submitted: boolean;
}
/** POST /store/import/check 请求参数(FormData) */
export interface StoreImportCheckParams {
file: File;
/** 备注(可选,≤ 200 字) */
remark?: string;
}
/** POST /store/import/submit 请求体:把草稿记录提交为待审批(不重新解析文件) */
export interface StoreImportCommitDTO {
/** 导入返回的上架记录 ID 列表(同一门店的多个业务场景) */
listingIds: number[];
}
/** 校验失败明细行 */
export interface StoreImportFailVO {
rowIndex?: number;
storeName: string;
merchantNo: string;
productCategory: string;
/** 校验层级编码:L3-单元格级 L4-业务级 L5-重复上架级 */
levelCode: string;
/** 校验层级文案:如「L4 业务级」 */
levelLabel: string;
/** 失败原因 */
reason: string;
}
/** 导入行(产品分类明细) */
export interface StoreImportRowDTO {
/** 门店名称(营业执照全称) */
storeName: string;
merchantNo: string;
/** 业务场景(展示用 label,落库为 baseSceneCode) */
businessScene: string;
/** 业务场景编码(D+ baseSceneCode,如 110102) */
businessSceneCode: string;
/** 产品分类(系统字典标准名,可多级以「-」分隔) */
productCategory: string;
/** 产品分类 ID(D+ dj_car_life_goods_category_configuration.category_type) */
productCategoryId: number;
/** 产品分类层级(D+ dj_car_life_goods_category_configuration.level,1 起) */
productCategoryLevel: number;
marketFee1CalcMode: string;
marketFee1CalcWay: string;
marketFee1Value: number;
/** 数值单位:RATIO-比例 AMOUNT-金额(由计算方式推导) */
marketFee1Unit: string;
marketFee2CalcMode: string;
marketFee2CalcWay: string;
marketFee2Value: number;
marketFee2Unit: string;
/** 一线阳光是否开启线上积分:1-是 0-否 */
sunshine1OnlinePoint: number;
sunshine1CalcMode: string;
sunshine1CalcWay: string;
sunshine1Value: number;
sunshine1Unit: string;
sunshine2OnlinePoint: number;
sunshine2CalcMode: string;
sunshine2CalcWay: string;
sunshine2Value: number;
sunshine2Unit: string;
/** 装修、设备总投入 */
costDecoration: number;
/** 当月产生(房租、水电、耗材等) */
costMonthly: number;
/** 人工成本 */
costLabor: number;
}
/** POST /store/import/check 响应 data */
export interface StoreImportCheckVO {
templateVersion: string;
/** 解析总行数 */
totalRows: number;
/** 校验通过行数 */
passRows: number;
/** 校验失败行数 */
failRows: number;
storeName: string;
merchantNo: string;
/** 所属组织(完整层级路径 label,例如「优加主体 / 线上运营部」) */
orgPath: string;
/** 业务场景(多个以「/」分隔,label,例如「售后会员权益升级 / 售前延保」) */
businessScene: string;
/** 产品分类(去重后的 label,多个以「/」分隔,例如「太阳膜-原厂/车衣-原厂/精品-小桌板」) */
productCategories: string;
/** 校验失败明细 */
failures: StoreImportFailVO[];
/** 导入行(产品分类明细) */
previewRows: StoreImportRowDTO[];
/** 导入失败明细文件下载地址(全部成功时为 null) */
failFileUrl: string | null;
/** 下一个待审批角色名称,如「优加商务经理」 */
nextRoleName: string;
/** 去重后的产品分类数,例如 6(2 个业务场景 × 6 个分类 → 6) */
distinctProductCategoryCount: number;
/** 去重后的业务场景数,例如 2 */
distinctBusinessSceneCount: number;
/** 产品分类总行数,例如 12 */
productCategoryRowCount: number;
/** 本次落库 / 提交的上架记录 ID(按业务场景拆分,一条 = 一个场景) */
listingIds: number[];
/** 是否已落库(导入成功为 true;仅校验失败为 false) */
submitted: boolean;
}
/** POST /store/import/check 请求参数(FormData) */
export interface StoreImportCheckParams {
file: File;
/** 备注(可选,≤ 200 字) */
remark?: string;
}
/** POST /store/import/submit 请求体:把草稿记录提交为待审批(不重新解析文件) */
export interface StoreImportCommitDTO {
/** 导入返回的上架记录 ID 列表(同一门店的多个业务场景) */
listingIds: number[];
}
const APPROVAL_PATHS: Record<ApproveTab, string> = { const APPROVAL_PATHS: Record<ApproveTab, string> = {
todo: '/store/approval/pending', todo: '/store/approval/pending',
done: '/store/approval/done', done: '/store/approval/done',
...@@ -63,17 +277,19 @@ class Store extends ApiClient { ...@@ -63,17 +277,19 @@ class Store extends ApiClient {
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
} }
/** 上传模板文件做五级校验(FormData,请求体不参与签名,§3.1/§9.6) */ /** 上传模板文件做五级校验 + 落库草稿(失败时返回失败明细文件 URL,不落库) */
uploadImport(file: File, templateVersion = 'V1.0.1') { uploadImport(params: StoreImportCheckParams) {
const form = new FormData(); const form = new FormData();
form.append('file', file); form.append('file', params.file);
form.append('templateVersion', templateVersion); if (params.remark !== undefined && params.remark !== null) {
return this.post<{ taskId: string }>('/store/import/check', form); form.append('remark', String(params.remark));
}
return this.post<StoreImportCheckVO>('/store/import/check', form);
} }
/** 保持现有导入向导的调用契约,导入流程由独立模块维护。 */ /** 提交:把草稿记录提交为待审批(不重新解析文件,响应 data 类型同 check) */
submitImport(payload: ImportSubmitPayload) { submitImport(payload: StoreImportCommitDTO) {
return this.post<{ approveId: string }>('/store/import/submit', payload); return this.post<StoreImportCheckVO>('/store/import/submit', payload);
} }
listApprovals(tab: ApproveTab = 'todo', params: ApprovalPageParams = {}) { listApprovals(tab: ApproveTab = 'todo', params: ApprovalPageParams = {}) {
......
import { useEffect } from 'react';
import { InfoCircleFilled } from '@ant-design/icons'; import { InfoCircleFilled } from '@ant-design/icons';
import { UCard, UForm, UFormItem, USelect, UInput } from '@uj/ui'; import { UCard, UForm, UFormItem, USelect, UInput } from '@uj/ui';
import type { USelectProps } from '@uj/ui'; import type { USelectProps } from '@uj/ui';
...@@ -9,33 +10,50 @@ export interface ImportInfoValues { ...@@ -9,33 +10,50 @@ export interface ImportInfoValues {
remark?: string; remark?: string;
} }
// 注意:value 统一用 label 字符串,与后端 StoreImportCheckVO 返回的 orgPath / businessScene / productCategories 对齐
const orgOptions: USelectProps['options'] = [ const orgOptions: USelectProps['options'] = [
{ label: '优加主体 / 线上运营部', value: 'uj-online' }, { label: '优加主体 / 线上运营部', value: '优加主体 / 线上运营部' },
{ label: '优加主体 / 线下事业部', value: 'uj-offline' }, { label: '优加主体 / 线下事业部', value: '优加主体 / 线下事业部' },
]; ];
const sceneOptions: USelectProps['options'] = [ const sceneOptions: USelectProps['options'] = [
{ label: '售后会员权益升级 / 售前延保', value: 'warranty' }, { label: '售后会员权益升级 / 售前延保', value: '售后会员权益升级 / 售前延保' },
{ label: '汽车用品销售', value: 'accessories' }, { label: '汽车用品销售', value: '汽车用品销售' },
{ label: '保养服务', value: 'maintenance' }, { label: '保养服务', value: '保养服务' },
]; ];
const categoryOptions: USelectProps['options'] = [ const categoryOptions: USelectProps['options'] = [
{ label: '太阳膜-原厂', value: 'film-original' }, { label: '太阳膜-原厂', value: '太阳膜-原厂' },
{ label: '车衣-原厂', value: 'ppf-original' }, { label: '车衣-原厂', value: '车衣-原厂' },
{ label: '精品-小桌板', value: 'bp-table' }, { label: '精品-小桌板', value: '精品-小桌板' },
{ label: '精品-脚垫', value: 'bp-mat' }, { label: '精品-脚垫', value: '精品-脚垫' },
{ label: '精品-后备箱垫', value: 'bp-trunk' }, { label: '精品-后备箱垫', value: '精品-后备箱垫' },
{ label: '保养-基础A保', value: 'mt-a' }, { label: '保养-基础A保', value: '保养-基础A保' },
]; ];
const formItemLayout = { const formItemLayout = {
style: { marginBottom: 18 }, style: { marginBottom: 18 },
}; };
export function ImportInfoCard() { export interface ImportInfoCardProps {
values?: Partial<ImportInfoValues>;
onChange?: (values: ImportInfoValues) => void;
}
export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
const [form] = UForm.useForm<ImportInfoValues>(); const [form] = UForm.useForm<ImportInfoValues>();
// 受控回填:外部 values 变化时,把导入结果同步到表单
useEffect(() => {
if (values) {
form.setFieldsValue(values);
}
}, [values, form]);
const handleValuesChange = (_: Partial<ImportInfoValues>, all: ImportInfoValues) => {
onChange?.(all);
};
return ( return (
<UCard <UCard
styles={{ body: { padding: 20 } }} styles={{ body: { padding: 20 } }}
...@@ -50,10 +68,9 @@ export function ImportInfoCard() { ...@@ -50,10 +68,9 @@ export function ImportInfoCard() {
<UForm <UForm
form={form} form={form}
layout="vertical" layout="vertical"
initialValues={{ onValuesChange={handleValuesChange}
org: 'uj-online', onFinish={() => {
scene: 'warranty', onChange?.(form.getFieldsValue());
categories: ['film-original', 'ppf-original', 'bp-table'],
}} }}
> >
<div <div
...@@ -72,7 +89,11 @@ export function ImportInfoCard() { ...@@ -72,7 +89,11 @@ export function ImportInfoCard() {
name="org" name="org"
{...formItemLayout} {...formItemLayout}
> >
<USelect options={orgOptions} placeholder="请选择所属组织" /> <USelect
disabled
options={orgOptions}
placeholder="请选择所属组织"
/>
</UFormItem> </UFormItem>
<UFormItem <UFormItem
...@@ -84,7 +105,11 @@ export function ImportInfoCard() { ...@@ -84,7 +105,11 @@ export function ImportInfoCard() {
name="scene" name="scene"
{...formItemLayout} {...formItemLayout}
> >
<USelect options={sceneOptions} placeholder="请选择业务场景" /> <USelect
disabled
options={sceneOptions}
placeholder="请选择业务场景"
/>
</UFormItem> </UFormItem>
<UFormItem <UFormItem
...@@ -97,6 +122,7 @@ export function ImportInfoCard() { ...@@ -97,6 +122,7 @@ export function ImportInfoCard() {
{...formItemLayout} {...formItemLayout}
> >
<USelect <USelect
disabled
mode="multiple" mode="multiple"
options={categoryOptions} options={categoryOptions}
placeholder="请选择产品分类" placeholder="请选择产品分类"
......
...@@ -16,6 +16,13 @@ const bizPolicyHeaderStyle: React.CSSProperties = { ...@@ -16,6 +16,13 @@ const bizPolicyHeaderStyle: React.CSSProperties = {
fontSize: 13, fontSize: 13,
}; };
const costHeaderStyle: React.CSSProperties = {
background: '#FFF7ED',
color: '#C2410C',
fontWeight: 600,
fontSize: 13,
};
const cellStyle: React.CSSProperties = { const cellStyle: React.CSSProperties = {
fontSize: 12.5, fontSize: 12.5,
color: '#374151', color: '#374151',
...@@ -24,7 +31,18 @@ const cellStyle: React.CSSProperties = { ...@@ -24,7 +31,18 @@ const cellStyle: React.CSSProperties = {
function SceneTag({ text }: { text: string }) { function SceneTag({ text }: { text: string }) {
return ( return (
<UTag color="processing" bordered={false} style={{ fontSize: 12 }}> <UTag
color="processing"
bordered={false}
title={text}
style={{
fontSize: 12,
maxWidth: '100%',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{text} {text}
</UTag> </UTag>
); );
...@@ -32,14 +50,46 @@ function SceneTag({ text }: { text: string }) { ...@@ -32,14 +50,46 @@ function SceneTag({ text }: { text: string }) {
function CategoryTag({ text }: { text: string }) { function CategoryTag({ text }: { text: string }) {
return ( return (
<UTag color="success" bordered={false} style={{ fontSize: 12 }}> <UTag
color="success"
bordered={false}
title={text}
style={{
fontSize: 12,
maxWidth: '100%',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{text} {text}
</UTag> </UTag>
); );
} }
/** 金额列渲染(加粗深灰) */
function MoneyCell({ value }: { value: string }) {
return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}
/** 激励费列(数值加粗) */
function FeeValueCell({ value }: { value: string }) {
return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}
/** 金额列渲染(加粗深灰) */
function MoneyCell({ value }: { value: string }) {
return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}
/** 激励费列(数值加粗) */
function FeeValueCell({ value }: { value: string }) {
return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}
export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
return [ return [
// ------------- 第一组:门店信息(4 列) -------------
{ {
title: '门店信息', title: '门店信息',
align: 'center', align: 'center',
...@@ -77,23 +127,32 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -77,23 +127,32 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '产品分类', title: '产品分类',
dataIndex: 'productCategory', dataIndex: 'productCategory',
key: 'productCategory', key: 'productCategory',
width: 120, width: 280,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }), onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({
style: {
...cellStyle,
// 确保 tableLayout=fixed 下,Tag 内容超长时单元格不会溢出到右侧列
overflow: 'hidden',
whiteSpace: 'nowrap',
},
}),
render: (v: string) => <CategoryTag text={v} />, render: (v: string) => <CategoryTag text={v} />,
}, },
], ],
}, },
// ------------- 第二组:商务政策(14 列) -------------
{ {
title: '商务政策', title: '商务政策',
align: 'center', align: 'center',
children: [ children: [
// 管理层市场费 1
{ {
title: '管理层市场费1计算模式', title: '管理层市场费1计算模式',
dataIndex: 'mgmtFee1Mode', dataIndex: 'mgmtFee1Mode',
key: 'mgmtFee1Mode', key: 'mgmtFee1Mode',
width: 140, width: 150,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
...@@ -102,7 +161,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -102,7 +161,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费1计算方式', title: '管理层市场费1计算方式',
dataIndex: 'mgmtFee1CalcMethod', dataIndex: 'mgmtFee1CalcMethod',
key: 'mgmtFee1CalcMethod', key: 'mgmtFee1CalcMethod',
width: 140, width: 150,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
...@@ -111,17 +170,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -111,17 +170,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费1', title: '管理层市场费1',
dataIndex: 'mgmtFee1Value', dataIndex: 'mgmtFee1Value',
key: 'mgmtFee1Value', key: 'mgmtFee1Value',
width: 110, width: 130,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>, render: (v) => <FeeValueCell value={v as string} />,
}, },
// 管理层市场费 2
{ {
title: '管理层市场费2计算模式', title: '管理层市场费2计算模式',
dataIndex: 'mgmtFee2Mode', dataIndex: 'mgmtFee2Mode',
key: 'mgmtFee2Mode', key: 'mgmtFee2Mode',
width: 140, width: 150,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
...@@ -130,7 +190,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -130,7 +190,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费2计算方式', title: '管理层市场费2计算方式',
dataIndex: 'mgmtFee2CalcMethod', dataIndex: 'mgmtFee2CalcMethod',
key: 'mgmtFee2CalcMethod', key: 'mgmtFee2CalcMethod',
width: 140, width: 150,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
...@@ -139,17 +199,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -139,17 +199,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费2', title: '管理层市场费2',
dataIndex: 'mgmtFee2Value', dataIndex: 'mgmtFee2Value',
key: 'mgmtFee2Value', key: 'mgmtFee2Value',
width: 110, width: 130,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>, render: (v) => <FeeValueCell value={v as string} />,
}, },
// 一线阳光 1
{ {
title: '一线阳光是否开启线上积分', title: '一线阳光是否开启线上积分',
dataIndex: 'sunshineOnlinePoints', dataIndex: 'sunshineOnlinePoints',
key: 'sunshineOnlinePoints', key: 'sunshineOnlinePoints',
width: 150, width: 170,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
...@@ -158,10 +219,104 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] { ...@@ -158,10 +219,104 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '一线阳光计算模式', title: '一线阳光计算模式',
dataIndex: 'sunshineCalcMode', dataIndex: 'sunshineCalcMode',
key: 'sunshineCalcMode', key: 'sunshineCalcMode',
width: 130, width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光计算方式',
dataIndex: 'sunshineCalcMethod',
key: 'sunshineCalcMethod',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光激励费',
dataIndex: 'sunshineValue',
key: 'sunshineValue',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <FeeValueCell value={v as string} />,
},
// 一线阳光 2
{
title: '一线阳光2是否开启线上积分',
dataIndex: 'sunshine2OnlinePoints',
key: 'sunshine2OnlinePoints',
width: 180,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光2计算模式',
dataIndex: 'sunshine2CalcMode',
key: 'sunshine2CalcMode',
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光2计算方式',
dataIndex: 'sunshine2CalcMethod',
key: 'sunshine2CalcMethod',
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光2激励费',
dataIndex: 'sunshine2Value',
key: 'sunshine2Value',
width: 150,
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => <FeeValueCell value={v as string} />,
},
],
},
// ------------- 第三组:运营成本(3 列) -------------
{
title: '运营成本',
align: 'center',
children: [
{
title: '装修、设备总投入',
dataIndex: 'costDecoration',
key: 'costDecoration',
width: 160,
align: 'center',
onHeaderCell: () => ({ style: costHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <MoneyCell value={v as string} />,
},
{
title: '当月产生(房租、水电、耗材等)',
dataIndex: 'costMonthly',
key: 'costMonthly',
width: 220,
align: 'center',
onHeaderCell: () => ({ style: costHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <MoneyCell value={v as string} />,
},
{
title: '人工成本',
dataIndex: 'costLabor',
key: 'costLabor',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: costHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <MoneyCell value={v as string} />,
}, },
], ],
}, },
......
import { UCard, FillTable, UText } from '@uj/ui'; import { useMemo } from 'react';
import { UCard, UTable, UText } from '@uj/ui';
import type { UTableProps } from '@uj/ui';
import { buildPolicyColumns } from './columns'; import { buildPolicyColumns } from './columns';
import type { StoreImportRowDTO } from '@/api/modules/store';
import { mockPolicyRows, convertPreviewRows } from '../../tools/policyTableData';
import type { PolicyConfirmRow } from '../../tools/policyTableData'; import type { PolicyConfirmRow } from '../../tools/policyTableData';
const footerText = const footerText =
...@@ -7,25 +11,69 @@ const footerText = ...@@ -7,25 +11,69 @@ const footerText =
export interface PolicyConfirmTableProps { export interface PolicyConfirmTableProps {
dataSource?: PolicyConfirmRow[]; dataSource?: PolicyConfirmRow[];
previewRows?: StoreImportRowDTO[];
} }
export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) { export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTableProps) {
const columns = buildPolicyColumns(); const columns = useMemo(() => buildPolicyColumns() as any[], []);
// columns 预设宽度累加,保证横向滚动条出现
const scrollX = useMemo(() => {
const colWidths: number[] = [];
const walk = (arr: any[] | undefined) => {
if (!arr) return;
for (const c of arr) {
if (c.children && c.children.length > 0) walk(c.children);
else if (typeof c.width === 'number') colWidths.push(c.width);
else colWidths.push(160);
}
};
walk(columns);
return colWidths.reduce((a, b) => a + b, 0) + 40; // 加 40px 冗余
}, [columns]);
const rows: PolicyConfirmRow[] = useMemo(() => {
// 优先级:previewRows(接口真实数据) > dataSource > mock 兜底
if (Array.isArray(previewRows) && previewRows.length > 0) {
return convertPreviewRows(previewRows);
}
if (Array.isArray(dataSource) && dataSource.length > 0) {
return dataSource;
}
return mockPolicyRows;
}, [dataSource, previewRows]);
const tableProps = {
rowKey: (r: PolicyConfirmRow) =>
`${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`,
columns: columns as UTableProps<PolicyConfirmRow>['columns'],
dataSource: rows,
size: 'middle' as const,
// tableLayout='fixed' 强制按每列 width 渲染,避免 ant 自动压缩到父容器宽度
tableLayout: 'fixed' as const,
// 明确给 scroll.x,让 antd Table 内部生成横向滚动容器(内层 table width=x)
scroll: { x: scrollX },
pagination: false,
bordered: true,
};
return ( return (
<UCard <UCard
styles={{ body: { padding: '16px 16px 12px' } }} styles={{ body: { padding: '16px 16px 12px' } }}
style={{ border: '1px solid #E5E7EB', marginBottom: 20, borderRadius: 10 }} style={{
border: '1px solid #E5E7EB',
marginBottom: 20,
borderRadius: 10,
overflow: 'hidden',
}}
>
{/* 外层专属 wrapper:覆盖全局 index.css 关 ant Table 横向滚动的 !important 规则 */}
<div
className="policy-confirm-table-wrap"
style={{ width: '100%' }}
> >
<FillTable<PolicyConfirmRow> <UTable<PolicyConfirmRow> {...tableProps} />
rowKey={(r) => `${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`} </div>
columns={columns}
dataSource={dataSource}
size="middle"
scroll={{ x: 1600 }}
pagination={false}
bordered
/>
<div <div
style={{ style={{
marginTop: 12, marginTop: 12,
...@@ -38,6 +86,15 @@ export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) { ...@@ -38,6 +86,15 @@ export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) {
{footerText} {footerText}
</UText> </UText>
</div> </div>
{/* 写在组件末尾的 <style>:针对当前 wrapper 下的 ant 容器恢复横向滚动 */}
<style>{`
.policy-confirm-table-wrap .ant-table,
.policy-confirm-table-wrap .ant-table-container,
.policy-confirm-table-wrap .ant-table-content,
.policy-confirm-table-wrap .ant-table-body {
overflow-x: auto !important;
}
`}</style>
</UCard> </UCard>
); );
} }
...@@ -3,11 +3,19 @@ import { UButton } from '@uj/ui'; ...@@ -3,11 +3,19 @@ import { UButton } from '@uj/ui';
export interface SubmitActionBarProps { export interface SubmitActionBarProps {
totalRows?: number; totalRows?: number;
loading?: boolean;
disabled?: boolean;
onBack?: () => void; onBack?: () => void;
onSubmit?: () => void; onSubmit?: () => void | Promise<void>;
} }
export function SubmitActionBar({ totalRows = 12, onBack, onSubmit }: SubmitActionBarProps) { export function SubmitActionBar({
totalRows = 12,
loading = false,
disabled = false,
onBack,
onSubmit,
}: SubmitActionBarProps) {
return ( return (
<div <div
style={{ style={{
...@@ -17,13 +25,19 @@ export function SubmitActionBar({ totalRows = 12, onBack, onSubmit }: SubmitActi ...@@ -17,13 +25,19 @@ export function SubmitActionBar({ totalRows = 12, onBack, onSubmit }: SubmitActi
paddingTop: 4, paddingTop: 4,
}} }}
> >
<UButton icon={<ArrowLeftOutlined />} onClick={onBack ?? (() => console.log('返回上一步'))}> <UButton
icon={<ArrowLeftOutlined />}
disabled={loading}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步 返回上一步
</UButton> </UButton>
<UButton <UButton
type="primary" type="primary"
icon={<SendOutlined />} icon={<SendOutlined />}
loading={loading}
disabled={disabled || loading}
onClick={onSubmit ?? (() => console.log('确认提交并推送审批'))} onClick={onSubmit ?? (() => console.log('确认提交并推送审批'))}
> >
确认提交并推送审批({totalRows}) 确认提交并推送审批({totalRows})
......
import { useState } from 'react'; import { useMemo, useState } from 'react';
import { InfoCircleFilled } from '@ant-design/icons'; import { InfoCircleFilled } from '@ant-design/icons';
import { UCard, UCheckbox, UTag } from '@uj/ui'; import { UCard, UCheckbox, UTag } from '@uj/ui';
import type { StoreImportCheckVO } from '@/api/modules/store';
export interface SubmitConfirmInfo { export interface SubmitConfirmInfo {
storeName: string; storeName: string;
...@@ -49,13 +50,46 @@ const descStyle: React.CSSProperties = { ...@@ -49,13 +50,46 @@ const descStyle: React.CSSProperties = {
marginLeft: 6, 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 expectedApprover = vo.nextRoleName
? `(${vo.nextRoleName})`
: `(优加财务经理)`;
return {
storeName: vo.storeName ?? defaultInfo.storeName,
storeMerchantNo: vo.merchantNo ?? defaultInfo.storeMerchantNo,
categoryCount: vo.distinctProductCategoryCount ?? defaultInfo.categoryCount,
sceneCount: vo.distinctBusinessSceneCount ?? defaultInfo.sceneCount,
totalRows: vo.productCategoryRowCount ?? vo.totalRows ?? defaultInfo.totalRows,
operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` : defaultInfo.operatingCost,
operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`,
approvalChain: vo.nextRoleName || defaultInfo.approvalChain,
approvalChainTag: defaultInfo.approvalChainTag,
approvalChainDesc: defaultInfo.approvalChainDesc,
expectedApprover: defaultInfo.expectedApprover.includes(vo.nextRoleName ?? '')
? defaultInfo.expectedApprover
: `陈盛${expectedApprover}`,
};
}
export interface SubmitConfirmCardProps { export interface SubmitConfirmCardProps {
info?: SubmitConfirmInfo; info?: SubmitConfirmInfo;
checkResult?: StoreImportCheckVO;
} }
export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps) { export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps) {
const [checked, setChecked] = useState(true); const [checked, setChecked] = useState(true);
const finalInfo: SubmitConfirmInfo = useMemo(
() => info ?? (checkResult ? buildInfoFromCheckResult(checkResult) : defaultInfo),
[info, checkResult],
);
const infoRows: Array<{ const infoRows: Array<{
label: string; label: string;
value: React.ReactNode; value: React.ReactNode;
...@@ -64,35 +98,35 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps ...@@ -64,35 +98,35 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps
}> = [ }> = [
{ {
label: '门店名称', label: '门店名称',
value: info.storeName, value: finalInfo.storeName,
}, },
{ {
label: '门店商户号', label: '门店商户号',
value: info.storeMerchantNo, value: finalInfo.storeMerchantNo,
}, },
{ {
label: '产品分类', label: '产品分类',
value: `${info.categoryCount} 个`, value: `${finalInfo.categoryCount} 个`,
desc: `(${info.sceneCount} 个业务场景,共 ${info.totalRows} 行)`, desc: `(${finalInfo.sceneCount} 个业务场景,共 ${finalInfo.totalRows} 行)`,
}, },
{ {
label: '运营成本合计', label: '运营成本合计',
value: <span style={{ color: '#4F46E5', fontWeight: 600 }}>{info.operatingCost}</span>, value: <span style={{ color: '#4F46E5', fontWeight: 600 }}>{finalInfo.operatingCost}</span>,
desc: info.operatingCostDetail, desc: finalInfo.operatingCostDetail,
}, },
{ {
label: '触发审批链', label: '触发审批链',
value: info.approvalChain, value: finalInfo.approvalChain,
extra: ( extra: (
<UTag color="processing" bordered={false} style={{ marginLeft: 6 }}> <UTag color="processing" bordered={false} style={{ marginLeft: 6 }}>
{info.approvalChainTag} {finalInfo.approvalChainTag}
</UTag> </UTag>
), ),
desc: info.approvalChainDesc, desc: finalInfo.approvalChainDesc,
}, },
{ {
label: '预计审批人', label: '预计审批人',
value: info.expectedApprover, value: finalInfo.expectedApprover,
}, },
]; ];
...@@ -121,7 +155,7 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps ...@@ -121,7 +155,7 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps
style={{ fontSize: 13, fontWeight: 500 }} style={{ fontSize: 13, fontWeight: 500 }}
> >
<span style={{ color: '#374151' }}> <span style={{ color: '#374151' }}>
我已确认该门店 {info.sceneCount} 个业务场景共 {info.totalRows} 行数据准确无误 我已确认该门店 {finalInfo.sceneCount} 个业务场景共 {finalInfo.totalRows} 行数据准确无误
</span> </span>
</UCheckbox> </UCheckbox>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}> <div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
......
...@@ -3,10 +3,15 @@ import { UButton } from '@uj/ui'; ...@@ -3,10 +3,15 @@ import { UButton } from '@uj/ui';
export interface UploadActionBarProps { export interface UploadActionBarProps {
disabled?: boolean; disabled?: boolean;
onNext?: () => void; loading?: boolean;
onNext?: () => void | Promise<void>;
} }
export function UploadActionBar({ disabled = false, onNext }: UploadActionBarProps) { export function UploadActionBar({
disabled = false,
loading = false,
onNext,
}: UploadActionBarProps) {
return ( return (
<div <div
style={{ style={{
...@@ -18,7 +23,8 @@ export function UploadActionBar({ disabled = false, onNext }: UploadActionBarPro ...@@ -18,7 +23,8 @@ export function UploadActionBar({ disabled = false, onNext }: UploadActionBarPro
<UButton <UButton
type="primary" type="primary"
icon={<ArrowRightOutlined />} icon={<ArrowRightOutlined />}
disabled={disabled} disabled={disabled || loading}
loading={loading}
onClick={onNext ?? (() => console.log('下一步:数据校验'))} onClick={onNext ?? (() => console.log('下一步:数据校验'))}
> >
下一步:数据校验 下一步:数据校验
......
import { useState, useCallback } from 'react'; import { useState, useCallback, useEffect } from 'react';
import { App, Upload } from 'antd'; import { App } from 'antd';
import { import {
InfoCircleFilled, InfoCircleFilled,
UploadOutlined, UploadOutlined,
CheckCircleFilled, CheckCircleFilled,
CloseOutlined, CloseOutlined,
FileExcelOutlined, FileExcelOutlined,
LoadingOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import type { UploadProps, UploadFile } from 'antd'; import type { UploadProps, UploadFile } from 'antd';
import type { RcFile } from 'antd/es/upload/interface'; import type { RcFile } from 'antd/es/upload/interface';
import { UCard, UUpload, UText, UButton } from '@uj/ui'; import { UCard, UUpload, UText, UButton } from '@uj/ui';
import { store } from '@/api'; import { store } from '@/api';
import { mockParseAndValidate, UPLOAD_RULES, type ParsedFileMeta } from '../tools/uploadValidate'; import type { StoreImportCheckVO } from '@/api/modules/store';
import {
validateFileExtension,
validateFileSize,
UPLOAD_RULES,
} from '../tools/uploadValidate';
const TEMPLATE_NAME = '【优加】门店上架模版-V1.0.1.xlsx'; const TEMPLATE_NAME = '【优加】门店上架模版-V1.0.1.xlsx';
export interface UploadCardProps { export interface UploadCardProps {
onUploadSuccess?: (meta: ParsedFileMeta) => void; file?: File | null;
remark?: string;
onFileChange?: (file: File | null) => void;
onUploadSuccess?: (vo: StoreImportCheckVO) => void;
} }
export function UploadCard({ onUploadSuccess }: UploadCardProps) { export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: UploadCardProps) {
const { message } = App.useApp(); const { message } = App.useApp();
const [uploading, setUploading] = useState(false); const [uploading, setUploading] = useState(false);
const [downloading, setDownloading] = useState(false); const [downloading, setDownloading] = useState(false);
const [fileMeta, setFileMeta] = useState<ParsedFileMeta | null>(null);
const [fileList, setFileList] = useState<UploadFile[]>([]); const [fileList, setFileList] = useState<UploadFile[]>([]);
// 受控:父组件 file 变化时,同步内部 fileList(解决返回上一步组件重新挂载丢失文件的问题)
useEffect(() => {
if (file) {
setFileList([buildUploadFile(file)]);
} else {
setFileList([]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [file]);
const clearFileState = useCallback(() => { const clearFileState = useCallback(() => {
setFileMeta(null);
setFileList([]); setFileList([]);
}, []); onFileChange?.(null);
}, [onFileChange]);
const handleRemove = useCallback(() => { const handleRemove = useCallback(() => {
clearFileState(); clearFileState();
...@@ -39,7 +57,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -39,7 +57,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
const handleDownloadTemplate = async (e?: React.MouseEvent) => { const handleDownloadTemplate = async (e?: React.MouseEvent) => {
e?.stopPropagation?.(); e?.stopPropagation?.();
if (downloading) return; if (downloading || uploading) return;
setDownloading(true); setDownloading(true);
try { try {
await store.downloadImportTemplate(TEMPLATE_NAME); await store.downloadImportTemplate(TEMPLATE_NAME);
...@@ -51,49 +69,57 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -51,49 +69,57 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
} }
}; };
const buildUploadFile = (file: RcFile): UploadFile => ({ const buildUploadFile = (f: File): UploadFile => ({
uid: Date.now().toString(), uid: Date.now().toString(),
name: file.name, name: f.name,
size: file.size, size: f.size,
type: file.type, type: f.type,
originFileObj: file, originFileObj: f,
status: 'done', status: 'done',
}); });
const handleFile: UploadProps['beforeUpload'] = async (rawFile) => { const runUpload = useCallback(
setUploading(true); async (f: File) => {
if (!validateFileExtension(f.name)) {
try { message.error(`仅支持 ${UPLOAD_RULES.ALLOW_EXTS.join(' / ')} 格式`);
const result = await mockParseAndValidate(rawFile as File); return;
if (!result.ok || !result.meta) {
message.error(result.message ?? '文件校验失败');
clearFileState();
setUploading(false);
return Upload.LIST_IGNORE;
} }
if (!validateFileSize(f.size)) {
message.error(
`文件大小超过限制,单文件 ≤ 10MB(当前 ${(f.size / 1024 / 1024).toFixed(2)}MB)`,
);
return;
}
setUploading(true);
try { try {
await store.uploadImport(rawFile as File); const vo = await store.uploadImport({ file: f, remark });
} catch (e) { if (!vo.submitted) {
message.error((e as Error).message); message.warning(
clearFileState(); `校验未通过,失败 ${vo.failRows} 行,未完成落库;请修正后重新上传`,
setUploading(false); );
return Upload.LIST_IGNORE; } else {
message.success(
`上传完成:通过 ${vo.passRows} 行 / 失败 ${vo.failRows} 行${vo.failFileUrl ? ';已生成失败明细文件' : ''}`,
);
} }
setFileList([buildUploadFile(f)]);
setFileMeta(result.meta); onFileChange?.(f);
setFileList([buildUploadFile(rawFile)]); onUploadSuccess?.(vo);
message.success('模板已上传,校验通过');
onUploadSuccess?.(result.meta);
} catch (e) { } catch (e) {
message.error((e as Error).message ?? '文件处理失败'); message.error((e as Error).message ?? '上传失败');
clearFileState(); clearFileState();
} finally { } finally {
setUploading(false); setUploading(false);
} }
},
[remark, onFileChange, onUploadSuccess, clearFileState, message],
);
return Upload.LIST_IGNORE; const customRequest: NonNullable<UploadProps['customRequest']> = (options) => {
const f = options.file as File;
void runUpload(f).finally(() => {
options.onSuccess?.({ ok: true });
});
}; };
const uploadProps: UploadProps = { const uploadProps: UploadProps = {
...@@ -101,7 +127,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -101,7 +127,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
multiple: false, multiple: false,
accept: UPLOAD_RULES.ALLOW_EXTS.join(','), accept: UPLOAD_RULES.ALLOW_EXTS.join(','),
showUploadList: false, showUploadList: false,
beforeUpload: handleFile, customRequest,
onRemove: handleRemove, onRemove: handleRemove,
fileList, fileList,
}; };
...@@ -123,7 +149,8 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -123,7 +149,8 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
</UText> </UText>
} }
> >
<UUpload.Dragger {...uploadProps} disabled={uploading}> <div style={{ position: 'relative' }}>
<UUpload.Dragger {...uploadProps}>
<div style={{ padding: '30px 0' }}> <div style={{ padding: '30px 0' }}>
<div <div
style={{ style={{
...@@ -137,7 +164,11 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -137,7 +164,11 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
marginBottom: 16, marginBottom: 16,
}} }}
> >
{uploading ? (
<LoadingOutlined style={{ fontSize: 22, color: '#4F46E5' }} />
) : (
<UploadOutlined style={{ fontSize: 22, color: '#4F46E5' }} /> <UploadOutlined style={{ fontSize: 22, color: '#4F46E5' }} />
)}
</div> </div>
<p <p
className="ant-upload-text" className="ant-upload-text"
...@@ -148,7 +179,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -148,7 +179,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
marginBottom: 8, marginBottom: 8,
}} }}
> >
点击选择文件,或拖拽到此处 {uploading ? '上传中,请稍候...' : '点击选择文件,或拖拽到此处'}
</p> </p>
<p <p
className="ant-upload-hint" className="ant-upload-hint"
...@@ -163,6 +194,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -163,6 +194,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
type="link" type="link"
size="small" size="small"
loading={downloading} loading={downloading}
disabled={uploading}
style={{ padding: '0 4px', height: 'auto' }} style={{ padding: '0 4px', height: 'auto' }}
onClick={handleDownloadTemplate} onClick={handleDownloadTemplate}
> >
...@@ -179,8 +211,19 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -179,8 +211,19 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
</div> </div>
</div> </div>
</UUpload.Dragger> </UUpload.Dragger>
{uploading && (
<div
style={{
position: 'absolute',
inset: 0,
background: 'rgba(255,255,255,0.01)',
cursor: 'not-allowed',
}}
/>
)}
</div>
{fileMeta && ( {fileList[0] && (
<div <div
style={{ style={{
marginTop: 16, marginTop: 16,
...@@ -226,21 +269,15 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -226,21 +269,15 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
}} }}
> >
{fileMeta.fileName} {fileList[0].name}
</span> </span>
<CheckCircleFilled style={{ color: '#16A34A', fontSize: 16, flex: 'none' }} /> <CheckCircleFilled style={{ color: '#16A34A', fontSize: 16, flex: 'none' }} />
</div> </div>
<div <div style={{ fontSize: 12, color: '#6B7280' }}>
style={{ {fileList[0].size ? Math.max(1, Math.round(fileList[0].size / 1024)) : '-'} KB
fontSize: 12, <CheckCircleFilled
color: '#6B7280', style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }}
}} />
>
{fileMeta.sizeKB} KB · 共 {fileMeta.rows} 行数据 (
{fileMeta.storeName.split('').slice(0, 6).join('')}… × {fileMeta.sceneCount}{' '}
个业务场景 × {fileMeta.categoryCount} 个产品分类) · 模板版本{' '}
{fileMeta.templateVersion}
<CheckCircleFilled style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }} />
</div> </div>
</div> </div>
<UButton <UButton
......
import { UCard } from '@uj/ui'; import { UCard } from '@uj/ui';
import type { StoreImportCheckVO } from '@/api/modules/store';
export interface StatItem { export interface StatItem {
label: string; label: string;
...@@ -78,34 +79,88 @@ function StatCard({ item }: StatCardProps) { ...@@ -78,34 +79,88 @@ function StatCard({ item }: StatCardProps) {
export interface ValidationStatsProps { export interface ValidationStatsProps {
stats?: StatItem[]; stats?: StatItem[];
checkResult?: StoreImportCheckVO;
}
function calcOperatingCost(vo: StoreImportCheckVO): number {
const rows = vo.previewRows ?? [];
if (rows.length === 0) return 0;
const first = rows[0];
return (
Math.round(first.costDecoration ?? 0) +
Math.round(first.costMonthly ?? 0) +
Math.round(first.costLabor ?? 0)
);
}
function buildStatsFromCheckResult(vo: StoreImportCheckVO): StatItem[] {
const rows = vo.productCategoryRowCount ?? vo.totalRows;
const storeCount = 1;
const sceneCount = vo.distinctBusinessSceneCount;
const categoryCount = vo.distinctProductCategoryCount;
const operating = calcOperatingCost(vo);
const items: StatItem[] = [
{
label: '解析总行数',
value: vo.totalRows,
desc: `${storeCount} 家门店 · ${sceneCount} 个业务场景 · ${rows} 行`,
tone: 'primary',
},
{
label: '校验通过',
value: vo.passRows,
desc: vo.passRows > 0 ? '可提交审批' : '无通过数据',
tone: 'success',
},
];
if (vo.failRows > 0) {
items.push({
label: '校验失败',
value: vo.failRows,
desc: vo.failFileUrl ? '可下载失败明细文件' : '需修正后重新上传',
tone: 'warning',
});
}
items.push({
label: '运营成本合计',
value: operating > 0 ? `¥ ${operating.toLocaleString('en-US')}` : '-',
desc: '门店维度(装修设备 + 当月产生 + 人工成本)',
tone: 'default',
});
return items;
} }
const defaultStats: StatItem[] = [ const defaultStats: StatItem[] = [
{ {
label: '解析总行数', label: '解析总行数',
value: '13', value: '-',
desc: '1 家门店 · 2 个业务场景 · 12 行', desc: '上传文件后展示',
tone: 'primary', tone: 'primary',
}, },
{ {
label: '校验通过', label: '校验通过',
value: '12', value: '-',
desc: '可提交审批', desc: '上传文件后展示',
tone: 'success', tone: 'success',
}, },
]; ];
export function ValidationStats({ stats = defaultStats }: ValidationStatsProps) { export function ValidationStats({ stats, checkResult }: ValidationStatsProps) {
const finalStats: StatItem[] = stats ?? (checkResult ? buildStatsFromCheckResult(checkResult) : defaultStats);
return ( return (
<div <div
style={{ style={{
display: 'grid', display: 'grid',
gridTemplateColumns: 'repeat(4, 1fr)', gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
gap: 16, gap: 16,
marginBottom: 20, marginBottom: 20,
}} }}
> >
{stats.map((s) => ( {finalStats.map((s) => (
<StatCard key={s.label} item={s} /> <StatCard key={s.label} item={s} />
))} ))}
</div> </div>
......
import { useState } from 'react'; import { useState } from 'react';
import { Skeleton } from '@uj/ui'; import { App, Skeleton } from 'antd';
import { PageHeader } from './components/PageHeader'; import { PageHeader } from './components/PageHeader';
import { NoticeSection } from './components/NoticeSection'; import { NoticeSection } from './components/NoticeSection';
import { StepsBar } from './components/StepsBar'; import { StepsBar } from './components/StepsBar';
import { ImportInfoCard } from './components/ImportInfoCard'; import { ImportInfoCard } from './components/ImportInfoCard';
import type { ImportInfoValues } from './components/ImportInfoCard';
import { UploadCard } from './components/UploadCard'; import { UploadCard } from './components/UploadCard';
import { UploadActionBar } from './components/UploadActionBar'; import { UploadActionBar } from './components/UploadActionBar';
import { ValidationStats } from './components/ValidationStats'; import { ValidationStats } from './components/ValidationStats';
...@@ -14,13 +15,19 @@ import { ConfirmActionBar } from './components/ConfirmActionBar'; ...@@ -14,13 +15,19 @@ import { ConfirmActionBar } from './components/ConfirmActionBar';
import { SubmitConfirmCard } from './components/SubmitConfirmCard'; import { SubmitConfirmCard } from './components/SubmitConfirmCard';
import { ApprovalChainPreview } from './components/ApprovalChainPreview'; import { ApprovalChainPreview } from './components/ApprovalChainPreview';
import { SubmitActionBar } from './components/SubmitActionBar'; import { SubmitActionBar } from './components/SubmitActionBar';
import { mockPolicyRows } from './tools/policyTableData'; import { store } from '@/api';
import type { StoreImportCheckVO } from '@/api/modules/store';
export default function TemplateImport() { export default function TemplateImport() {
const loading = false; const loading = false;
const { message, modal } = App.useApp();
const [currentStep, setCurrentStep] = useState<0 | 1 | 2 | 3>(0); const [currentStep, setCurrentStep] = useState<0 | 1 | 2 | 3>(0);
const [fileUploaded, setFileUploaded] = useState(false); const [importInfo, setImportInfo] = useState<ImportInfoValues | null>(null);
const passCount = 12; const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [checkResult, setCheckResult] = useState<StoreImportCheckVO | null>(null);
const [submitting, setSubmitting] = useState(false);
const passCount = checkResult?.passRows ?? 0;
const goPrev = () => { const goPrev = () => {
setCurrentStep((s) => (s > 0 ? ((s - 1) as 0 | 1 | 2 | 3) : s)); setCurrentStep((s) => (s > 0 ? ((s - 1) as 0 | 1 | 2 | 3) : s));
...@@ -28,12 +35,74 @@ export default function TemplateImport() { ...@@ -28,12 +35,74 @@ export default function TemplateImport() {
const goNext = () => { const goNext = () => {
setCurrentStep((s) => (s < 3 ? ((s + 1) as 0 | 1 | 2 | 3) : s)); setCurrentStep((s) => (s < 3 ? ((s + 1) as 0 | 1 | 2 | 3) : s));
}; };
const handleFileChange = (f: File | null) => {
setSelectedFile(f);
// 移除文件时,同步清空校验结果 + 导入信息里的 3 个回显字段(保留 remark)
if (f === null) {
setCheckResult(null);
setImportInfo((prev) => ({
org: prev?.org ?? '',
scene: prev?.scene ?? '',
categories: prev?.categories ?? [],
remark: prev?.remark,
}));
}
};
/** 把后端用「/」分隔的多值字符串拆成数组,兼容空串、含空格的情况 */
const splitMultiLabel = (raw: string | null | undefined): string[] => {
if (!raw) return [];
return raw
.split('/')
.map((s) => s.trim())
.filter(Boolean);
};
const handleUploadSuccess = (vo: StoreImportCheckVO) => {
setCheckResult(vo);
setImportInfo((prev) => ({
org: vo.orgPath,
scene: vo.businessScene,
categories: splitMultiLabel(vo.productCategories),
remark: prev?.remark,
}));
};
const handleSubmitPassOnly = () => { const handleSubmitPassOnly = () => {
console.log(`仅提交通过行(${passCount})`); console.log(`仅提交通过行(${passCount})`);
goNext(); goNext();
}; };
const handleFinalSubmit = () => {
console.log(`确认提交并推送审批(${passCount})`); const handleFinalSubmit = async () => {
const listingIds = checkResult?.listingIds ?? [];
if (listingIds.length === 0) {
message.warning('本次无可提交的上架记录(listingIds 为空)');
return;
}
if (submitting) return;
setSubmitting(true);
try {
const result = await store.submitImport({ listingIds });
setCheckResult(result);
modal.success({
title: '提交审批成功',
content: `已提交 ${result.passRows ?? 0} 行 / 涉及 ${listingIds.length} 条上架记录,请在「门店审批」中跟踪进度。`,
okText: '前往门店审批',
okButtonProps: { type: 'primary' },
cancelText: '知道了',
// 非阻塞(不强制跳转):「知道了」留在当前页
showCancel: true,
onOk: () => {
// 跳转门店审批页(对应路由:/store/approve)
window.location.href = '/store/approve';
},
});
} catch (e) {
message.error((e as Error).message ?? '提交审批失败');
} finally {
setSubmitting(false);
}
}; };
if (loading) return <Skeleton variant="default" />; if (loading) return <Skeleton variant="default" />;
...@@ -46,15 +115,23 @@ export default function TemplateImport() { ...@@ -46,15 +115,23 @@ export default function TemplateImport() {
{currentStep === 0 && ( {currentStep === 0 && (
<> <>
<ImportInfoCard /> <ImportInfoCard
<UploadCard onUploadSuccess={() => setFileUploaded(true)} /> values={importInfo ?? undefined}
<UploadActionBar disabled={!fileUploaded} onNext={goNext} /> onChange={(v) => setImportInfo(v)}
/>
<UploadCard
file={selectedFile}
remark={importInfo?.remark}
onFileChange={handleFileChange}
onUploadSuccess={handleUploadSuccess}
/>
<UploadActionBar disabled={!checkResult?.submitted} onNext={goNext} />
</> </>
)} )}
{currentStep === 1 && ( {currentStep === 1 && (
<> <>
<ValidationStats /> <ValidationStats checkResult={checkResult ?? undefined} />
<ValidationActionBar <ValidationActionBar
passCount={passCount} passCount={passCount}
onBack={goPrev} onBack={goPrev}
...@@ -66,17 +143,30 @@ export default function TemplateImport() { ...@@ -66,17 +143,30 @@ export default function TemplateImport() {
{currentStep === 2 && ( {currentStep === 2 && (
<> <>
<PolicyConfirmHeader storeName="巴州强冠东风汽车销售服务有限公司" totalRows={12} /> <PolicyConfirmHeader
<PolicyConfirmTable dataSource={mockPolicyRows} /> storeName={checkResult?.storeName}
<ConfirmActionBar passCount={passCount} onBack={goPrev} onSubmit={goNext} /> totalRows={checkResult?.productCategoryRowCount ?? checkResult?.passRows}
/>
<PolicyConfirmTable previewRows={checkResult?.previewRows} />
<ConfirmActionBar
passCount={passCount}
onBack={goPrev}
onSubmit={goNext}
/>
</> </>
)} )}
{currentStep === 3 && ( {currentStep === 3 && (
<> <>
<SubmitConfirmCard /> <SubmitConfirmCard checkResult={checkResult ?? undefined} />
<ApprovalChainPreview /> <ApprovalChainPreview />
<SubmitActionBar totalRows={passCount} onBack={goPrev} onSubmit={handleFinalSubmit} /> <SubmitActionBar
totalRows={passCount}
loading={submitting}
disabled={!checkResult?.submitted || (checkResult?.listingIds?.length ?? 0) === 0}
onBack={goPrev}
onSubmit={handleFinalSubmit}
/>
</> </>
)} )}
</div> </div>
......
import type { StoreImportRowDTO } from '@/api/modules/store';
export interface PolicyConfirmRow { export interface PolicyConfirmRow {
// 门店信息(4 列)
storeName: string; storeName: string;
storeMerchantNo: string; storeMerchantNo: string;
businessScene: string; businessScene: string;
productCategory: string; productCategory: string;
// 商务政策(14 列:管理层市场费 ×6 + 一线阳光 ×4 + 一线阳光2 ×4)
mgmtFee1Mode: string; mgmtFee1Mode: string;
mgmtFee1CalcMethod: string; mgmtFee1CalcMethod: string;
mgmtFee1Value: string; mgmtFee1Value: string;
...@@ -11,26 +15,36 @@ export interface PolicyConfirmRow { ...@@ -11,26 +15,36 @@ export interface PolicyConfirmRow {
mgmtFee2Value: string; mgmtFee2Value: string;
sunshineOnlinePoints: string; sunshineOnlinePoints: string;
sunshineCalcMode: string; sunshineCalcMode: string;
sunshineCalcMethod: string;
sunshineValue: string;
sunshine2OnlinePoints: string;
sunshine2CalcMode: string;
sunshine2CalcMethod: string;
sunshine2Value: string;
// 运营成本(3 列)
costDecoration: string;
costMonthly: string;
costLabor: string;
} }
const BUSINESS_SCENES = ['售后会员权益升级', '售前延保']; const BUSINESS_SCENES = ['售后众筹', '精品升级'];
const PRODUCT_CATEGORIES = [ const PRODUCT_CATEGORIES = [
'太阳膜-原厂', '车辆美容',
'车衣-原厂', '精品(集采)',
'精品-小桌板', '记录仪',
'精品-脚垫', '其他(众筹)',
'踏板', '电子烟(集采)',
'车衣-副厂', '太阳膜()',
]; ];
function buildRows(): PolicyConfirmRow[] { function buildRows(): PolicyConfirmRow[] {
const rows: PolicyConfirmRow[] = []; const rows: PolicyConfirmRow[] = [];
for (const scene of BUSINESS_SCENES) { for (const scene of BUSINESS_SCENES) {
for (const cat of PRODUCT_CATEGORIES) { for (const cat of PRODUCT_CATEGORIES) {
const calcMode = cat === '车衣-原厂' ? '按整单计算' : '按品类计算'; const calcMode = cat === '精品(集采)' ? '按整单计算' : '按品类计算';
rows.push({ rows.push({
storeName: '巴州强冠东风汽车销售服务有限公司', storeName: '明明崇文4s店A',
storeMerchantNo: 'SQ20240115', storeMerchantNo: '44211227',
businessScene: scene, businessScene: scene,
productCategory: cat, productCategory: cat,
mgmtFee1Mode: calcMode, mgmtFee1Mode: calcMode,
...@@ -41,6 +55,15 @@ function buildRows(): PolicyConfirmRow[] { ...@@ -41,6 +55,15 @@ function buildRows(): PolicyConfirmRow[] {
mgmtFee2Value: '5%', mgmtFee2Value: '5%',
sunshineOnlinePoints: '是', sunshineOnlinePoints: '是',
sunshineCalcMode: calcMode, sunshineCalcMode: calcMode,
sunshineCalcMethod: '收入',
sunshineValue: '5%',
sunshine2OnlinePoints: '是',
sunshine2CalcMode: calcMode,
sunshine2CalcMethod: '收入',
sunshine2Value: '5%',
costDecoration: '¥ 200,000',
costMonthly: '¥ 15,000',
costLabor: '¥ 30,000',
}); });
} }
} }
...@@ -48,3 +71,56 @@ function buildRows(): PolicyConfirmRow[] { ...@@ -48,3 +71,56 @@ function buildRows(): PolicyConfirmRow[] {
} }
export const mockPolicyRows: PolicyConfirmRow[] = buildRows(); export const mockPolicyRows: PolicyConfirmRow[] = buildRows();
function formatRatio(value: number | undefined | null, unit: string | undefined | null): string {
if (value === undefined || value === null) return '-';
if ((unit ?? '').toUpperCase() !== 'RATIO') return String(value);
// 后端约定:RATIO 单位下,value 本身就是百分比的整数表示
// 例:1 → 1%,5 → 5%,0.5 → 0.5%(极少数小数百分比场景也直接显示)
const rounded = Math.round(value * 100) / 100;
return `${rounded}%`;
}
function formatYesNo(value: number | undefined | null): string {
if (value === 1) return '是';
if (value === 0) return '否';
return '-';
}
function formatMoney(value: number | undefined | null): string {
if (value === undefined || value === null) return '-';
return `¥ ${value.toLocaleString('zh-CN')}`;
}
/** 将接口返回的 previewRows 转为 PolicyConfirmRow */
export function convertPreviewRows(preview: StoreImportRowDTO[]): PolicyConfirmRow[] {
return preview.map((r) => ({
// 门店信息
storeName: r.storeName,
storeMerchantNo: r.merchantNo,
businessScene: r.businessScene,
productCategory: r.productCategory,
// 管理层市场费 1
mgmtFee1Mode: r.marketFee1CalcMode || '-',
mgmtFee1CalcMethod: r.marketFee1CalcWay || '-',
mgmtFee1Value: formatRatio(r.marketFee1Value, r.marketFee1Unit),
// 管理层市场费 2
mgmtFee2Mode: r.marketFee2CalcMode || '-',
mgmtFee2CalcMethod: r.marketFee2CalcWay || '-',
mgmtFee2Value: formatRatio(r.marketFee2Value, r.marketFee2Unit),
// 一线阳光 1
sunshineOnlinePoints: formatYesNo(r.sunshine1OnlinePoint),
sunshineCalcMode: r.sunshine1CalcMode || '-',
sunshineCalcMethod: r.sunshine1CalcWay || '-',
sunshineValue: formatRatio(r.sunshine1Value, r.sunshine1Unit),
// 一线阳光 2
sunshine2OnlinePoints: formatYesNo(r.sunshine2OnlinePoint),
sunshine2CalcMode: r.sunshine2CalcMode || '-',
sunshine2CalcMethod: r.sunshine2CalcWay || '-',
sunshine2Value: formatRatio(r.sunshine2Value, r.sunshine2Unit),
// 运营成本
costDecoration: formatMoney(r.costDecoration),
costMonthly: formatMoney(r.costMonthly),
costLabor: formatMoney(r.costLabor),
}));
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!