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 cbad90be
authored
Oct 09, 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
21e62269
19186edb
Pipeline
#301
for
cbad90be
failed
in 0 seconds
Changes
21
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1803 additions
and
56 deletions
src/api/core/client.ts
src/api/modules/store.ts
src/pages/TemplateImport/components/ApprovalChainPreview.tsx
src/pages/TemplateImport/components/ConfirmActionBar.tsx
src/pages/TemplateImport/components/ImportInfoCard.tsx
src/pages/TemplateImport/components/ImportUploader.tsx
src/pages/TemplateImport/components/NoticeSection.tsx
src/pages/TemplateImport/components/PageHeader.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/StepsBar.tsx
src/pages/TemplateImport/components/SubmitActionBar.tsx
src/pages/TemplateImport/components/SubmitConfirmCard.tsx
src/pages/TemplateImport/components/UploadActionBar.tsx
src/pages/TemplateImport/components/UploadCard.tsx
src/pages/TemplateImport/components/ValidationActionBar.tsx
src/pages/TemplateImport/components/ValidationStats.tsx
src/pages/TemplateImport/index.tsx
src/pages/TemplateImport/tools/policyTableData.ts
src/pages/TemplateImport/tools/uploadValidate.ts
src/api/core/client.ts
View file @
cbad90b
...
...
@@ -3,6 +3,12 @@
// 规范见《优加门店上架系统 · 前后端 RSA 非对称加签对接说明》。
import
{
http
}
from
'./http'
;
import
type
{
ApiResult
}
from
'./types'
;
import
type
{
AxiosResponseHeaders
}
from
'axios'
;
export
interface
BlobResponse
{
blob
:
Blob
;
headers
:
Record
<
string
,
string
>
|
AxiosResponseHeaders
;
}
export
class
ApiClient
{
/** 共享的 axios 实例(请求加签 / 响应验签在 ./http 拦截器中完成) */
...
...
@@ -24,6 +30,23 @@ export class ApiClient {
return
this
.
call
<
T
>
(
'DELETE'
,
url
,
{
params
});
}
/** 下载二进制文件(不解包 data,直接返回原始 blob + response headers(含 content-disposition)) */
protected
async
getBlob
(
url
:
string
,
params
?:
Record
<
string
,
unknown
>
,
):
Promise
<
BlobResponse
>
{
const
resp
=
(
await
this
.
http
.
request
({
method
:
'GET'
,
url
,
params
,
responseType
:
'blob'
,
}))
as
unknown
as
{
data
:
Blob
;
headers
:
Record
<
string
,
string
>
};
return
{
blob
:
resp
.
data
,
headers
:
resp
.
headers
??
{},
};
}
/** 统一请求入口:调用共享 http,并把响应 body 解包为 data */
private
call
<
T
>
(
method
:
string
,
url
:
string
,
extra
:
Record
<
string
,
unknown
>
=
{}):
Promise
<
T
>
{
const
config
=
{
method
,
url
,
...
extra
}
as
any
;
...
...
src/api/modules/store.ts
View file @
cbad90b
...
...
@@ -57,6 +57,26 @@ class Store extends ApiClient {
);
}
/** 下载门店上架导入模板(V1.0.1,21 列,输出 .xlsx 文件) */
async
downloadImportTemplate
(
defaultFilename
=
'【优加】门店上架模版-V1.0.1.xlsx'
):
Promise
<
void
>
{
const
{
blob
,
headers
}
=
await
this
.
getBlob
(
STORE_IMPORT_TEMPLATE_URL
);
const
disposition
=
(
headers
[
'content-disposition'
]
??
''
)
as
string
;
let
filename
=
defaultFilename
;
if
(
disposition
)
{
const
matched
=
disposition
.
match
(
/filename
\*
=UTF-8''
([^
;
]
+
)
/i
);
const
simple
=
disposition
.
match
(
/filename="
?([^
";
]
+
)
"
?
/i
);
filename
=
decodeURIComponent
(
matched
?.[
1
]
??
simple
?.[
1
]
??
defaultFilename
);
}
const
url
=
URL
.
createObjectURL
(
blob
);
const
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
filename
;
document
.
body
.
appendChild
(
a
);
a
.
click
();
document
.
body
.
removeChild
(
a
);
URL
.
revokeObjectURL
(
url
);
}
/** 上传模板文件做五级校验(FormData,请求体不参与签名,§3.1/§9.6) */
uploadImport
(
file
:
File
,
templateVersion
=
'V1.0.1'
)
{
const
form
=
new
FormData
();
...
...
src/pages/TemplateImport/components/ApprovalChainPreview.tsx
0 → 100644
View file @
cbad90b
import { InfoCircleFilled, CheckCircleFilled } from '@ant-design/icons';
import { UCard, UTag } from '@uj/ui';
export type ChainNodeStatus = 'done' | 'active' | 'pending';
export interface ChainNode {
status: ChainNodeStatus;
title: string;
subtitle: string;
time?: string;
}
const defaultNodes: ChainNode[] = [
{
status: 'done',
title: '提交',
subtitle: '陈盛',
time: '2026-09-20 15:12',
},
{
status: 'active',
title: '优加财务经理',
subtitle: '唯一审批节点',
},
{
status: 'pending',
title: '生效',
subtitle: '写入门店列表',
},
];
interface NodeIconProps {
status: ChainNodeStatus;
index: number;
}
function NodeIcon({ status, index }: NodeIconProps) {
if (status === 'done') {
return (
<div
style={{
width: 32,
height: 32,
borderRadius: '50%',
background: '#16A34A',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
color: '#fff',
flex: 'none',
}}
>
<CheckCircleFilled style={{ fontSize: 18 }} />
</div>
);
}
if (status === 'active') {
return (
<div
style={{
width: 32,
height: 32,
borderRadius: '50%',
background: '#4F46E5',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
color: '#fff',
fontWeight: 600,
fontSize: 13,
flex: 'none',
boxShadow: '0 0 0 4px #EEF2FF',
}}
>
{index + 1}
</div>
);
}
return (
<div
style={{
width: 32,
height: 32,
borderRadius: '50%',
background: '#fff',
border: '2px solid #D1D5DB',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
color: '#9CA3AF',
flex: 'none',
}}
>
<CheckCircleFilled style={{ fontSize: 16 }} />
</div>
);
}
function NodeLine({ status }: { status: ChainNodeStatus }) {
const bg = status === 'done' ? '#16A34A' : '#E5E7EB';
return (
<div
style={{
flex: 1,
height: 2,
background: bg,
alignSelf: 'center',
marginTop: -16,
}}
/>
);
}
export interface ApprovalChainPreviewProps {
nodes?: ChainNode[];
chainType?: string;
}
export function ApprovalChainPreview({
nodes = defaultNodes,
chainType = '单级审批',
}: ApprovalChainPreviewProps) {
return (
<UCard
styles={{ body: { padding: '20px 24px 24px' } }}
style={{ marginBottom: 20, border: '1px solid #E5E7EB', borderRadius: 10 }}
title={
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600 }}>审批链预览</span>
</div>
}
extra={
<UTag color="default" bordered style={{ fontSize: 12 }}>
{chainType}
</UTag>
}
>
<div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{nodes.map((n, i) => (
<div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}>
<NodeIcon status={n.status} index={i} />
<div
style={{
marginTop: 14,
fontSize: 14,
fontWeight: 600,
color:
n.status === 'active'
? '#4F46E5'
: n.status === 'done'
? '#16A34A'
: '#6B7280',
textAlign: 'center',
}}
>
{n.title}
</div>
<div
style={{
marginTop: 4,
fontSize: 12,
color: '#9CA3AF',
textAlign: 'center',
}}
>
{n.subtitle}
</div>
{n.time && (
<div
style={{
marginTop: 4,
fontSize: 11,
color: '#C7CDD6',
textAlign: 'center',
}}
>
{n.time}
</div>
)}
</div>
{i < nodes.length - 1 && (
<NodeLine status={nodes[i].status} />
)}
</div>
))}
</div>
</UCard>
);
}
src/pages/TemplateImport/components/ConfirmActionBar.tsx
0 → 100644
View file @
cbad90b
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
export interface ConfirmActionBarProps {
passCount?: number;
onBack?: () => void;
onSubmit?: () => void;
}
export function ConfirmActionBar({
passCount = 12,
onBack,
onSubmit,
}: ConfirmActionBarProps) {
return (
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
paddingTop: 4,
}}
>
<UButton
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步
</UButton>
<div style={{ display: 'flex', gap: 12 }}>
<UButton
type="primary"
icon={<ArrowRightOutlined />}
onClick={onSubmit ?? (() => console.log('下一步:提交审批'))}
>
下一步:提交审批({passCount})
</UButton>
</div>
</div>
);
}
src/pages/TemplateImport/components/ImportInfoCard.tsx
0 → 100644
View file @
cbad90b
import { InfoCircleFilled } from '@ant-design/icons';
import {
UCard,
UForm,
UFormItem,
USelect,
UInput,
} from '@uj/ui';
import type { USelectProps } from '@uj/ui';
export interface ImportInfoValues {
org: string;
scene: string;
categories: string[];
remark?: string;
}
const orgOptions: USelectProps['options'] = [
{ label: '优加主体 / 线上运营部', value: 'uj-online' },
{ label: '优加主体 / 线下事业部', value: 'uj-offline' },
];
const sceneOptions: USelectProps['options'] = [
{ label: '售后会员权益升级 / 售前延保', value: 'warranty' },
{ label: '汽车用品销售', value: 'accessories' },
{ label: '保养服务', value: 'maintenance' },
];
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' },
];
const formItemLayout = {
style: { marginBottom: 18 },
};
export function ImportInfoCard() {
const [form] = UForm.useForm<ImportInfoValues>();
return (
<UCard
styles={{ body: { padding: 20 } }}
style={{ marginBottom: 20, border: '1px solid #E5E7EB' }}
title={
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600 }}>导入信息</span>
</div>
}
>
<UForm
form={form}
layout="vertical"
initialValues={{
org: 'uj-online',
scene: 'warranty',
categories: ['film-original', 'ppf-original', 'bp-table'],
}}
>
<div
style={{
display: 'grid',
gridTemplateColumns: '1fr 1fr 1fr',
gap: 20,
}}
>
<UFormItem
label={
<span>
所属组织<span style={{ color: '#E5484D', marginLeft: 2 }}>*</span>
</span>
}
name="org"
{...formItemLayout}
>
<USelect
options={orgOptions}
placeholder="请选择所属组织"
/>
</UFormItem>
<UFormItem
label={
<span>
业务场景<span style={{ color: '#E5484D', marginLeft: 2 }}>*</span>
</span>
}
name="scene"
{...formItemLayout}
>
<USelect
options={sceneOptions}
placeholder="请选择业务场景"
/>
</UFormItem>
<UFormItem
label={
<span>
产品分类<span style={{ color: '#E5484D', marginLeft: 2 }}>*</span>
</span>
}
name="categories"
{...formItemLayout}
>
<USelect
mode="multiple"
options={categoryOptions}
placeholder="请选择产品分类"
maxTagCount="responsive"
/>
</UFormItem>
</div>
<div
style={{
display: 'grid',
gridTemplateColumns: '1fr 1fr 1fr',
gap: 20,
marginTop: 4,
}}
>
<div style={{ fontSize: 12, color: '#8A94A6', lineHeight: 1.6 }}>
决定本次导入数据的数据可见范围
</div>
<div style={{ fontSize: 12, color: '#8A94A6', lineHeight: 1.6 }}>
同一门店有多个业务场景时需拆分为独立行导入
</div>
<div style={{ fontSize: 12, color: '#8A94A6', lineHeight: 1.6 }}>
决定模板中「产品分类」列的枚举范围
</div>
</div>
<UFormItem
label={<span style={{ marginTop: 18, display: 'inline-block' }}>备注</span>}
name="remark"
style={{ marginBottom: 0 }}
>
<UInput.TextArea
rows={2}
maxLength={200}
showCount
placeholder="选填,≤ 200 字,将在审批详情中展示给审批人"
/>
</UFormItem>
</UForm>
</UCard>
);
}
src/pages/TemplateImport/components/ImportUploader.tsx
deleted
100644 → 0
View file @
21e6226
import { useState } from 'react';
import { App } from 'antd';
import { InboxOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
import { store } from '@/api';
import { UAlert, UUpload, UParagraph } from '@uj/ui';
export function ImportUploader() {
const { message } = App.useApp();
const [uploading, setUploading] = useState(false);
const props: UploadProps = {
name: 'file',
multiple: false,
accept: '.xlsx,.xls',
showUploadList: true,
beforeUpload: async (file) => {
setUploading(true);
try {
await store.uploadImport(file as File);
message.success('模板已提交,后端解析中');
} catch (e) {
message.error((e as Error).message);
} finally {
setUploading(false);
}
// 返回 false 阻止 antd 自动上传,由我们手动走后端
return false;
},
};
return (
<>
<UAlert
type="info"
showIcon
style={{ marginBottom: 16 }}
message="Excel 由后端解析"
description="上传《【优加】门店上架模版-V1.0.1.xlsx》,前端仅做文件提交;模板版本一致性校验在后端完成。"
/>
<UParagraph type="secondary">
前端不引入 Excel 解析库,文件经 /api/store-import 提交,由后端完成解析与校验。
</UParagraph>
<UUpload.Dragger {...props} disabled={uploading}>
<p className="ant-upload-drag-icon">
<InboxOutlined />
</p>
<p className="ant-upload-text">点击或拖拽门店上架模版到此处</p>
<p className="ant-upload-hint">支持 .xlsx / .xls,单文件</p>
</UUpload.Dragger>
</>
);
}
src/pages/TemplateImport/components/NoticeSection.tsx
0 → 100644
View file @
cbad90b
import { BulbFilled } from '@ant-design/icons';
import { UCard } from '@uj/ui';
const rules = [
'主服务商切换:主服务商由「深圳嘀加」变更为「深圳优加」;凡在优加系统中完成上架的门店,嘀加系统中对应门店的主服务商必须同步更新为「深圳优加」。',
'北森同步:需考虑北森同步处理,优加进入同步配置,组织与人员账号同步范围扩展至优加主体。',
'商品上架利润率测算:非优加门店的测算逻辑保持不变;优加门店不需要重复计算一次,避免毛利被重复扣减出现「负毛利」。',
'上架规则回补:把优加上架规则内容回补到嘀加上架模板中,方便对账数据计算——以优加上架表中对应的内容为准,回填到嘀加系统。',
'上架时序建议:建议嘀加系统先上架、优加系统后上架,且两者上架的时间间隔在同一天内完成。',
];
export function NoticeSection() {
return (
<UCard
styles={{
body: { padding: '16px 20px' },
}}
style={{
marginBottom: 20,
border: '1px solid #C7D2FE',
background: 'linear-gradient(90deg, #EEF2FF 0%, #F5F3FF 100%)',
}}
>
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 10,
marginBottom: 14,
}}
>
<span
style={{
display: 'inline-flex',
alignItems: 'center',
gap: 6,
padding: '2px 10px',
borderRadius: 10,
background: '#4F46E5',
color: '#fff',
fontSize: 12,
fontWeight: 500,
}}
>
<BulbFilled style={{ fontSize: 12 }} />
上架联动规则
</span>
<span style={{ fontSize: 14, fontWeight: 600, color: '#3730A3' }}>
主服务商切换与外部系统联动要点
</span>
</div>
<ol style={{ margin: 0, paddingLeft: 0, listStyle: 'none' }}>
{rules.map((r, i) => (
<li
key={i}
style={{
display: 'flex',
gap: 10,
fontSize: 13,
color: '#4B5563',
lineHeight: 1.7,
marginBottom: i === rules.length - 1 ? 0 : 6,
}}
>
<span
style={{
flex: 'none',
width: 18,
height: 18,
borderRadius: '50%',
background: '#E0E7FF',
color: '#4338CA',
fontSize: 11,
fontWeight: 600,
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
{i + 1}
</span>
<span style={{ flex: 1 }}>{r}</span>
</li>
))}
</ol>
</UCard>
);
}
src/pages/TemplateImport/components/PageHeader.tsx
0 → 100644
View file @
cbad90b
import { useState } from 'react';
import { App } from 'antd';
import { DownloadOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
import { store } from '@/api';
const DEFAULT_TEMPLATE = '【优加】门店上架模版-V1.0.1.xlsx';
export function PageHeader() {
const { message } = App.useApp();
const [downloading, setDownloading] = useState(false);
const handleDownload = async () => {
if (downloading) return;
setDownloading(true);
try {
await store.downloadImportTemplate(DEFAULT_TEMPLATE);
message.success('模板下载成功');
} catch (e) {
message.error((e as Error).message ?? '模板下载失败');
} finally {
setDownloading(false);
}
};
const actions = [
{
key: 'download',
label: '下载模板',
icon: <DownloadOutlined />,
loading: downloading,
onClick: handleDownload,
},
{
key: 'spec',
label: '查看导入规范',
icon: null as React.ReactNode,
loading: false,
onClick: () => {
console.log('查看导入规范');
},
},
];
return (
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-start',
marginBottom: 20,
}}
>
<div>
<h1
style={{
fontSize: 20,
fontWeight: 600,
margin: 0,
color: '#1A202C',
}}
>
导入门店信息
</h1>
<p
style={{
fontSize: 13,
color: '#6B7280',
margin: '8px 0 0',
lineHeight: 1.6,
}}
>
按《{DEFAULT_TEMPLATE}》导入单个门店的商务政策(一行 = 一个产品分类),
校验通过并提交审批,审批通过后门店方可对外展示。
</p>
</div>
<div style={{ display: 'flex', gap: 12 }}>
{actions.map((a) => (
<UButton
key={a.key}
icon={a.icon ?? undefined}
loading={a.loading}
onClick={a.onClick}
>
{a.label}
</UButton>
))}
</div>
</div>
);
}
src/pages/TemplateImport/components/PolicyConfirmHeader.tsx
0 → 100644
View file @
cbad90b
import { InfoCircleFilled } from '@ant-design/icons';
import { UText } from '@uj/ui';
export interface PolicyConfirmHeaderProps {
storeName?: string;
totalRows?: number;
}
export function PolicyConfirmHeader({
storeName = '巴州强冠东风汽车销售服务有限公司',
totalRows = 12,
}: PolicyConfirmHeaderProps) {
return (
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
marginBottom: 12,
padding: '0 2px',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600, color: '#1A202C' }}>
商务政策确认 · {storeName} / 共 {totalRows} 行
</span>
</div>
<UText type="secondary" style={{ fontSize: 12 }}>
唯一项 = 门店 + 业务场景 + 产品分类 · 列按三组横向分块
</UText>
</div>
);
}
src/pages/TemplateImport/components/PolicyConfirmTable/columns.tsx
0 → 100644
View file @
cbad90b
import { UTag } from '@uj/ui';
import type { UTableProps } from '@uj/ui';
import type { PolicyConfirmRow } from '../tools/policyTableData';
const storeInfoHeaderStyle: React.CSSProperties = {
background: '#EEF2FF',
color: '#3730A3',
fontWeight: 600,
fontSize: 13,
};
const bizPolicyHeaderStyle: React.CSSProperties = {
background: '#ECFDF5',
color: '#047857',
fontWeight: 600,
fontSize: 13,
};
const cellStyle: React.CSSProperties = {
fontSize: 12.5,
color: '#374151',
padding: '10px 12px',
};
function SceneTag({ text }: { text: string }) {
return (
<UTag color="processing" bordered={false} style={{ fontSize: 12 }}>
{text}
</UTag>
);
}
function CategoryTag({ text }: { text: string }) {
return (
<UTag color="success" bordered={false} style={{ fontSize: 12 }}>
{text}
</UTag>
);
}
export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] {
return [
{
title: '门店信息',
align: 'center',
children: [
{
title: '门店名称',
dataIndex: 'storeName',
key: 'storeName',
width: 200,
onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => (
<span style={{ color: '#1A202C', fontWeight: 500 }}>{v}</span>
),
},
{
title: '门店商户号',
dataIndex: 'storeMerchantNo',
key: 'storeMerchantNo',
width: 130,
align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => (
<a style={{ color: '#2563EB', fontSize: 12.5 }}>{v}</a>
),
},
{
title: '业务场景',
dataIndex: 'businessScene',
key: 'businessScene',
width: 130,
align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v: string) => <SceneTag text={v} />,
},
{
title: '产品分类',
dataIndex: 'productCategory',
key: 'productCategory',
width: 120,
align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v: string) => <CategoryTag text={v} />,
},
],
},
{
title: '商务政策',
align: 'center',
children: [
{
title: '管理层市场费1计算模式',
dataIndex: 'mgmtFee1Mode',
key: 'mgmtFee1Mode',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '管理层市场费1计算方式',
dataIndex: 'mgmtFee1CalcMethod',
key: 'mgmtFee1CalcMethod',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '管理层市场费1',
dataIndex: 'mgmtFee1Value',
key: 'mgmtFee1Value',
width: 110,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => (
<span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>
),
},
{
title: '管理层市场费2计算模式',
dataIndex: 'mgmtFee2Mode',
key: 'mgmtFee2Mode',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '管理层市场费2计算方式',
dataIndex: 'mgmtFee2CalcMethod',
key: 'mgmtFee2CalcMethod',
width: 140,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '管理层市场费2',
dataIndex: 'mgmtFee2Value',
key: 'mgmtFee2Value',
width: 110,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
render: (v) => (
<span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>
),
},
{
title: '一线阳光是否开启线上积分',
dataIndex: 'sunshineOnlinePoints',
key: 'sunshineOnlinePoints',
width: 150,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
{
title: '一线阳光计算模式',
dataIndex: 'sunshineCalcMode',
key: 'sunshineCalcMode',
width: 130,
align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }),
},
],
},
];
}
src/pages/TemplateImport/components/PolicyConfirmTable/index.tsx
0 → 100644
View file @
cbad90b
import { UCard, FillTable, UText } from '@uj/ui';
import { buildPolicyColumns } from './columns';
import type { PolicyConfirmRow } from '../../tools/policyTableData';
const footerText =
'表格唯一项 = 门店 + 业务场景 + 产品分类。同一门店的多个业务场景各占独立行(本批次 2 个业务场景 × 6 个产品分类 = 12 行),门店名称重复出现、不合并;「业务场景」若一家门店有多个,须拆分为独立行导入。「产品分类」多级分类可用「-」区分。「装修、设备总投入」「当月产生费用」按产品分类维度合并填写,「人工成本」按人力成本维度合并填写 —— 同一门店的多行需保持一致,系统将校验一致性。';
export interface PolicyConfirmTableProps {
dataSource?: PolicyConfirmRow[];
}
export function PolicyConfirmTable({ dataSource }: PolicyConfirmTableProps) {
const columns = buildPolicyColumns();
return (
<UCard
styles={{ body: { padding: '16px 16px 12px' } }}
style={{ border: '1px solid #E5E7EB', marginBottom: 20, borderRadius: 10 }}
>
<FillTable<PolicyConfirmRow>
rowKey={(r) => `${r.storeMerchantNo}-${r.businessScene}-${r.productCategory}`}
columns={columns}
dataSource={dataSource}
size="middle"
scroll={{ x: 1600 }}
pagination={false}
bordered
/>
<div
style={{
marginTop: 12,
padding: '10px 12px',
background: '#F9FAFB',
borderRadius: 6,
}}
>
<UText type="secondary" style={{ fontSize: 12, lineHeight: 1.7 }}>
{footerText}
</UText>
</div>
</UCard>
);
}
src/pages/TemplateImport/components/StepsBar.tsx
0 → 100644
View file @
cbad90b
import { Steps } from 'antd';
export interface StepsBarProps {
current?: number;
}
const stepItems = [
{
title: '上传文件',
description: '选择模板并上传',
},
{
title: '数据校验',
description: '五级校验与失败明细',
},
{
title: '数据确认',
description: '转译与成本核算',
},
{
title: '提交审批',
description: '进入审批链',
},
];
export function StepsBar({ current = 0 }: StepsBarProps) {
return (
<div
style={{
background: '#fff',
borderRadius: 10,
padding: '20px 32px 12px',
marginBottom: 20,
border: '1px solid #E5E7EB',
}}
>
<Steps
current={current}
items={stepItems}
size="default"
status="process"
/>
</div>
);
}
src/pages/TemplateImport/components/SubmitActionBar.tsx
0 → 100644
View file @
cbad90b
import { ArrowLeftOutlined, SendOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
export interface SubmitActionBarProps {
totalRows?: number;
onBack?: () => void;
onSubmit?: () => void;
}
export function SubmitActionBar({
totalRows = 12,
onBack,
onSubmit,
}: SubmitActionBarProps) {
return (
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
paddingTop: 4,
}}
>
<UButton
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步
</UButton>
<UButton
type="primary"
icon={<SendOutlined />}
onClick={onSubmit ?? (() => console.log('确认提交并推送审批'))}
>
确认提交并推送审批({totalRows})
</UButton>
</div>
);
}
src/pages/TemplateImport/components/SubmitConfirmCard.tsx
0 → 100644
View file @
cbad90b
import { useState } from 'react';
import { InfoCircleFilled } from '@ant-design/icons';
import { UCard, UCheckbox, UTag } from '@uj/ui';
export interface SubmitConfirmInfo {
storeName: string;
storeMerchantNo: string;
categoryCount: number;
sceneCount: number;
totalRows: number;
operatingCost: string;
operatingCostDetail: string;
approvalChain: string;
approvalChainTag: string;
approvalChainDesc: string;
expectedApprover: string;
}
const 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 = {
width: 120,
flex: 'none',
fontSize: 13,
color: '#8A94A6',
};
const valueStyle: React.CSSProperties = {
fontSize: 13,
color: '#1A202C',
fontWeight: 500,
};
const descStyle: React.CSSProperties = {
fontSize: 12,
color: '#9CA3AF',
marginLeft: 6,
};
export interface SubmitConfirmCardProps {
info?: SubmitConfirmInfo;
}
export function SubmitConfirmCard({ info = defaultInfo }: SubmitConfirmCardProps) {
const [checked, setChecked] = useState(true);
const infoRows: Array<{
label: string;
value: React.ReactNode;
desc?: string;
extra?: React.ReactNode;
}> = [
{
label: '门店名称',
value: info.storeName,
},
{
label: '门店商户号',
value: info.storeMerchantNo,
},
{
label: '产品分类',
value: `${info.categoryCount} 个`,
desc: `(${info.sceneCount} 个业务场景,共 ${info.totalRows} 行)`,
},
{
label: '运营成本合计',
value: <span style={{ color: '#4F46E5', fontWeight: 600 }}>{info.operatingCost}</span>,
desc: info.operatingCostDetail,
},
{
label: '触发审批链',
value: info.approvalChain,
extra: (
<UTag color="processing" bordered={false} style={{ marginLeft: 6 }}>
{info.approvalChainTag}
</UTag>
),
desc: info.approvalChainDesc,
},
{
label: '预计审批人',
value: info.expectedApprover,
},
];
return (
<UCard
styles={{ body: { padding: '20px 24px' } }}
style={{ marginBottom: 20, border: '1px solid #E5E7EB', borderRadius: 10 }}
title={
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600 }}>提交确认</span>
</div>
}
>
<div
style={{
padding: '14px 16px',
background: '#F9FAFB',
borderRadius: 8,
marginBottom: 18,
}}
>
<UCheckbox
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
style={{ fontSize: 13, fontWeight: 500 }}
>
<span style={{ color: '#374151' }}>
我已确认该门店 {info.sceneCount} 个业务场景共 {info.totalRows} 行数据准确无误
</span>
</UCheckbox>
<div style={{ fontSize: 12, color: '#9CA3AF', marginTop: 6, paddingLeft: 24 }}>
提交后如需调整,请在该门店「待审批」状态下撤回。
</div>
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
{infoRows.map((r) => (
<div key={r.label} style={{ display: 'flex', alignItems: 'flex-start' }}>
<span style={labelStyle}>{r.label}</span>
<div style={{ flex: 1, display: 'flex', alignItems: 'center', flexWrap: 'wrap' }}>
<span style={valueStyle}>{r.value}</span>
{r.extra}
{r.desc && <span style={descStyle}>{r.desc}</span>}
</div>
</div>
))}
</div>
</UCard>
);
}
src/pages/TemplateImport/components/UploadActionBar.tsx
0 → 100644
View file @
cbad90b
import { ArrowRightOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
export interface UploadActionBarProps {
disabled?: boolean;
onNext?: () => void;
}
export function UploadActionBar({
disabled = false,
onNext,
}: UploadActionBarProps) {
return (
<div
style={{
display: 'flex',
justifyContent: 'flex-end',
paddingTop: 0,
}}
>
<UButton
type="primary"
icon={<ArrowRightOutlined />}
disabled={disabled}
onClick={onNext ?? (() => console.log('下一步:数据校验'))}
>
下一步:数据校验
</UButton>
</div>
);
}
src/pages/TemplateImport/components/UploadCard.tsx
0 → 100644
View file @
cbad90b
import { useState, useCallback } from 'react';
import { App, Upload } from 'antd';
import {
InfoCircleFilled,
UploadOutlined,
CheckCircleFilled,
CloseOutlined,
FileExcelOutlined,
} from '@ant-design/icons';
import type { UploadProps, UploadFile } from 'antd';
import { UCard, UUpload, UText, UButton } from '@uj/ui';
import { store } from '@/api';
import {
mockParseAndValidate,
UPLOAD_RULES,
type ParsedFileMeta,
} from '../tools/uploadValidate';
const TEMPLATE_NAME = '【优加】门店上架模版-V1.0.1.xlsx';
export interface UploadCardProps {
onUploadSuccess?: (meta: ParsedFileMeta) => void;
}
export function UploadCard({ onUploadSuccess }: UploadCardProps) {
const { message } = App.useApp();
const [uploading, setUploading] = useState(false);
const [downloading, setDownloading] = useState(false);
const [fileMeta, setFileMeta] = useState<ParsedFileMeta | null>(null);
const [fileList, setFileList] = useState<UploadFile[]>([]);
const clearFileState = useCallback(() => {
setFileMeta(null);
setFileList([]);
}, []);
const handleRemove = useCallback(() => {
clearFileState();
message.info('已移除文件');
return true;
}, [clearFileState, message]);
const handleDownloadTemplate = async (e?: React.MouseEvent) => {
e?.stopPropagation?.();
if (downloading) return;
setDownloading(true);
try {
await store.downloadImportTemplate(TEMPLATE_NAME);
message.success('模板下载成功');
} catch (e) {
message.error((e as Error).message ?? '模板下载失败');
} finally {
setDownloading(false);
}
};
const buildUploadFile = (file: File): UploadFile => ({
uid: Date.now().toString(),
name: file.name,
size: file.size,
type: file.type,
originFileObj: file,
status: 'done',
});
const handleFile: UploadProps['beforeUpload'] = async (rawFile) => {
setUploading(true);
try {
const result = await mockParseAndValidate(rawFile as File);
if (!result.ok || !result.meta) {
message.error(result.message ?? '文件校验失败');
clearFileState();
setUploading(false);
return Upload.LIST_IGNORE;
}
try {
await store.uploadImport(rawFile as File);
} catch (e) {
message.error((e as Error).message);
clearFileState();
setUploading(false);
return Upload.LIST_IGNORE;
}
setFileMeta(result.meta);
setFileList([buildUploadFile(rawFile as File)]);
message.success('模板已上传,校验通过');
onUploadSuccess?.(result.meta);
} catch (e) {
message.error((e as Error).message ?? '文件处理失败');
clearFileState();
} finally {
setUploading(false);
}
return Upload.LIST_IGNORE;
};
const uploadProps: UploadProps = {
name: 'file',
multiple: false,
accept: UPLOAD_RULES.ALLOW_EXTS.join(','),
showUploadList: false,
beforeUpload: handleFile,
onRemove: handleRemove,
fileList,
};
return (
<UCard
styles={{ body: { padding: 20 } }}
style={{ border: '1px solid #E5E7EB', marginBottom: 20 }}
title={
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleFilled style={{ color: '#4F46E5', fontSize: 14 }} />
<span style={{ fontSize: 15, fontWeight: 600 }}>上传门店上架表</span>
</div>
}
extra={
<UText type="secondary" style={{ fontSize: 12 }}>
支持 {UPLOAD_RULES.ALLOW_EXTS.join(' / ')} · 单文件 ≤ 10MB · 单次导入 1 家门店(≤ {UPLOAD_RULES.MAX_ROWS} 行)
</UText>
}
>
<UUpload.Dragger {...uploadProps} disabled={uploading}>
<div style={{ padding: '30px 0' }}>
<div
style={{
width: 48,
height: 48,
borderRadius: 12,
background: '#EEF2FF',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
marginBottom: 16,
}}
>
<UploadOutlined style={{ fontSize: 22, color: '#4F46E5' }} />
</div>
<p
className="ant-upload-text"
style={{
fontSize: 15,
fontWeight: 500,
color: '#374151',
marginBottom: 8,
}}
>
点击选择文件,或拖拽到此处
</p>
<p
className="ant-upload-hint"
style={{
fontSize: 12,
color: '#9CA3AF',
marginBottom: 6,
}}
>
请使用《{TEMPLATE_NAME}》填写
<UButton
type="link"
size="small"
loading={downloading}
style={{ padding: '0 4px', height: 'auto' }}
onClick={handleDownloadTemplate}
>
下载最新模板
</UButton>
</p>
<div
style={{
fontSize: 12,
color: '#C7CDD6',
}}
>
模板版本:v1.0.1 · 系统将校验模板版本一致性
</div>
</div>
</UUpload.Dragger>
{fileMeta && (
<div
style={{
marginTop: 16,
display: 'flex',
alignItems: 'center',
padding: '14px 16px',
background: '#F9FAFB',
borderRadius: 8,
border: '1px solid #E5E7EB',
}}
>
<div
style={{
width: 36,
height: 36,
borderRadius: 8,
background: '#E7F5EE',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
marginRight: 12,
flex: 'none',
}}
>
<FileExcelOutlined style={{ color: '#16A34A', fontSize: 18 }} />
</div>
<div style={{ flex: 1, minWidth: 0 }}>
<div
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
marginBottom: 4,
}}
>
<span
style={{
fontSize: 14,
fontWeight: 600,
color: '#1A202C',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{fileMeta.fileName}
</span>
<CheckCircleFilled
style={{ color: '#16A34A', fontSize: 16, flex: 'none' }}
/>
</div>
<div
style={{
fontSize: 12,
color: '#6B7280',
}}
>
{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>
<UButton
type="text"
size="small"
icon={<CloseOutlined />}
onClick={() => handleRemove()}
style={{
color: '#9CA3AF',
padding: '4px 8px',
flex: 'none',
marginLeft: 8,
}}
>
移除
</UButton>
</div>
)}
</UCard>
);
}
src/pages/TemplateImport/components/ValidationActionBar.tsx
0 → 100644
View file @
cbad90b
import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
import { UButton } from '@uj/ui';
export interface ValidationActionBarProps {
passCount?: number;
onBack?: () => void;
onSubmitPassOnly?: () => void;
onNextStep?: () => void;
}
export function ValidationActionBar({
passCount = 12,
onBack,
onSubmitPassOnly,
onNextStep,
}: ValidationActionBarProps) {
return (
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
paddingTop: 8,
}}
>
<UButton
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步
</UButton>
<div style={{ display: 'flex', gap: 12 }}>
<UButton
onClick={onSubmitPassOnly ?? (() => console.log('仅提交通过行'))}
>
仅提交通过行({passCount})
</UButton>
<UButton
type="primary"
icon={<ArrowRightOutlined />}
onClick={onNextStep ?? (() => console.log('下一步:数据确认'))}
>
下一步:数据确认
</UButton>
</div>
</div>
);
}
src/pages/TemplateImport/components/ValidationStats.tsx
0 → 100644
View file @
cbad90b
import { UCard } from '@uj/ui';
export interface StatItem {
label: string;
value: string | number;
desc: string;
tone: 'primary' | 'success' | 'warning' | 'default';
}
interface StatCardProps {
item: StatItem;
}
const toneMap: Record<StatItem['tone'], { border: string; accent: string }> = {
primary: {
border: '1px solid #C7D2FE',
accent: '#4F46E5',
},
success: {
border: '1px solid #86EFAC',
accent: '#16A34A',
},
warning: {
border: '1px solid #FCD34D',
accent: '#CA8A04',
},
default: {
border: '1px solid #E5E7EB',
accent: '#6B7280',
},
};
function StatCard({ item }: StatCardProps) {
const tone = toneMap[item.tone];
return (
<UCard
styles={{ body: { padding: '18px 20px' } }}
style={{
borderLeft: `3px solid ${tone.accent}`,
border: tone.border,
borderRadius: 10,
background: '#fff',
}}
>
<div
style={{
fontSize: 13,
color: '#6B7280',
marginBottom: 10,
fontWeight: 500,
}}
>
{item.label}
</div>
<div
style={{
fontSize: 26,
fontWeight: 700,
color: '#1A202C',
marginBottom: 8,
lineHeight: 1.2,
}}
>
{item.value}
</div>
<div
style={{
fontSize: 12,
color: '#9CA3AF',
lineHeight: 1.5,
}}
>
{item.desc}
</div>
</UCard>
);
}
export interface ValidationStatsProps {
stats?: StatItem[];
}
const defaultStats: StatItem[] = [
{
label: '解析总行数',
value: '13',
desc: '1 家门店 · 2 个业务场景 · 12 行',
tone: 'primary',
},
{
label: '校验通过',
value: '12',
desc: '可提交审批',
tone: 'success',
},
];
export function ValidationStats({ stats = defaultStats }: ValidationStatsProps) {
return (
<div
style={{
display: 'grid',
gridTemplateColumns: 'repeat(4, 1fr)',
gap: 16,
marginBottom: 20,
}}
>
{stats.map((s) => (
<StatCard key={s.label} item={s} />
))}
</div>
);
}
src/pages/TemplateImport/index.tsx
View file @
cbad90b
import {
ImportUploader } from './components/ImportUploader
';
import {
useState } from 'react
';
import { Skeleton } from '@uj/ui';
import { PageHeader } from './components/PageHeader';
import { NoticeSection } from './components/NoticeSection';
import { StepsBar } from './components/StepsBar';
import { ImportInfoCard } from './components/ImportInfoCard';
import { UploadCard } from './components/UploadCard';
import { UploadActionBar } from './components/UploadActionBar';
import { ValidationStats } from './components/ValidationStats';
import { ValidationActionBar } from './components/ValidationActionBar';
import { PolicyConfirmHeader } from './components/PolicyConfirmHeader';
import { PolicyConfirmTable } from './components/PolicyConfirmTable';
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';
export default function TemplateImport() {
const loading = false;
const [currentStep, setCurrentStep] = useState<0 | 1 | 2 | 3>(0);
const [fileUploaded, setFileUploaded] = useState(false);
const passCount = 12;
const goPrev = () => {
setCurrentStep((s) => (s > 0 ? ((s - 1) as 0 | 1 | 2 | 3) : s));
};
const goNext = () => {
setCurrentStep((s) => (s < 3 ? ((s + 1) as 0 | 1 | 2 | 3) : s));
};
const handleSubmitPassOnly = () => {
console.log(`仅提交通过行(${passCount})`);
goNext();
};
const handleFinalSubmit = () => {
console.log(`确认提交并推送审批(${passCount})`);
};
if (loading) return <Skeleton variant="default" />;
return (
<div style={{ maxWidth: 640 }}>
<ImportUploader />
<div style={{ display: 'flex', flexDirection: 'column' }}>
<PageHeader />
<NoticeSection />
<StepsBar current={currentStep} />
{currentStep === 0 && (
<>
<ImportInfoCard />
<UploadCard onUploadSuccess={() => setFileUploaded(true)} />
<UploadActionBar disabled={!fileUploaded} onNext={goNext} />
</>
)}
{currentStep === 1 && (
<>
<ValidationStats />
<ValidationActionBar
passCount={passCount}
onBack={goPrev}
onSubmitPassOnly={handleSubmitPassOnly}
onNextStep={goNext}
/>
</>
)}
{currentStep === 2 && (
<>
<PolicyConfirmHeader storeName="巴州强冠东风汽车销售服务有限公司" totalRows={12} />
<PolicyConfirmTable dataSource={mockPolicyRows} />
<ConfirmActionBar
passCount={passCount}
onBack={goPrev}
onSubmit={goNext}
/>
</>
)}
{currentStep === 3 && (
<>
<SubmitConfirmCard />
<ApprovalChainPreview />
<SubmitActionBar
totalRows={passCount}
onBack={goPrev}
onSubmit={handleFinalSubmit}
/>
</>
)}
</div>
);
}
src/pages/TemplateImport/tools/policyTableData.ts
0 → 100644
View file @
cbad90b
export
interface
PolicyConfirmRow
{
storeName
:
string
;
storeMerchantNo
:
string
;
businessScene
:
string
;
productCategory
:
string
;
mgmtFee1Mode
:
string
;
mgmtFee1CalcMethod
:
string
;
mgmtFee1Value
:
string
;
mgmtFee2Mode
:
string
;
mgmtFee2CalcMethod
:
string
;
mgmtFee2Value
:
string
;
sunshineOnlinePoints
:
string
;
sunshineCalcMode
:
string
;
}
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
===
'车衣-原厂'
?
'按整单计算'
:
'按品类计算'
;
rows
.
push
({
storeName
:
'巴州强冠东风汽车销售服务有限公司'
,
storeMerchantNo
:
'SQ20240115'
,
businessScene
:
scene
,
productCategory
:
cat
,
mgmtFee1Mode
:
calcMode
,
mgmtFee1CalcMethod
:
'收入'
,
mgmtFee1Value
:
'5%'
,
mgmtFee2Mode
:
calcMode
,
mgmtFee2CalcMethod
:
'收入'
,
mgmtFee2Value
:
'5%'
,
sunshineOnlinePoints
:
'是'
,
sunshineCalcMode
:
calcMode
,
});
}
}
return
rows
;
}
export
const
mockPolicyRows
:
PolicyConfirmRow
[]
=
buildRows
();
src/pages/TemplateImport/tools/uploadValidate.ts
0 → 100644
View file @
cbad90b
export
interface
ParsedFileMeta
{
fileName
:
string
;
sizeKB
:
number
;
rows
:
number
;
sceneCount
:
number
;
categoryCount
:
number
;
storeName
:
string
;
storeMerchantNo
:
string
;
templateVersion
:
string
;
isSingleStoreConsistent
:
boolean
;
}
export
interface
ValidateResult
{
ok
:
boolean
;
code
?:
|
'EXT_ERROR'
|
'SIZE_ERROR'
|
'ROWS_ERROR'
|
'STORE_INCONSISTENT'
|
'PARSE_ERROR'
;
message
?:
string
;
meta
?:
ParsedFileMeta
;
}
const
ALLOW_EXTS
=
[
'.xlsx'
,
'.xls'
];
const
MAX_SIZE_BYTES
=
10
*
1024
*
1024
;
const
MAX_ROWS
=
2000
;
export
function
validateFileExtension
(
fileName
:
string
):
boolean
{
const
lower
=
fileName
.
toLowerCase
();
return
ALLOW_EXTS
.
some
((
ext
)
=>
lower
.
endsWith
(
ext
));
}
export
function
validateFileSize
(
bytes
:
number
):
boolean
{
return
bytes
<=
MAX_SIZE_BYTES
;
}
export
function
formatBytesToKB
(
bytes
:
number
):
number
{
return
Math
.
max
(
1
,
Math
.
round
(
bytes
/
1024
));
}
export
function
mockParseAndValidate
(
file
:
File
):
Promise
<
ValidateResult
>
{
return
new
Promise
((
resolve
)
=>
{
setTimeout
(()
=>
{
const
name
=
file
.
name
;
if
(
!
validateFileExtension
(
name
))
{
resolve
({
ok
:
false
,
code
:
'EXT_ERROR'
,
message
:
`仅支持
${
ALLOW_EXTS
.
join
(
' / '
)}
格式`
,
});
return
;
}
if
(
!
validateFileSize
(
file
.
size
))
{
resolve
({
ok
:
false
,
code
:
'SIZE_ERROR'
,
message
:
`文件大小超过限制,单文件 ≤ 10MB(当前
${(
file
.
size
/
1024
/
1024
).
toFixed
(
2
)}
MB)`
,
});
return
;
}
const
rows
=
12
;
const
sceneCount
=
2
;
const
categoryCount
=
6
;
if
(
rows
>
MAX_ROWS
)
{
resolve
({
ok
:
false
,
code
:
'ROWS_ERROR'
,
message
:
`数据行数超过限制,单文件 ≤
${
MAX_ROWS
}
行(当前
${
rows
}
行)`
,
});
return
;
}
const
storeName
=
'巴州强冠东风汽车销售服务有限公司'
;
const
storeMerchantNo
=
'SQ20240115'
;
const
templateVersion
=
'v1.0.1'
;
const
isSingleStoreConsistent
=
true
;
if
(
!
isSingleStoreConsistent
)
{
resolve
({
ok
:
false
,
code
:
'STORE_INCONSISTENT'
,
message
:
'检测到文件内门店名称或商户号不一致,单次导入仅支持 1 家门店'
,
});
return
;
}
resolve
({
ok
:
true
,
meta
:
{
fileName
:
name
,
sizeKB
:
formatBytesToKB
(
file
.
size
),
rows
,
sceneCount
,
categoryCount
,
storeName
,
storeMerchantNo
,
templateVersion
,
isSingleStoreConsistent
,
},
});
},
500
);
});
}
export
const
UPLOAD_RULES
=
{
ALLOW_EXTS
,
MAX_SIZE_BYTES
,
MAX_ROWS
,
};
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