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 {
[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> = {
todo: '/store/approval/pending',
done: '/store/approval/done',
......@@ -63,17 +277,19 @@ class Store extends ApiClient {
URL.revokeObjectURL(url);
}
/** 上传模板文件做五级校验(FormData,请求体不参与签名,§3.1/§9.6) */
uploadImport(file: File, templateVersion = 'V1.0.1') {
/** 上传模板文件做五级校验 + 落库草稿(失败时返回失败明细文件 URL,不落库) */
uploadImport(params: StoreImportCheckParams) {
const form = new FormData();
form.append('file', file);
form.append('templateVersion', templateVersion);
return this.post<{ taskId: string }>('/store/import/check', form);
form.append('file', params.file);
if (params.remark !== undefined && params.remark !== null) {
form.append('remark', String(params.remark));
}
return this.post<StoreImportCheckVO>('/store/import/check', form);
}
/** 保持现有导入向导的调用契约,导入流程由独立模块维护。 */
submitImport(payload: ImportSubmitPayload) {
return this.post<{ approveId: string }>('/store/import/submit', payload);
/** 提交:把草稿记录提交为待审批(不重新解析文件,响应 data 类型同 check) */
submitImport(payload: StoreImportCommitDTO) {
return this.post<StoreImportCheckVO>('/store/import/submit', payload);
}
listApprovals(tab: ApproveTab = 'todo', params: ApprovalPageParams = {}) {
......
import { useEffect } from 'react';
import { InfoCircleFilled } from '@ant-design/icons';
import { UCard, UForm, UFormItem, USelect, UInput } from '@uj/ui';
import type { USelectProps } from '@uj/ui';
......@@ -9,33 +10,50 @@ export interface ImportInfoValues {
remark?: string;
}
// 注意:value 统一用 label 字符串,与后端 StoreImportCheckVO 返回的 orgPath / businessScene / productCategories 对齐
const orgOptions: USelectProps['options'] = [
{ label: '优加主体 / 线上运营部', value: 'uj-online' },
{ label: '优加主体 / 线下事业部', value: 'uj-offline' },
{ label: '优加主体 / 线上运营部', value: '优加主体 / 线上运营部' },
{ label: '优加主体 / 线下事业部', value: '优加主体 / 线下事业部' },
];
const sceneOptions: USelectProps['options'] = [
{ label: '售后会员权益升级 / 售前延保', value: 'warranty' },
{ label: '汽车用品销售', value: 'accessories' },
{ label: '保养服务', value: 'maintenance' },
{ label: '售后会员权益升级 / 售前延保', value: '售后会员权益升级 / 售前延保' },
{ label: '汽车用品销售', value: '汽车用品销售' },
{ label: '保养服务', value: '保养服务' },
];
const categoryOptions: USelectProps['options'] = [
{ label: '太阳膜-原厂', value: 'film-original' },
{ label: '车衣-原厂', value: 'ppf-original' },
{ label: '精品-小桌板', value: 'bp-table' },
{ label: '精品-脚垫', value: 'bp-mat' },
{ label: '精品-后备箱垫', value: 'bp-trunk' },
{ label: '保养-基础A保', value: 'mt-a' },
{ label: '太阳膜-原厂', value: '太阳膜-原厂' },
{ label: '车衣-原厂', value: '车衣-原厂' },
{ label: '精品-小桌板', value: '精品-小桌板' },
{ label: '精品-脚垫', value: '精品-脚垫' },
{ label: '精品-后备箱垫', value: '精品-后备箱垫' },
{ label: '保养-基础A保', value: '保养-基础A保' },
];
const formItemLayout = {
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>();
// 受控回填:外部 values 变化时,把导入结果同步到表单
useEffect(() => {
if (values) {
form.setFieldsValue(values);
}
}, [values, form]);
const handleValuesChange = (_: Partial<ImportInfoValues>, all: ImportInfoValues) => {
onChange?.(all);
};
return (
<UCard
styles={{ body: { padding: 20 } }}
......@@ -50,10 +68,9 @@ export function ImportInfoCard() {
<UForm
form={form}
layout="vertical"
initialValues={{
org: 'uj-online',
scene: 'warranty',
categories: ['film-original', 'ppf-original', 'bp-table'],
onValuesChange={handleValuesChange}
onFinish={() => {
onChange?.(form.getFieldsValue());
}}
>
<div
......@@ -72,7 +89,11 @@ export function ImportInfoCard() {
name="org"
{...formItemLayout}
>
<USelect options={orgOptions} placeholder="请选择所属组织" />
<USelect
disabled
options={orgOptions}
placeholder="请选择所属组织"
/>
</UFormItem>
<UFormItem
......@@ -84,7 +105,11 @@ export function ImportInfoCard() {
name="scene"
{...formItemLayout}
>
<USelect options={sceneOptions} placeholder="请选择业务场景" />
<USelect
disabled
options={sceneOptions}
placeholder="请选择业务场景"
/>
</UFormItem>
<UFormItem
......@@ -97,6 +122,7 @@ export function ImportInfoCard() {
{...formItemLayout}
>
<USelect
disabled
mode="multiple"
options={categoryOptions}
placeholder="请选择产品分类"
......
......@@ -16,6 +16,13 @@ const bizPolicyHeaderStyle: React.CSSProperties = {
fontSize: 13,
};
const costHeaderStyle: React.CSSProperties = {
background: '#FFF7ED',
color: '#C2410C',
fontWeight: 600,
fontSize: 13,
};
const cellStyle: React.CSSProperties = {
fontSize: 12.5,
color: '#374151',
......@@ -24,7 +31,18 @@ const cellStyle: React.CSSProperties = {
function SceneTag({ text }: { text: string }) {
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}
</UTag>
);
......@@ -32,14 +50,46 @@ function SceneTag({ text }: { text: string }) {
function CategoryTag({ text }: { text: string }) {
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}
</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'] {
return [
// ------------- 第一组:门店信息(4 列) -------------
{
title: '门店信息',
align: 'center',
......@@ -77,23 +127,32 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '产品分类',
dataIndex: 'productCategory',
key: 'productCategory',
width: 120,
width: 280,
align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }),
onCell: () => ({
style: {
...cellStyle,
// 确保 tableLayout=fixed 下,Tag 内容超长时单元格不会溢出到右侧列
overflow: 'hidden',
whiteSpace: 'nowrap',
},
}),
render: (v: string) => <CategoryTag text={v} />,
},
],
},
// ------------- 第二组:商务政策(14 列) -------------
{
title: '商务政策',
align: 'center',
children: [
// 管理层市场费 1
{
title: '管理层市场费1计算模式',
dataIndex: 'mgmtFee1Mode',
key: 'mgmtFee1Mode',
width: 140,
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
......@@ -102,7 +161,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费1计算方式',
dataIndex: 'mgmtFee1CalcMethod',
key: 'mgmtFee1CalcMethod',
width: 140,
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
......@@ -111,17 +170,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费1',
dataIndex: 'mgmtFee1Value',
key: 'mgmtFee1Value',
width: 110,
width: 130,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>,
render: (v) => <FeeValueCell value={v as string} />,
},
// 管理层市场费 2
{
title: '管理层市场费2计算模式',
dataIndex: 'mgmtFee2Mode',
key: 'mgmtFee2Mode',
width: 140,
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
......@@ -130,7 +190,7 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费2计算方式',
dataIndex: 'mgmtFee2CalcMethod',
key: 'mgmtFee2CalcMethod',
width: 140,
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
......@@ -139,17 +199,18 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '管理层市场费2',
dataIndex: 'mgmtFee2Value',
key: 'mgmtFee2Value',
width: 110,
width: 130,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>,
render: (v) => <FeeValueCell value={v as string} />,
},
// 一线阳光 1
{
title: '一线阳光是否开启线上积分',
dataIndex: 'sunshineOnlinePoints',
key: 'sunshineOnlinePoints',
width: 150,
width: 170,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
......@@ -158,10 +219,104 @@ export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
title: '一线阳光计算模式',
dataIndex: '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',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
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 type { StoreImportRowDTO } from '@/api/modules/store';
import { mockPolicyRows, convertPreviewRows } from '../../tools/policyTableData';
import type { PolicyConfirmRow } from '../../tools/policyTableData';
const footerText =
......@@ -7,25 +11,69 @@ const footerText =
export interface PolicyConfirmTableProps {
dataSource?: PolicyConfirmRow[];
previewRows?: StoreImportRowDTO[];
}
export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) {
const columns = buildPolicyColumns();
export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTableProps) {
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 (
<UCard
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',
}}
>
<FillTable<PolicyConfirmRow>
rowKey={(r) => `${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`}
columns={columns}
dataSource={dataSource}
size="middle"
scroll={{ x: 1600 }}
pagination={false}
bordered
/>
{/* 外层专属 wrapper:覆盖全局 index.css 关 ant Table 横向滚动的 !important 规则 */}
<div
className="policy-confirm-table-wrap"
style={{ width: '100%' }}
>
<UTable<PolicyConfirmRow> {...tableProps} />
</div>
<div
style={{
marginTop: 12,
......@@ -38,6 +86,15 @@ export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) {
{footerText}
</UText>
</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>
);
}
......@@ -3,11 +3,19 @@ import { UButton } from '@uj/ui';
export interface SubmitActionBarProps {
totalRows?: number;
loading?: boolean;
disabled?: boolean;
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 (
<div
style={{
......@@ -17,13 +25,19 @@ export function SubmitActionBar({ totalRows = 12, onBack, onSubmit }: SubmitActi
paddingTop: 4,
}}
>
<UButton icon={<ArrowLeftOutlined />} onClick={onBack ?? (() => console.log('返回上一步'))}>
<UButton
icon={<ArrowLeftOutlined />}
disabled={loading}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步
</UButton>
<UButton
type="primary"
icon={<SendOutlined />}
loading={loading}
disabled={disabled || loading}
onClick={onSubmit ?? (() => console.log('确认提交并推送审批'))}
>
确认提交并推送审批({totalRows})
......
import { useState } from 'react';
import { useMemo, useState } from 'react';
import { InfoCircleFilled } from '@ant-design/icons';
import { UCard, UCheckbox, UTag } from '@uj/ui';
import type { StoreImportCheckVO } from '@/api/modules/store';
export interface SubmitConfirmInfo {
storeName: string;
......@@ -49,13 +50,46 @@ const descStyle: React.CSSProperties = {
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 {
info?: SubmitConfirmInfo;
checkResult?: StoreImportCheckVO;
}
export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps) {
export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps) {
const [checked, setChecked] = useState(true);
const finalInfo: SubmitConfirmInfo = useMemo(
() => info ?? (checkResult ? buildInfoFromCheckResult(checkResult) : defaultInfo),
[info, checkResult],
);
const infoRows: Array<{
label: string;
value: React.ReactNode;
......@@ -64,35 +98,35 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps
}> = [
{
label: '门店名称',
value: info.storeName,
value: finalInfo.storeName,
},
{
label: '门店商户号',
value: info.storeMerchantNo,
value: finalInfo.storeMerchantNo,
},
{
label: '产品分类',
value: `${info.categoryCount} 个`,
desc: `(${info.sceneCount} 个业务场景,共 ${info.totalRows} 行)`,
value: `${finalInfo.categoryCount} 个`,
desc: `(${finalInfo.sceneCount} 个业务场景,共 ${finalInfo.totalRows} 行)`,
},
{
label: '运营成本合计',
value: <span style={{ color: '#4F46E5', fontWeight: 600 }}>{info.operatingCost}</span>,
desc: info.operatingCostDetail,
value: <span style={{ color: '#4F46E5', fontWeight: 600 }}>{finalInfo.operatingCost}</span>,
desc: finalInfo.operatingCostDetail,
},
{
label: '触发审批链',
value: info.approvalChain,
value: finalInfo.approvalChain,
extra: (
<UTag color="processing" bordered={false} style={{ marginLeft: 6 }}>
{info.approvalChainTag}
{finalInfo.approvalChainTag}
</UTag>
),
desc: info.approvalChainDesc,
desc: finalInfo.approvalChainDesc,
},
{
label: '预计审批人',
value: info.expectedApprover,
value: finalInfo.expectedApprover,
},
];
......@@ -121,7 +155,7 @@ export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps
style={{ fontSize: 13, fontWeight: 500 }}
>
<span style={{ color: '#374151' }}>
我已确认该门店 {info.sceneCount} 个业务场景共 {info.totalRows} 行数据准确无误
我已确认该门店 {finalInfo.sceneCount} 个业务场景共 {finalInfo.totalRows} 行数据准确无误
</span>
</UCheckbox>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
......
......@@ -3,10 +3,15 @@ import { UButton } from '@uj/ui';
export interface UploadActionBarProps {
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 (
<div
style={{
......@@ -18,7 +23,8 @@ export function UploadActionBar({ disabled = false, onNext }: UploadActionBarPro
<UButton
type="primary"
icon={<ArrowRightOutlined />}
disabled={disabled}
disabled={disabled || loading}
loading={loading}
onClick={onNext ?? (() => console.log('下一步:数据校验'))}
>
下一步:数据校验
......
import { UCard } from '@uj/ui';
import type { StoreImportCheckVO } from '@/api/modules/store';
export interface StatItem {
label: string;
......@@ -78,34 +79,88 @@ function StatCard({ item }: StatCardProps) {
export interface ValidationStatsProps {
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[] = [
{
label: '解析总行数',
value: '13',
desc: '1 家门店 · 2 个业务场景 · 12 行',
value: '-',
desc: '上传文件后展示',
tone: 'primary',
},
{
label: '校验通过',
value: '12',
desc: '可提交审批',
value: '-',
desc: '上传文件后展示',
tone: 'success',
},
];
export function ValidationStats({ stats = defaultStats }: ValidationStatsProps) {
export function ValidationStats({ stats, checkResult }: ValidationStatsProps) {
const finalStats: StatItem[] = stats ?? (checkResult ? buildStatsFromCheckResult(checkResult) : defaultStats);
return (
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(4, 1fr)',
gridTemplateColumns: 'repeat(4, minmax(0, 1fr))',
gap: 16,
marginBottom: 20,
}}
>
{stats.map((s) => (
{finalStats.map((s) => (
<StatCard key={s.label} item={s} />
))}
</div>
......
import { useState } from 'react';
import { Skeleton } from '@uj/ui';
import { App, Skeleton } from 'antd';
import { PageHeader } from './components/PageHeader';
import { NoticeSection } from './components/NoticeSection';
import { StepsBar } from './components/StepsBar';
import { ImportInfoCard } from './components/ImportInfoCard';
import type { ImportInfoValues } from './components/ImportInfoCard';
import { UploadCard } from './components/UploadCard';
import { UploadActionBar } from './components/UploadActionBar';
import { ValidationStats } from './components/ValidationStats';
......@@ -14,13 +15,19 @@ import { ConfirmActionBar } from './components/ConfirmActionBar';
import { SubmitConfirmCard } from './components/SubmitConfirmCard';
import { ApprovalChainPreview } from './components/ApprovalChainPreview';
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() {
const loading = false;
const { message, modal } = App.useApp();
const [currentStep, setCurrentStep] = useState<0 | 1 | 2 | 3>(0);
const [fileUploaded, setFileUploaded] = useState(false);
const passCount = 12;
const [importInfo, setImportInfo] = useState<ImportInfoValues | null>(null);
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 = () => {
setCurrentStep((s) => (s > 0 ? ((s - 1) as 0 | 1 | 2 | 3) : s));
......@@ -28,12 +35,74 @@ export default function TemplateImport() {
const goNext = () => {
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 = () => {
console.log(`仅提交通过行(${passCount})`);
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" />;
......@@ -46,15 +115,23 @@ export default function TemplateImport() {
{currentStep === 0 && (
<>
<ImportInfoCard />
<UploadCard onUploadSuccess={() => setFileUploaded(true)} />
<UploadActionBar disabled={!fileUploaded} onNext={goNext} />
<ImportInfoCard
values={importInfo ?? undefined}
onChange={(v) => setImportInfo(v)}
/>
<UploadCard
file={selectedFile}
remark={importInfo?.remark}
onFileChange={handleFileChange}
onUploadSuccess={handleUploadSuccess}
/>
<UploadActionBar disabled={!checkResult?.submitted} onNext={goNext} />
</>
)}
{currentStep === 1 && (
<>
<ValidationStats />
<ValidationStats checkResult={checkResult ?? undefined} />
<ValidationActionBar
passCount={passCount}
onBack={goPrev}
......@@ -66,17 +143,30 @@ export default function TemplateImport() {
{currentStep === 2 && (
<>
<PolicyConfirmHeader storeName="巴州强冠东风汽车销售服务有限公司" totalRows={12} />
<PolicyConfirmTable dataSource={mockPolicyRows} />
<ConfirmActionBar passCount={passCount} onBack={goPrev} onSubmit={goNext} />
<PolicyConfirmHeader
storeName={checkResult?.storeName}
totalRows={checkResult?.productCategoryRowCount ?? checkResult?.passRows}
/>
<PolicyConfirmTable previewRows={checkResult?.previewRows} />
<ConfirmActionBar
passCount={passCount}
onBack={goPrev}
onSubmit={goNext}
/>
</>
)}
{currentStep === 3 && (
<>
<SubmitConfirmCard />
<SubmitConfirmCard checkResult={checkResult ?? undefined} />
<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>
......
import type { StoreImportRowDTO } from '@/api/modules/store';
export interface PolicyConfirmRow {
// 门店信息(4 列)
storeName: string;
storeMerchantNo: string;
businessScene: string;
productCategory: string;
// 商务政策(14 列:管理层市场费 ×6 + 一线阳光 ×4 + 一线阳光2 ×4)
mgmtFee1Mode: string;
mgmtFee1CalcMethod: string;
mgmtFee1Value: string;
......@@ -11,26 +15,36 @@ export interface PolicyConfirmRow {
mgmtFee2Value: string;
sunshineOnlinePoints: 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 = [
'太阳膜-原厂',
'车衣-原厂',
'精品-小桌板',
'精品-脚垫',
'踏板',
'车衣-副厂',
'车辆美容',
'精品(集采)',
'记录仪',
'其他(众筹)',
'电子烟(集采)',
'太阳膜()',
];
function buildRows(): PolicyConfirmRow[] {
const rows: PolicyConfirmRow[] = [];
for (const scene of BUSINESS_SCENES) {
for (const cat of PRODUCT_CATEGORIES) {
const calcMode = cat === '车衣-原厂' ? '按整单计算' : '按品类计算';
const calcMode = cat === '精品(集采)' ? '按整单计算' : '按品类计算';
rows.push({
storeName: '巴州强冠东风汽车销售服务有限公司',
storeMerchantNo: 'SQ20240115',
storeName: '明明崇文4s店A',
storeMerchantNo: '44211227',
businessScene: scene,
productCategory: cat,
mgmtFee1Mode: calcMode,
......@@ -41,6 +55,15 @@ function buildRows(): PolicyConfirmRow[] {
mgmtFee2Value: '5%',
sunshineOnlinePoints: '是',
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[] {
}
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!