Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-store
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 25309a95
authored
Oct 10, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.0' of
http://192.168.3.233:8090/ujia/uj-store
into v1.0.0
2 parents
ac1c9986
318ab129
Pipeline
#313
for
25309a95
failed
in 0 seconds
Changes
13
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
421 additions
and
167 deletions
src/api/core/client.ts
src/api/core/http.ts
src/api/modules/store.ts
src/pages/TemplateImport/components/ApprovalChainPreview.tsx
src/pages/TemplateImport/components/FailDetailCard.tsx
src/pages/TemplateImport/components/ImportInfoCard.tsx
src/pages/TemplateImport/components/PolicyConfirmHeader.tsx
src/pages/TemplateImport/components/PolicyConfirmTable/columns.tsx
src/pages/TemplateImport/components/PolicyConfirmTable/index.tsx
src/pages/TemplateImport/components/SubmitConfirmCard.tsx
src/pages/TemplateImport/components/UploadCard.tsx
src/pages/TemplateImport/components/ValidationActionBar.tsx
src/pages/TemplateImport/index.tsx
src/api/core/client.ts
View file @
25309a9
...
@@ -32,6 +32,8 @@ export class ApiClient {
...
@@ -32,6 +32,8 @@ export class ApiClient {
/** 下载二进制文件(不解包 data,直接返回原始 blob + response headers(含 content-disposition)) */
/** 下载二进制文件(不解包 data,直接返回原始 blob + response headers(含 content-disposition)) */
protected
async
getBlob
(
url
:
string
,
params
?:
Record
<
string
,
unknown
>
):
Promise
<
BlobResponse
>
{
protected
async
getBlob
(
url
:
string
,
params
?:
Record
<
string
,
unknown
>
):
Promise
<
BlobResponse
>
{
// 注意:经过 http.ts 响应拦截器后,非 JSON(文件流)分支会返回 {data: Blob, headers} 包装体(与原生 resp 形状一致)
// 详见 src/api/core/http.ts 响应拦截器「非 JSON 分支」
const
resp
=
(
await
this
.
http
.
request
({
const
resp
=
(
await
this
.
http
.
request
({
method
:
'GET'
,
method
:
'GET'
,
url
,
url
,
...
...
src/api/core/http.ts
View file @
25309a9
...
@@ -83,12 +83,21 @@ http.interceptors.request.use((config: any) => {
...
@@ -83,12 +83,21 @@ http.interceptors.request.use((config: any) => {
});
});
// ---------- 响应拦截:服务端验签 + 统一错误 ----------
// ---------- 响应拦截:服务端验签 + 统一错误 ----------
/**
* 拦截器返回规则(统一 + 下游 getBlob/download 兼容):
* - JSON 响应:返回 ApiResult 的解包结果 body(= {code,data,message} 或 throw err)
* - 非 JSON(文件流 / Blob):返回 { data: Blob, headers: AxiosHeaders } 结构体,
* 方便下游 ApiClient.getBlob 既能拿到原始 Blob,也能读到 content-disposition 拿文件名
*/
http
.
interceptors
.
response
.
use
(
http
.
interceptors
.
response
.
use
(
(
response
:
any
)
=>
{
(
response
:
any
)
=>
{
const
ct
=
(
response
.
headers
[
'content-type'
]
||
''
)
as
string
;
const
ct
=
(
response
.
headers
[
'content-type'
]
||
''
)
as
string
;
// 二进制/文件流(模板下载、导出):服务端不签名,直接返回(§4.3)
// 二进制/文件流(模板下载、导出):服务端不签名,直接返回
带 headers 的包装体
(§4.3)
if
(
!
ct
.
includes
(
'application/json'
))
{
if
(
!
ct
.
includes
(
'application/json'
))
{
return
response
.
data
;
return
{
data
:
response
.
data
,
headers
:
response
.
headers
??
{},
};
}
}
const
raw
=
typeof
response
.
data
===
'string'
?
response
.
data
:
JSON
.
stringify
(
response
.
data
);
const
raw
=
typeof
response
.
data
===
'string'
?
response
.
data
:
JSON
.
stringify
(
response
.
data
);
...
...
src/api/modules/store.ts
View file @
25309a9
...
@@ -18,7 +18,7 @@ export * from './storeTypes';
...
@@ -18,7 +18,7 @@ export * from './storeTypes';
// ---------- 门店导入(PRD §5.1 四步:下载→校验→确认→提交审批) ----------
// ---------- 门店导入(PRD §5.1 四步:下载→校验→确认→提交审批) ----------
/** 模板下载(免签,浏览器直链 / 网关暴露,§4.3) */
/** 模板下载(免签,浏览器直链 / 网关暴露,§4.3) */
export
const
STORE_IMPORT_TEMPLATE_URL
=
'/
api/
store/import/template'
;
export
const
STORE_IMPORT_TEMPLATE_URL
=
'/store/import/template'
;
export
interface
ImportSubmitPayload
{
export
interface
ImportSubmitPayload
{
taskId
:
string
;
taskId
:
string
;
...
@@ -260,6 +260,22 @@ class Store extends ApiClient {
...
@@ -260,6 +260,22 @@ class Store extends ApiClient {
defaultFilename
=
'【优加】门店上架模版-V1.0.1.xlsx'
,
defaultFilename
=
'【优加】门店上架模版-V1.0.1.xlsx'
,
):
Promise
<
void
>
{
):
Promise
<
void
>
{
const
{
blob
,
headers
}
=
await
this
.
getBlob
(
STORE_IMPORT_TEMPLATE_URL
);
const
{
blob
,
headers
}
=
await
this
.
getBlob
(
STORE_IMPORT_TEMPLATE_URL
);
// 防御:如果后端网关 / 鉴权拦截返回 JSON(比如 code!=200 的错误),blob 的 type 会是 application/json。
if
(
/application
\/
json/i
.
test
(
blob
.
type
)
||
blob
.
size
<
200
)
{
try
{
const
text
=
await
blob
.
text
();
const
err
=
JSON
.
parse
(
text
);
throw
Object
.
assign
(
new
Error
(
err
?.
message
??
'模板下载失败:返回不是文件流'
),
{
code
:
err
?.
code
,
data
:
err
?.
data
,
});
}
catch
(
e
)
{
if
(
e
instanceof
Error
&&
/^模板下载失败/
.
test
(
e
.
message
))
throw
e
;
throw
new
Error
(
'模板下载失败:响应不是 .xlsx 文件流'
);
}
}
const
disposition
=
(
headers
[
'content-disposition'
]
??
''
)
as
string
;
const
disposition
=
(
headers
[
'content-disposition'
]
??
''
)
as
string
;
let
filename
=
defaultFilename
;
let
filename
=
defaultFilename
;
if
(
disposition
)
{
if
(
disposition
)
{
...
...
src/pages/TemplateImport/components/ApprovalChainPreview.tsx
View file @
25309a9
import { InfoCircleFilled, CheckCircleFilled } from '@ant-design/icons';
import { InfoCircleFilled, CheckCircleFilled } from '@ant-design/icons';
import { UCard, UTag } from '@uj/ui';
import { UCard, UTag } from '@uj/ui';
import { useAppStore } from '@/store/useAppStore';
export type ChainNodeStatus = 'done' | 'active' | 'pending';
export type ChainNodeStatus = 'done' | 'active' | 'pending';
...
@@ -10,24 +11,7 @@ export interface ChainNode {
...
@@ -10,24 +11,7 @@ export interface ChainNode {
time?: string;
time?: string;
}
}
const defaultNodes: ChainNode[] = [
const DEFAULT_SUBMIT_TIME = '2026-09-20 15:12';
{
status: 'done',
title: '提交',
subtitle: '陈盛',
time: '2026-09-20 15:12',
},
{
status: 'active',
title: '优加财务经理',
subtitle: '唯一审批节点',
},
{
status: 'pending',
title: '生效',
subtitle: '写入门店列表',
},
];
interface NodeIconProps {
interface NodeIconProps {
status: ChainNodeStatus;
status: ChainNodeStatus;
...
@@ -114,12 +98,51 @@ function NodeLine({ status }: { status: ChainNodeStatus }) {
...
@@ -114,12 +98,51 @@ function NodeLine({ status }: { status: ChainNodeStatus }) {
export interface ApprovalChainPreviewProps {
export interface ApprovalChainPreviewProps {
nodes?: ChainNode[];
nodes?: ChainNode[];
chainType?: string;
chainType?: string;
/** (可选)覆盖默认的提交人名称。不传则取当前登录用户名 */
submitterName?: string;
/** (可选)覆盖默认的提交时间,格式 YYYY-MM-DD HH:mm */
submitTime?: string;
}
/**
* 生成默认 3 节点审批链:
* - 第 1 个节点「提交」:副标题 = 当前登录用户名(外部 prop 覆盖优先);时间 = submitTime 或 DEFAULT_SUBMIT_TIME
* - 第 2 个节点「优加财务经理」:唯一审批节点
* - 第 3 个节点「生效」:写入门店列表
*/
function buildDefaultNodes(submitter: string, time: string): ChainNode[] {
return [
{
status: 'done',
title: '提交',
subtitle: submitter,
time,
},
{
status: 'active',
title: '优加财务经理',
subtitle: '唯一审批节点',
},
{
status: 'pending',
title: '生效',
subtitle: '写入门店列表',
},
];
}
}
export function ApprovalChainPreview({
export function ApprovalChainPreview({
nodes
= defaultNodes
,
nodes,
chainType = '单级审批',
chainType = '单级审批',
submitterName,
submitTime,
}: ApprovalChainPreviewProps) {
}: ApprovalChainPreviewProps) {
const { currentUser } = useAppStore();
const finalSubmitter = submitterName ?? currentUser.name ?? '管理员';
const finalTime = submitTime ?? DEFAULT_SUBMIT_TIME;
const finalNodes: ChainNode[] = nodes ?? buildDefaultNodes(finalSubmitter, finalTime);
return (
return (
<UCard
<UCard
styles={{ body: { padding: '20px 24px 24px' } }}
styles={{ body: { padding: '20px 24px 24px' } }}
...
@@ -137,7 +160,7 @@ export function ApprovalChainPreview({
...
@@ -137,7 +160,7 @@ export function ApprovalChainPreview({
}
}
>
>
<div style={{ display: 'flex', padding: '20px 8px 8px' }}>
<div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{
n
odes.map((n, i) => (
{
finalN
odes.map((n, i) => (
<div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}>
<div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}>
<div
<div
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}
...
@@ -178,7 +201,7 @@ export function ApprovalChainPreview({
...
@@ -178,7 +201,7 @@ export function ApprovalChainPreview({
</div>
</div>
)}
)}
</div>
</div>
{i <
nodes.length - 1 && <NodeLine status={n
odes[i].status} />}
{i <
finalNodes.length - 1 && <NodeLine status={finalN
odes[i].status} />}
</div>
</div>
))}
))}
</div>
</div>
...
...
src/pages/TemplateImport/components/FailDetailCard.tsx
0 → 100644
View file @
25309a9
This diff is collapsed.
Click to expand it.
src/pages/TemplateImport/components/ImportInfoCard.tsx
View file @
25309a9
import { useEffect } from 'react';
import { useEffect
, useMemo
} from 'react';
import { InfoCircleFilled } from '@ant-design/icons';
import { InfoCircleFilled } from '@ant-design/icons';
import { App } from 'antd';
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';
import type { StoreImportCheckVO } from '@/api/modules/store';
export interface ImportInfoValues {
export interface ImportInfoValues {
org: string;
org: string;
...
@@ -10,39 +12,55 @@ export interface ImportInfoValues {
...
@@ -10,39 +12,55 @@ export interface ImportInfoValues {
remark?: string;
remark?: string;
}
}
// 注意:value 统一用 label 字符串,与后端 StoreImportCheckVO 返回的 orgPath / businessScene / productCategories 对齐
const orgOptions: USelectProps['options'] = [
{ label: '优加主体 / 线上运营部', value: '优加主体 / 线上运营部' },
{ label: '优加主体 / 线下事业部', value: '优加主体 / 线下事业部' },
];
const sceneOptions: USelectProps['options'] = [
{ label: '售后会员权益升级 / 售前延保', value: '售后会员权益升级 / 售前延保' },
{ label: '汽车用品销售', value: '汽车用品销售' },
{ label: '保养服务', value: '保养服务' },
];
const categoryOptions: USelectProps['options'] = [
{ label: '太阳膜-原厂', value: '太阳膜-原厂' },
{ label: '车衣-原厂', value: '车衣-原厂' },
{ label: '精品-小桌板', value: '精品-小桌板' },
{ label: '精品-脚垫', value: '精品-脚垫' },
{ label: '精品-后备箱垫', value: '精品-后备箱垫' },
{ label: '保养-基础A保', value: '保养-基础A保' },
];
const formItemLayout = {
const formItemLayout = {
style: { marginBottom: 18 },
style: { marginBottom: 18 },
};
};
export interface ImportInfoCardProps {
export interface ImportInfoCardProps {
values?: Partial<ImportInfoValues>;
values?: Partial<ImportInfoValues>;
/** check 接口返回结果(用于动态生成 3 个下拉的 options) */
checkResult?: StoreImportCheckVO | null;
onChange?: (values: ImportInfoValues) => void;
onChange?: (values: ImportInfoValues) => void;
}
}
export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
export function ImportInfoCard({ values, checkResult, onChange }: ImportInfoCardProps) {
const { message } = App.useApp();
const [form] = UForm.useForm<ImportInfoValues>();
const [form] = UForm.useForm<ImportInfoValues>();
/**
* 3 个下拉 options 完全由接口返回决定(不再硬编码):
* - orgPath / businessScene 都是单值(名字里可能带 "/",是层级/组合名,不拆分)
* - productCategories 是多值,用 "/" 分隔成多选数组
*/
const orgOptions: USelectProps['options'] = useMemo(() => {
if (!checkResult?.orgPath) return [];
return [{ label: checkResult.orgPath, value: checkResult.orgPath }];
}, [checkResult?.orgPath]);
const sceneOptions: USelectProps['options'] = useMemo(() => {
if (!checkResult?.businessScene) return [];
return [{ label: checkResult.businessScene, value: checkResult.businessScene }];
}, [checkResult?.businessScene]);
const categoryOptions: USelectProps['options'] = useMemo(() => {
if (!checkResult?.productCategories) return [];
return checkResult.productCategories
.split('/')
.map((s) => s.trim())
.filter(Boolean)
.map((v) => ({ label: v, value: v }));
}, [checkResult?.productCategories]);
// 「只读」标记:只要任一3个下拉从接口回填过,即被锁定,禁止改动
const readOnly = useMemo(
() =>
Boolean(
values &&
(values.org || values.scene || (values.categories && values.categories.length > 0)),
),
[values],
);
// 受控回填:外部 values 变化时,把导入结果同步到表单
// 受控回填:外部 values 变化时,把导入结果同步到表单
useEffect(() => {
useEffect(() => {
if (values) {
if (values) {
...
@@ -50,7 +68,28 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
...
@@ -50,7 +68,28 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
}
}
}, [values, form]);
}, [values, form]);
const handleValuesChange = (_: Partial<ImportInfoValues>, all: ImportInfoValues) => {
const handleValuesChange = (changed: Partial<ImportInfoValues>, all: ImportInfoValues) => {
// 只读模式下:所属组织/业务场景/产品分类一旦由接口回填确定,不允许再修改
if (readOnly) {
const lockedKeys: (keyof ImportInfoValues)[] = ['org', 'scene', 'categories'];
const touched = lockedKeys.filter((k) => Object.prototype.hasOwnProperty.call(changed, k));
if (touched.length > 0) {
message.warning('该字段由模板解析结果自动回填,不可手动修改');
// 立刻恢复原值(只读语义:展示原值恢复不改)
form.setFieldsValue({
org: values?.org ?? all.org,
scene: values?.scene ?? all.scene,
categories: values?.categories ?? all.categories,
});
// 回退 touched keys 恢复后,不向上游广播 change(只传 remark 的变化允许)
const next: ImportInfoValues = { ...all };
if (values?.org != null) next.org = values.org;
if (values?.scene != null) next.scene = values.scene;
if (values?.categories != null) next.categories = values.categories;
onChange?.(next);
return;
}
}
onChange?.(all);
onChange?.(all);
};
};
...
@@ -89,11 +128,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
...
@@ -89,11 +128,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
name="org"
name="org"
{...formItemLayout}
{...formItemLayout}
>
>
<USelect
<USelect options={orgOptions} placeholder="请选择所属组织" />
disabled
options={orgOptions}
placeholder="请选择所属组织"
/>
</UFormItem>
</UFormItem>
<UFormItem
<UFormItem
...
@@ -105,11 +140,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
...
@@ -105,11 +140,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
name="scene"
name="scene"
{...formItemLayout}
{...formItemLayout}
>
>
<USelect
<USelect options={sceneOptions} placeholder="请选择业务场景" />
disabled
options={sceneOptions}
placeholder="请选择业务场景"
/>
</UFormItem>
</UFormItem>
<UFormItem
<UFormItem
...
@@ -122,7 +153,6 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
...
@@ -122,7 +153,6 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
{...formItemLayout}
{...formItemLayout}
>
>
<USelect
<USelect
disabled
mode="multiple"
mode="multiple"
options={categoryOptions}
options={categoryOptions}
placeholder="请选择产品分类"
placeholder="请选择产品分类"
...
@@ -153,7 +183,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
...
@@ -153,7 +183,7 @@ export function ImportInfoCard({ values, onChange }: ImportInfoCardProps) {
<UFormItem
<UFormItem
label={<span style={{ marginTop: 18, display: 'inline-block' }}>备注</span>}
label={<span style={{ marginTop: 18, display: 'inline-block' }}>备注</span>}
name="remark"
name="remark"
style={{ marginBottom:
0
}}
style={{ marginBottom:
8
}}
>
>
<UInput.TextArea
<UInput.TextArea
rows={2}
rows={2}
...
...
src/pages/TemplateImport/components/PolicyConfirmHeader.tsx
View file @
25309a9
...
@@ -3,13 +3,30 @@ import { UText } from '@uj/ui';
...
@@ -3,13 +3,30 @@ import { UText } from '@uj/ui';
export interface PolicyConfirmHeaderProps {
export interface PolicyConfirmHeaderProps {
storeName?: string;
storeName?: string;
/** 总解析行数(兜底用) */
totalRows?: number;
totalRows?: number;
/** 校验通过行数(failRows>0 时优先显示这个) */
passRows?: number;
/** 校验失败行数(> 0 时,红框数量改用 passRows 显示) */
failRows?: number;
}
}
export function PolicyConfirmHeader({
export function PolicyConfirmHeader({
storeName = '巴州强冠东风汽车销售服务有限公司',
storeName = '巴州强冠东风汽车销售服务有限公司',
totalRows = 12,
totalRows = 12,
passRows,
failRows,
}: PolicyConfirmHeaderProps) {
}: PolicyConfirmHeaderProps) {
/**
* 显示数量规则(与 Step4 SubmitConfirmCard 两处红框保持一致):
* - 有失败行(failRows > 0)→ 只显示通过数量 passRows
* - 全通过 → 显示 totalRows(= 总解析行数 productCategoryRowCount)
*/
const displayRows =
typeof failRows === 'number' && failRows > 0 && typeof passRows === 'number'
? passRows
: totalRows;
return (
return (
<div
<div
style={{
style={{
...
@@ -23,7 +40,7 @@ export function PolicyConfirmHeader({
...
@@ -23,7 +40,7 @@ export function PolicyConfirmHeader({
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600, color: '#1A202C' }}>
<span style={{ fontSize: 15, fontWeight: 600, color: '#1A202C' }}>
商务政策确认 · {storeName} / 共 {
total
Rows} 行
商务政策确认 · {storeName} / 共 {
display
Rows} 行
</span>
</span>
</div>
</div>
<UText type="secondary" style={{ fontSize: 12 }}>
<UText type="secondary" style={{ fontSize: 12 }}>
...
...
src/pages/TemplateImport/components/PolicyConfirmTable/columns.tsx
View file @
25309a9
...
@@ -77,16 +77,6 @@ function FeeValueCell({ value }: { value: string }) {
...
@@ -77,16 +77,6 @@ function FeeValueCell({ value }: { value: string }) {
return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
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 列) -------------
// ------------- 第一组:门店信息(4 列) -------------
...
...
src/pages/TemplateImport/components/PolicyConfirmTable/index.tsx
View file @
25309a9
...
@@ -6,17 +6,56 @@ import type { StoreImportRowDTO } from '@/api/modules/store';
...
@@ -6,17 +6,56 @@ import type { StoreImportRowDTO } from '@/api/modules/store';
import { mockPolicyRows, convertPreviewRows } from '../../tools/policyTableData';
import { mockPolicyRows, convertPreviewRows } from '../../tools/policyTableData';
import type { PolicyConfirmRow } from '../../tools/policyTableData';
import type { PolicyConfirmRow } from '../../tools/policyTableData';
const footerText =
'表格唯一项 = 门店 + 业务场景 + 产品分类。同一门店的多个业务场景各占独立行(本批次 2 个业务场景 × 6 个产品分类 = 12 行),门店名称重复出现、不合并;「业务场景」若一家门店有多个,须拆分为独立行导入。「产品分类」多级分类可用「-」区分。「装修、设备总投入」「当月产生费用」按产品分类维度合并填写,「人工成本」按人力成本维度合并填写 —— 同一门店的多行需保持一致,系统将校验一致性。';
export interface PolicyConfirmTableProps {
export interface PolicyConfirmTableProps {
dataSource?: PolicyConfirmRow[];
dataSource?: PolicyConfirmRow[];
previewRows?: StoreImportRowDTO[];
previewRows?: StoreImportRowDTO[];
/** 通过行的业务场景数(如 2) */
ruleSceneCount?: number;
/** 通过行的产品分类数(如 6) */
ruleCategoryCount?: number;
/** 通过行数(标题红框显示的数,如 11) */
ruleTotalRows?: number;
}
}
export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTableProps) {
export function PolicyConfirmTable({
dataSource,
previewRows,
ruleSceneCount,
ruleCategoryCount,
ruleTotalRows,
}: PolicyConfirmTableProps) {
const columns = useMemo(() => buildPolicyColumns() as any[], []);
const columns = useMemo(() => buildPolicyColumns() as any[], []);
/**
* 动态拼接 footer 文字:优先用外部传入的通过行统计,
* 否则从 previewRows 派生,最后兜底 2 场景 × 6 分类 = 12 行。
*/
const footerText = useMemo(() => {
// 内部派生兜底(外部没传时用)
let s = ruleSceneCount;
let c = ruleCategoryCount;
let t = ruleTotalRows;
if (
(typeof s !== 'number' || typeof c !== 'number' || typeof t !== 'number') &&
Array.isArray(previewRows) &&
previewRows.length > 0
) {
s = s ?? new Set(previewRows.map((r) => r.businessScene).filter(Boolean)).size;
c = c ?? new Set(previewRows.map((r) => r.productCategory).filter(Boolean)).size;
t = t ?? previewRows.length;
}
const scene = s ?? 2;
const category = c ?? 6;
const total = t ?? scene * category;
return (
`表格唯一项 = 门店 + 业务场景 + 产品分类。同一门店的多个业务场景各占独立行` +
`(本批次 ${scene} 个业务场景 × ${category} 个产品分类 = ${total} 行),` +
`门店名称重复出现、不合并;「业务场景」若一家门店有多个,须拆分为独立行导入。` +
`「产品分类」多级分类可用「-」区分。「装修、设备总投入」「当月产生费用」按产品分类维度合并填写,` +
`「人工成本」按人力成本维度合并填写 —— 同一门店的多行需保持一致,系统将校验一致性。`
);
}, [ruleSceneCount, ruleCategoryCount, ruleTotalRows, previewRows]);
// columns 预设宽度累加,保证横向滚动条出现
// columns 预设宽度累加,保证横向滚动条出现
const scrollX = useMemo(() => {
const scrollX = useMemo(() => {
const colWidths: number[] = [];
const colWidths: number[] = [];
...
@@ -44,8 +83,7 @@ export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTab
...
@@ -44,8 +83,7 @@ export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTab
}, [dataSource, previewRows]);
}, [dataSource, previewRows]);
const tableProps = {
const tableProps = {
rowKey: (r: PolicyConfirmRow) =>
rowKey: (r: PolicyConfirmRow) => `${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`,
`${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`,
columns: columns as UTableProps<PolicyConfirmRow>['columns'],
columns: columns as UTableProps<PolicyConfirmRow>['columns'],
dataSource: rows,
dataSource: rows,
size: 'middle' as const,
size: 'middle' as const,
...
@@ -68,10 +106,7 @@ export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTab
...
@@ -68,10 +106,7 @@ export function PolicyConfirmTable({ dataSource, previewRows }: PolicyConfirmTab
}}
}}
>
>
{/* 外层专属 wrapper:覆盖全局 index.css 关 ant Table 横向滚动的 !important 规则 */}
{/* 外层专属 wrapper:覆盖全局 index.css 关 ant Table 横向滚动的 !important 规则 */}
<div
<div className="policy-confirm-table-wrap" style={{ width: '100%' }}>
className="policy-confirm-table-wrap"
style={{ width: '100%' }}
>
<UTable<PolicyConfirmRow> {...tableProps} />
<UTable<PolicyConfirmRow> {...tableProps} />
</div>
</div>
<div
<div
...
...
src/pages/TemplateImport/components/SubmitConfirmCard.tsx
View file @
25309a9
import { useMemo
, useState
} from 'react';
import { useMemo } from 'react';
import { InfoCircleFilled } from '@ant-design/icons';
import { InfoCircleFilled
, ExclamationCircleOutlined
} 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';
import type { StoreImportCheckVO } from '@/api/modules/store';
import { useAppStore } from '@/store/useAppStore';
export interface SubmitConfirmInfo {
export interface SubmitConfirmInfo {
storeName: string;
storeName: string;
...
@@ -17,20 +18,6 @@ export interface SubmitConfirmInfo {
...
@@ -17,20 +18,6 @@ export interface SubmitConfirmInfo {
expectedApprover: string;
expectedApprover: string;
}
}
const defaultInfo: SubmitConfirmInfo = {
storeName: '巴州强冠东风汽车销售服务有限公司',
storeMerchantNo: 'SQ20240115',
categoryCount: 6,
sceneCount: 2,
totalRows: 12,
operatingCost: '¥ 1,500.00',
operatingCostDetail: '门店维度字段(装修设备 500 + 当月产生 500 + 人工成本 500)',
approvalChain: '优加财务经理',
approvalChainTag: '单级审批',
approvalChainDesc: '提交后直接进入单级审批,无中间节点',
expectedApprover: '陈盛(优加财务经理)',
};
const labelStyle: React.CSSProperties = {
const labelStyle: React.CSSProperties = {
width: 120,
width: 120,
flex: 'none',
flex: 'none',
...
@@ -50,46 +37,70 @@ const descStyle: React.CSSProperties = {
...
@@ -50,46 +37,70 @@ const descStyle: React.CSSProperties = {
marginLeft: 6,
marginLeft: 6,
};
};
function buildInfoFromCheckResult(vo: StoreImportCheckVO): SubmitConfirmInfo {
function buildInfoFromCheckResult(
vo: StoreImportCheckVO,
currentUserName: string,
): SubmitConfirmInfo {
const preview = vo.previewRows ?? [];
const preview = vo.previewRows ?? [];
const first = preview[0];
const first = preview[0];
const deco = Math.round(first?.costDecoration ?? 0);
const deco = Math.round(first?.costDecoration ?? 0);
const monthly = Math.round(first?.costMonthly ?? 0);
const monthly = Math.round(first?.costMonthly ?? 0);
const labor = Math.round(first?.costLabor ?? 0);
const labor = Math.round(first?.costLabor ?? 0);
const total = deco + monthly + labor;
const total = deco + monthly + labor;
const expectedApprover = vo.nextRoleName
const approvalRole = vo.nextRoleName ?? '优加财务经理';
? `(${vo.nextRoleName})`
: `(优加财务经理)`;
return {
return {
storeName: vo.storeName ??
defaultInfo.storeName
,
storeName: vo.storeName ??
'巴州强冠东风汽车销售服务有限公司'
,
storeMerchantNo: vo.merchantNo ??
defaultInfo.storeMerchantNo
,
storeMerchantNo: vo.merchantNo ??
'SQ20240115'
,
categoryCount: vo.distinctProductCategoryCount ??
defaultInfo.categoryCount
,
categoryCount: vo.distinctProductCategoryCount ??
6
,
sceneCount: vo.distinctBusinessSceneCount ??
defaultInfo.sceneCount
,
sceneCount: vo.distinctBusinessSceneCount ??
2
,
totalRows: vo.productCategoryRowCount ?? vo.totalRows ??
defaultInfo.totalRows
,
totalRows: vo.productCategoryRowCount ?? vo.totalRows ??
12
,
operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` :
defaultInfo.operatingCost
,
operatingCost: total > 0 ? `¥ ${total.toLocaleString('en-US')}` :
'¥ 1,500.00'
,
operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`,
operatingCostDetail: `门店维度字段(装修设备 ${deco} + 当月产生 ${monthly} + 人工成本 ${labor})`,
approvalChain: vo.nextRoleName || defaultInfo.approvalChain,
approvalChain: approvalRole,
approvalChainTag: defaultInfo.approvalChainTag,
approvalChainTag: '单级审批',
approvalChainDesc: defaultInfo.approvalChainDesc,
approvalChainDesc: '提交后直接进入单级审批,无中间节点',
expectedApprover: defaultInfo.expectedApprover.includes(vo.nextRoleName ?? '')
// 预计审批人 = 当前提交人(登录用户名) + (审批角色)
? defaultInfo.expectedApprover
expectedApprover: `${approvalRole}`,
: `陈盛${expectedApprover}`,
};
};
}
}
export interface SubmitConfirmCardProps {
export interface SubmitConfirmCardProps {
info?: SubmitConfirmInfo;
info?: SubmitConfirmInfo;
checkResult?: StoreImportCheckVO;
checkResult?: StoreImportCheckVO;
checked?: boolean;
onCheckedChange?: (checked: boolean) => void;
}
}
export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps) {
export function SubmitConfirmCard({
const [checked, setChecked] = useState(true);
info,
checkResult,
checked = true,
onCheckedChange,
}: SubmitConfirmCardProps) {
const { currentUser } = useAppStore();
const userName = currentUser.name ?? '管理员';
const f
inal
Info: SubmitConfirmInfo = useMemo(
const f
allback
Info: SubmitConfirmInfo = useMemo(
() =>
info ?? (checkResult ? buildInfoFromCheckResult(checkResult) : defaultInfo
),
() =>
buildInfoFromCheckResult(checkResult ?? ({} as StoreImportCheckVO), userName
),
[
info, checkResult
],
[
checkResult, userName
],
);
);
const finalInfo: SubmitConfirmInfo = info ?? fallbackInfo;
/**
* 红框两处「共 N 行」的取值:
* - 只要存在校验失败(failRows>0)→ 本次提交的都是通过行 → 显示 passRows(通过行数,例如 11)
* - 全通过(failRows=0)→ 显示 productCategoryRowCount / totalRows(总解析行数,例如 12)
* - 不再依赖 onlyPass 字段(父组件可能不传),直接按业务结果决定
*/
const displayRows =
checkResult &&
typeof checkResult.failRows === 'number' &&
checkResult.failRows > 0 &&
typeof checkResult.passRows === 'number'
? checkResult.passRows
: finalInfo.totalRows;
const infoRows: Array<{
const infoRows: Array<{
label: string;
label: string;
value: React.ReactNode;
value: React.ReactNode;
...
@@ -107,7 +118,7 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
...
@@ -107,7 +118,7 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
{
{
label: '产品分类',
label: '产品分类',
value: `${finalInfo.categoryCount} 个`,
value: `${finalInfo.categoryCount} 个`,
desc: `(${finalInfo.sceneCount} 个业务场景,共 ${
finalInfo.total
Rows} 行)`,
desc: `(${finalInfo.sceneCount} 个业务场景,共 ${
display
Rows} 行)`,
},
},
{
{
label: '运营成本合计',
label: '运营成本合计',
...
@@ -141,6 +152,35 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
...
@@ -141,6 +152,35 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
</div>
</div>
}
}
>
>
{checkResult && (checkResult.failRows ?? 0) > 0 && (
<div
style={{
padding: '10px 14px',
borderRadius: 8,
background: '#FFF7ED',
border: '1px solid #FED7AA',
display: 'flex',
alignItems: 'flex-start',
gap: 8,
marginBottom: 16,
}}
>
<ExclamationCircleOutlined
style={{ color: '#EA580C', fontSize: 16, marginTop: 1, flex: 'none' }}
/>
<div style={{ flex: 1, fontSize: 12, lineHeight: '20px' }}>
<span style={{ color: '#9A3412', fontWeight: 600 }}>
本次存在校验失败数据:共 {checkResult.failRows} 行失败。
</span>
<span style={{ color: '#7C2D12', marginLeft: 4 }}>
本次将只提交「通过 {checkResult.passRows ?? 0} 行(listingIds 共{' '}
{checkResult.listingIds?.length ?? 0}{' '}
条)」进入审批,失败行需要您下载明细后修正再上传。
</span>
</div>
</div>
)}
<div
<div
style={{
style={{
padding: '14px 16px',
padding: '14px 16px',
...
@@ -151,11 +191,11 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
...
@@ -151,11 +191,11 @@ export function SubmitConfirmCard({ info, checkResult }: SubmitConfirmCardProps)
>
>
<UCheckbox
<UCheckbox
checked={checked}
checked={checked}
onChange={(e) =>
setChecked
(e.target.checked)}
onChange={(e) =>
onCheckedChange?.
(e.target.checked)}
style={{ fontSize: 13, fontWeight: 500 }}
style={{ fontSize: 13, fontWeight: 500 }}
>
>
<span style={{ color: '#374151' }}>
<span style={{ color: '#374151' }}>
我已确认该门店 {finalInfo.sceneCount} 个业务场景共 {
finalInfo.total
Rows} 行数据准确无误
我已确认该门店 {finalInfo.sceneCount} 个业务场景共 {
display
Rows} 行数据准确无误
</span>
</span>
</UCheckbox>
</UCheckbox>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
...
...
src/pages/TemplateImport/components/UploadCard.tsx
View file @
25309a9
...
@@ -13,27 +13,83 @@ import type { RcFile } from 'antd/es/upload/interface';
...
@@ -13,27 +13,83 @@ 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 type { StoreImportCheckVO } from '@/api/modules/store';
import type { StoreImportCheckVO } from '@/api/modules/store';
import {
import { validateFileExtension, validateFileSize, UPLOAD_RULES } from '../tools/uploadValidate';
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 {
file?: File | null;
file?: File | null;
remark?: string;
remark?: string;
/** 上传后 check 接口返回结果(用于回显行数/门店数/场景数/分类数/版本) */
checkResult?: StoreImportCheckVO | null;
/** 父组件触发重新上传的信号:每次递增即自动重跑 runUpload(使用已选 file) */
reUploadTrigger?: number;
onFileChange?: (file: File | null) => void;
onFileChange?: (file: File | null) => void;
onUploadSuccess?: (vo: StoreImportCheckVO) => void;
onUploadSuccess?: (vo: StoreImportCheckVO) => void;
}
}
export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: UploadCardProps) {
export function UploadCard({
file,
remark,
checkResult,
reUploadTrigger = 0,
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 [fileList, setFileList] = useState<UploadFile[]>([]);
const [fileList, setFileList] = useState<UploadFile[]>([]);
/** 从 checkResult + 文件名推导要显示的统计文案:共 N 行(X 家门店 × Y 场景 × Z 分类)· 模板版本 vX.X.X */
const statLineText = (() => {
if (!checkResult) return null;
const previewRows = checkResult.previewRows ?? [];
// 门店数:优先 storeName 存在即算 1 家;或从 previewRows 去重
const storeCount = (() => {
if (checkResult.storeName) return 1;
const s = new Set(previewRows.map((r) => r.storeName).filter(Boolean));
return s.size || 1;
})();
const sceneCount =
// 注意:businessScene 是单值(名字里可能带 "/" 是组合名,不拆分),有值就算 1 个场景;
// 多场景统计通过 previewRows 去重派生
(checkResult.businessScene ? 1 : 0) ||
new Set(previewRows.map((r) => r.businessScene).filter(Boolean)).size ||
0;
const categoryCount =
(checkResult.productCategories
? new Set(
checkResult.productCategories
.split('/')
.map((s) => s.trim())
.filter(Boolean),
).size
: 0) ||
new Set(previewRows.map((r) => r.productCategory).filter(Boolean)).size ||
0;
const totalRows =
typeof checkResult.productCategoryRowCount === 'number'
? checkResult.productCategoryRowCount
: typeof checkResult.totalRows === 'number'
? checkResult.totalRows
: previewRows.length || 0;
// 模板版本:优先从文件名解析(xxx-V1.0.1.xlsx → v1.0.1);兜底 TEMPLATE_NAME 里的版本
const fileVersion = (() => {
const name = fileList[0]?.name || TEMPLATE_NAME || '';
const m = name.match(/[Vv](\d+(?:\.\d+){0,3})/);
if (m && m[1]) return `v${m[1]}`;
const mm = TEMPLATE_NAME.match(/[Vv](\d+(?:\.\d+){0,3})/);
return mm ? `v${mm[1]}` : 'v1.0.1';
})();
if (sceneCount > 0 && categoryCount > 0) {
return `共 ${totalRows} 行数据(${storeCount} 家门店 × ${sceneCount} 个业务场景 × ${categoryCount} 个产品分类)· 模板版本 ${fileVersion}`;
}
return `共 ${totalRows} 行数据 · 模板版本 ${fileVersion}`;
})();
// 受控:父组件 file 变化时,同步内部 fileList(解决返回上一步组件重新挂载丢失文件的问题)
// 受控:父组件 file 变化时,同步内部 fileList(解决返回上一步组件重新挂载丢失文件的问题)
useEffect(() => {
useEffect(() => {
if (file) {
if (file) {
...
@@ -44,6 +100,18 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
...
@@ -44,6 +100,18 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [file]);
}, [file]);
/**
* Step 2 → 点击失败明细里的【重新上传】:
* 父组件 handleReUpload = 切 Step0 + 清空 checkResult + reUploadCounter++
* 本 useEffect 监听 reUploadTrigger(>0 表示被触发过)+ 有 file + 非 uploading → 自动 runUpload
*/
useEffect(() => {
if (reUploadTrigger > 0 && file && !uploading) {
void runUpload(file);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reUploadTrigger]);
const clearFileState = useCallback(() => {
const clearFileState = useCallback(() => {
setFileList([]);
setFileList([]);
onFileChange?.(null);
onFileChange?.(null);
...
@@ -93,15 +161,6 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
...
@@ -93,15 +161,6 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
setUploading(true);
setUploading(true);
try {
try {
const vo = await store.uploadImport({ file: f, remark });
const vo = await store.uploadImport({ file: f, remark });
if (!vo.submitted) {
message.warning(
`校验未通过,失败 ${vo.failRows} 行,未完成落库;请修正后重新上传`,
);
} else {
message.success(
`上传完成:通过 ${vo.passRows} 行 / 失败 ${vo.failRows} 行${vo.failFileUrl ? ';已生成失败明细文件' : ''}`,
);
}
setFileList([buildUploadFile(f)]);
setFileList([buildUploadFile(f)]);
onFileChange?.(f);
onFileChange?.(f);
onUploadSuccess?.(vo);
onUploadSuccess?.(vo);
...
@@ -275,10 +334,20 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
...
@@ -275,10 +334,20 @@ export function UploadCard({ file, remark, onFileChange, onUploadSuccess }: Uplo
</div>
</div>
<div style={{ fontSize: 12, color: '#6B7280' }}>
<div style={{ fontSize: 12, color: '#6B7280' }}>
{fileList[0].size ? Math.max(1, Math.round(fileList[0].size / 1024)) : '-'} KB
{fileList[0].size ? Math.max(1, Math.round(fileList[0].size / 1024)) : '-'} KB
<CheckCircleFilled
<CheckCircleFilled style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }} />
style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }}
</div>
/>
{statLineText && (
<div
style={{
marginTop: 6,
fontSize: 12,
color: '#4B5563',
lineHeight: 1.6,
}}
>
{statLineText}
</div>
</div>
)}
</div>
</div>
<UButton
<UButton
type="text"
type="text"
...
...
src/pages/TemplateImport/components/ValidationActionBar.tsx
View file @
25309a9
...
@@ -2,16 +2,15 @@ import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
...
@@ -2,16 +2,15 @@ import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
import { UButton } from '@uj/ui';
export interface ValidationActionBarProps {
export interface ValidationActionBarProps {
passCount?: number;
/** 下一步(数据确认)按钮是否禁用(有失败行时禁用,先下载失败明细修模板) */
nextDisabled?: boolean;
onBack?: () => void;
onBack?: () => void;
onSubmitPassOnly?: () => void;
onNextStep?: () => void;
onNextStep?: () => void;
}
}
export function ValidationActionBar({
export function ValidationActionBar({
passCount = 12
,
nextDisabled = false
,
onBack,
onBack,
onSubmitPassOnly,
onNextStep,
onNextStep,
}: ValidationActionBarProps) {
}: ValidationActionBarProps) {
return (
return (
...
@@ -27,18 +26,14 @@ export function ValidationActionBar({
...
@@ -27,18 +26,14 @@ export function ValidationActionBar({
返回上一步
返回上一步
</UButton>
</UButton>
<div style={{ display: 'flex', gap: 12 }}>
<UButton onClick={onSubmitPassOnly ?? (() => console.log('仅提交通过行'))}>
仅提交通过行({passCount})
</UButton>
<UButton
<UButton
type="primary"
type="primary"
icon={<ArrowRightOutlined />}
icon={<ArrowRightOutlined />}
disabled={nextDisabled}
onClick={onNextStep ?? (() => console.log('下一步:数据确认'))}
onClick={onNextStep ?? (() => console.log('下一步:数据确认'))}
>
>
下一步:数据确认
下一步:数据确认
</UButton>
</UButton>
</div>
</div>
</div>
);
);
}
}
src/pages/TemplateImport/index.tsx
View file @
25309a9
...
@@ -14,6 +14,7 @@ import { PolicyConfirmTable } from './components/PolicyConfirmTable';
...
@@ -14,6 +14,7 @@ import { PolicyConfirmTable } from './components/PolicyConfirmTable';
import { ConfirmActionBar } from './components/ConfirmActionBar';
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 { FailDetailCard } from './components/FailDetailCard';
import { SubmitActionBar } from './components/SubmitActionBar';
import { SubmitActionBar } from './components/SubmitActionBar';
import { store } from '@/api';
import { store } from '@/api';
import type { StoreImportCheckVO } from '@/api/modules/store';
import type { StoreImportCheckVO } from '@/api/modules/store';
...
@@ -25,9 +26,14 @@ export default function TemplateImport() {
...
@@ -25,9 +26,14 @@ export default function TemplateImport() {
const [importInfo, setImportInfo] = useState<ImportInfoValues | null>(null);
const [importInfo, setImportInfo] = useState<ImportInfoValues | null>(null);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [checkResult, setCheckResult] = useState<StoreImportCheckVO | null>(null);
const [checkResult, setCheckResult] = useState<StoreImportCheckVO | null>(null);
// Step 4:提交确认勾选状态(受控,用于 disabled=!checked || 无通过数据)
const [submitChecked, setSubmitChecked] = useState(true);
const [submitting, setSubmitting] = useState(false);
const [submitting, setSubmitting] = useState(false);
// Step 2 点击【重新上传】:递增触发 UploadCard.useEffect 自动重新调用 runUpload(保留选中文件)
const [reUploadCounter, setReUploadCounter] = useState(0);
const passCount = checkResult?.passRows ?? 0;
const passCount = checkResult?.passRows ?? 0;
const failCount = checkResult?.failRows ?? 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));
...
@@ -69,9 +75,12 @@ export default function TemplateImport() {
...
@@ -69,9 +75,12 @@ export default function TemplateImport() {
}));
}));
};
};
const handleSubmitPassOnly = () => {
const handleReUpload = () => {
console.log(`仅提交通过行(${passCount})`);
// Step 2 重新上传:不清空文件,回到 Step0 后由 UploadCard.useEffect 监听 trigger 自动重跑上传
goNext();
setCheckResult(null);
setSubmitChecked(true);
setCurrentStep(0);
setReUploadCounter((c) => c + 1);
};
};
const handleFinalSubmit = async () => {
const handleFinalSubmit = async () => {
...
@@ -117,53 +126,72 @@ export default function TemplateImport() {
...
@@ -117,53 +126,72 @@ export default function TemplateImport() {
<>
<>
<ImportInfoCard
<ImportInfoCard
values={importInfo ?? undefined}
values={importInfo ?? undefined}
checkResult={checkResult}
onChange={(v) => setImportInfo(v)}
onChange={(v) => setImportInfo(v)}
/>
/>
<UploadCard
<UploadCard
file={selectedFile}
file={selectedFile}
remark={importInfo?.remark}
remark={importInfo?.remark}
checkResult={checkResult}
reUploadTrigger={reUploadCounter}
onFileChange={handleFileChange}
onFileChange={handleFileChange}
onUploadSuccess={handleUploadSuccess}
onUploadSuccess={handleUploadSuccess}
/>
/>
<UploadActionBar disabled={!checkResult
?.submitted
} onNext={goNext} />
<UploadActionBar disabled={!checkResult} onNext={goNext} />
</>
</>
)}
)}
{currentStep === 1 && (
{currentStep === 1 && (
<>
<>
<ValidationStats checkResult={checkResult ?? undefined} />
<ValidationStats checkResult={checkResult ?? undefined} />
<ValidationActionBar
<FailDetailCard checkResult={checkResult ?? undefined} onReUpload={handleReUpload} />
passCount={passCount}
<ValidationActionBar nextDisabled={failCount > 0} onBack={goPrev} onNextStep={goNext} />
onBack={goPrev}
onSubmitPassOnly={handleSubmitPassOnly}
onNextStep={goNext}
/>
</>
</>
)}
)}
{currentStep === 2 && (
{currentStep === 2 && (
<>
<>
{(() => {
// Step3 基于 previewRows(只含通过行)派生场景/分类数量,确保标题和 footer 都按通过数量显示
const previewRows = checkResult?.previewRows ?? [];
const ruleSceneCount = new Set(previewRows.map((r) => r.businessScene).filter(Boolean))
.size;
const ruleCategoryCount = new Set(
previewRows.map((r) => r.productCategory).filter(Boolean),
).size;
return (
<>
<PolicyConfirmHeader
<PolicyConfirmHeader
storeName={checkResult?.storeName}
storeName={checkResult?.storeName}
totalRows={checkResult?.productCategoryRowCount ?? checkResult?.passRows}
totalRows={checkResult?.productCategoryRowCount}
passRows={checkResult?.passRows}
failRows={checkResult?.failRows}
/>
/>
<PolicyConfirmTable previewRows={checkResult?.previewRows} />
<PolicyConfirmTable
<ConfirmActionBar
previewRows={checkResult?.previewRows}
passCount={passCount
}
ruleSceneCount={ruleSceneCount || undefined
}
onBack={goPrev
}
ruleCategoryCount={ruleCategoryCount || undefined
}
onSubmit={goNext
}
ruleTotalRows={passCount || undefined
}
/>
/>
<ConfirmActionBar passCount={passCount} onBack={goPrev} onSubmit={goNext} />
</>
);
})()}
</>
</>
)}
)}
{currentStep === 3 && (
{currentStep === 3 && (
<>
<>
<SubmitConfirmCard checkResult={checkResult ?? undefined} />
<SubmitConfirmCard
checkResult={checkResult ?? undefined}
checked={submitChecked}
onCheckedChange={setSubmitChecked}
/>
<ApprovalChainPreview />
<ApprovalChainPreview />
<SubmitActionBar
<SubmitActionBar
totalRows={passCount}
totalRows={
checkResult?.listingIds?.length ??
passCount}
loading={submitting}
loading={submitting}
disabled={!
checkResult?.submitt
ed || (checkResult?.listingIds?.length ?? 0) === 0}
disabled={!
submitCheck
ed || (checkResult?.listingIds?.length ?? 0) === 0}
onBack={goPrev}
onBack={goPrev}
onSubmit={handleFinalSubmit}
onSubmit={handleFinalSubmit}
/>
/>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment