Commit 1bee62ce by 张立顺

fix(build): 修复同步后导入页面类型与格式检查

修正模板确认表格类型和导入路径、保留上传RcFile类型,移除未使用导入,并统一格式以通过构建和CI检查。
1 parent b1385f4e
Pipeline #305 for 1bee62ce failed in 0 seconds
...@@ -31,10 +31,7 @@ export class ApiClient { ...@@ -31,10 +31,7 @@ export class ApiClient {
} }
/** 下载二进制文件(不解包 data,直接返回原始 blob + response headers(含 content-disposition)) */ /** 下载二进制文件(不解包 data,直接返回原始 blob + response headers(含 content-disposition)) */
protected async getBlob( protected async getBlob(url: string, params?: Record<string, unknown>): Promise<BlobResponse> {
url: string,
params?: Record<string, unknown>,
): Promise<BlobResponse> {
const resp = (await this.http.request({ const resp = (await this.http.request({
method: 'GET', method: 'GET',
url, url,
......
...@@ -42,7 +42,9 @@ class Store extends ApiClient { ...@@ -42,7 +42,9 @@ class Store extends ApiClient {
} }
/** 下载门店上架导入模板(V1.0.1,21 列,输出 .xlsx 文件) */ /** 下载门店上架导入模板(V1.0.1,21 列,输出 .xlsx 文件) */
async downloadImportTemplate(defaultFilename = '【优加】门店上架模版-V1.0.1.xlsx'): Promise<void> { async downloadImportTemplate(
defaultFilename = '【优加】门店上架模版-V1.0.1.xlsx',
): Promise<void> {
const { blob, headers } = await this.getBlob(STORE_IMPORT_TEMPLATE_URL); const { blob, headers } = await this.getBlob(STORE_IMPORT_TEMPLATE_URL);
const disposition = (headers['content-disposition'] ?? '') as string; const disposition = (headers['content-disposition'] ?? '') as string;
let filename = defaultFilename; let filename = defaultFilename;
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import type { ColumnsType } from 'antd/es/table'; import type { ColumnsType } from 'antd/es/table';
import { UAlert, UCard, UTag, UText, UTitle } from '@uj/ui'; import { UCard, UTag, UText, UTitle } from '@uj/ui';
import { import {
DataTable, DataTable,
SearchForm, SearchForm,
......
...@@ -139,7 +139,9 @@ export function ApprovalChainPreview({ ...@@ -139,7 +139,9 @@ export function ApprovalChainPreview({
<div style={{ display: 'flex', padding: '20px 8px 8px' }}> <div style={{ display: 'flex', padding: '20px 8px 8px' }}>
{nodes.map((n, i) => ( {nodes.map((n, i) => (
<div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}> <div key={i} style={{ flex: 1, display: 'flex', position: 'relative' }}>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}> <div
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flex: 1 }}
>
<NodeIcon status={n.status} index={i} /> <NodeIcon status={n.status} index={i} />
<div <div
style={{ style={{
...@@ -147,11 +149,7 @@ export function ApprovalChainPreview({ ...@@ -147,11 +149,7 @@ export function ApprovalChainPreview({
fontSize: 14, fontSize: 14,
fontWeight: 600, fontWeight: 600,
color: color:
n.status === 'active' n.status === 'active' ? '#4F46E5' : n.status === 'done' ? '#16A34A' : '#6B7280',
? '#4F46E5'
: n.status === 'done'
? '#16A34A'
: '#6B7280',
textAlign: 'center', textAlign: 'center',
}} }}
> >
...@@ -180,9 +178,7 @@ export function ApprovalChainPreview({ ...@@ -180,9 +178,7 @@ export function ApprovalChainPreview({
</div> </div>
)} )}
</div> </div>
{i < nodes.length - 1 && ( {i < nodes.length - 1 && <NodeLine status={nodes[i].status} />}
<NodeLine status={nodes[i].status} />
)}
</div> </div>
))} ))}
</div> </div>
......
...@@ -7,11 +7,7 @@ export interface ConfirmActionBarProps { ...@@ -7,11 +7,7 @@ export interface ConfirmActionBarProps {
onSubmit?: () => void; onSubmit?: () => void;
} }
export function ConfirmActionBar({ export function ConfirmActionBar({ passCount = 12, onBack, onSubmit }: ConfirmActionBarProps) {
passCount = 12,
onBack,
onSubmit,
}: ConfirmActionBarProps) {
return ( return (
<div <div
style={{ style={{
...@@ -21,10 +17,7 @@ export function ConfirmActionBar({ ...@@ -21,10 +17,7 @@ export function ConfirmActionBar({
paddingTop: 4, paddingTop: 4,
}} }}
> >
<UButton <UButton icon={<ArrowLeftOutlined />} onClick={onBack ?? (() => console.log('返回上一步'))}>
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步 返回上一步
</UButton> </UButton>
......
import { InfoCircleFilled } from '@ant-design/icons'; import { InfoCircleFilled } from '@ant-design/icons';
import { import { UCard, UForm, UFormItem, USelect, UInput } from '@uj/ui';
UCard,
UForm,
UFormItem,
USelect,
UInput,
} from '@uj/ui';
import type { USelectProps } from '@uj/ui'; import type { USelectProps } from '@uj/ui';
export interface ImportInfoValues { export interface ImportInfoValues {
...@@ -78,10 +72,7 @@ export function ImportInfoCard() { ...@@ -78,10 +72,7 @@ export function ImportInfoCard() {
name="org" name="org"
{...formItemLayout} {...formItemLayout}
> >
<USelect <USelect options={orgOptions} placeholder="请选择所属组织" />
options={orgOptions}
placeholder="请选择所属组织"
/>
</UFormItem> </UFormItem>
<UFormItem <UFormItem
...@@ -93,10 +84,7 @@ export function ImportInfoCard() { ...@@ -93,10 +84,7 @@ export function ImportInfoCard() {
name="scene" name="scene"
{...formItemLayout} {...formItemLayout}
> >
<USelect <USelect options={sceneOptions} placeholder="请选择业务场景" />
options={sceneOptions}
placeholder="请选择业务场景"
/>
</UFormItem> </UFormItem>
<UFormItem <UFormItem
......
...@@ -76,12 +76,7 @@ export function PageHeader() { ...@@ -76,12 +76,7 @@ export function PageHeader() {
</div> </div>
<div style={{ display: 'flex', gap: 12 }}> <div style={{ display: 'flex', gap: 12 }}>
{actions.map((a) => ( {actions.map((a) => (
<UButton <UButton key={a.key} icon={a.icon ?? undefined} loading={a.loading} onClick={a.onClick}>
key={a.key}
icon={a.icon ?? undefined}
loading={a.loading}
onClick={a.onClick}
>
{a.label} {a.label}
</UButton> </UButton>
))} ))}
......
import { UTag } from '@uj/ui'; import { UTag } from '@uj/ui';
import type { UTableProps } from '@uj/ui'; import type { TableProps } from 'antd';
import type { PolicyConfirmRow } from '../tools/policyTableData'; import type { PolicyConfirmRow } from '../../tools/policyTableData';
const storeInfoHeaderStyle: React.CSSProperties = { const storeInfoHeaderStyle: React.CSSProperties = {
background: '#EEF2FF', background: '#EEF2FF',
...@@ -38,7 +38,7 @@ function CategoryTag({ text }: { text: string }) { ...@@ -38,7 +38,7 @@ function CategoryTag({ text }: { text: string }) {
); );
} }
export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] { export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
return [ return [
{ {
title: '门店信息', title: '门店信息',
...@@ -51,9 +51,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] { ...@@ -51,9 +51,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] {
width: 200, width: 200,
onHeaderCell: () => ({ style: storeInfoHeaderStyle }), onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => ( render: (v) => <span style={{ color: '#1A202C', fontWeight: 500 }}>{v}</span>,
<span style={{ color: '#1A202C', fontWeight: 500 }}>{v}</span>
),
}, },
{ {
title: '门店商户号', title: '门店商户号',
...@@ -63,9 +61,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] { ...@@ -63,9 +61,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] {
align: 'center', align: 'center',
onHeaderCell: () => ({ style: storeInfoHeaderStyle }), onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => ( render: (v) => <a style={{ color: '#2563EB', fontSize: 12.5 }}>{v}</a>,
<a style={{ color: '#2563EB', fontSize: 12.5 }}>{v}</a>
),
}, },
{ {
title: '业务场景', title: '业务场景',
...@@ -119,9 +115,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] { ...@@ -119,9 +115,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] {
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => ( render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>,
<span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>
),
}, },
{ {
title: '管理层市场费2计算模式', title: '管理层市场费2计算模式',
...@@ -149,9 +143,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] { ...@@ -149,9 +143,7 @@ export function buildPolicyColumns(): UTableProps<PolicyConfirmRow>['columns'] {
align: 'center', align: 'center',
onHeaderCell: () => ({ style: bizPolicyHeaderStyle }), onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
onCell: () => ({ style: cellStyle }), onCell: () => ({ style: cellStyle }),
render: (v) => ( render: (v) => <span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>,
<span style={{ fontWeight: 600, color: '#1F2937' }}>{v}</span>
),
}, },
{ {
title: '一线阳光是否开启线上积分', title: '一线阳光是否开启线上积分',
......
...@@ -34,12 +34,7 @@ export function StepsBar({ current = 0 }: StepsBarProps) { ...@@ -34,12 +34,7 @@ export function StepsBar({ current = 0 }: StepsBarProps) {
border: '1px solid #E5E7EB', border: '1px solid #E5E7EB',
}} }}
> >
<Steps <Steps current={current} items={stepItems} size="default" status="process" />
current={current}
items={stepItems}
size="default"
status="process"
/>
</div> </div>
); );
} }
...@@ -7,11 +7,7 @@ export interface SubmitActionBarProps { ...@@ -7,11 +7,7 @@ export interface SubmitActionBarProps {
onSubmit?: () => void; onSubmit?: () => void;
} }
export function SubmitActionBar({ export function SubmitActionBar({ totalRows = 12, onBack, onSubmit }: SubmitActionBarProps) {
totalRows = 12,
onBack,
onSubmit,
}: SubmitActionBarProps) {
return ( return (
<div <div
style={{ style={{
...@@ -21,10 +17,7 @@ export function SubmitActionBar({ ...@@ -21,10 +17,7 @@ export function SubmitActionBar({
paddingTop: 4, paddingTop: 4,
}} }}
> >
<UButton <UButton icon={<ArrowLeftOutlined />} onClick={onBack ?? (() => console.log('返回上一步'))}>
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步 返回上一步
</UButton> </UButton>
......
...@@ -6,10 +6,7 @@ export interface UploadActionBarProps { ...@@ -6,10 +6,7 @@ export interface UploadActionBarProps {
onNext?: () => void; onNext?: () => void;
} }
export function UploadActionBar({ export function UploadActionBar({ disabled = false, onNext }: UploadActionBarProps) {
disabled = false,
onNext,
}: UploadActionBarProps) {
return ( return (
<div <div
style={{ style={{
......
...@@ -8,13 +8,10 @@ import { ...@@ -8,13 +8,10 @@ import {
FileExcelOutlined, FileExcelOutlined,
} from '@ant-design/icons'; } from '@ant-design/icons';
import type { UploadProps, UploadFile } from 'antd'; import type { UploadProps, UploadFile } from 'antd';
import type { RcFile } from 'antd/es/upload/interface';
import { UCard, UUpload, UText, UButton } from '@uj/ui'; import { UCard, UUpload, UText, UButton } from '@uj/ui';
import { store } from '@/api'; import { store } from '@/api';
import { import { mockParseAndValidate, UPLOAD_RULES, type ParsedFileMeta } from '../tools/uploadValidate';
mockParseAndValidate,
UPLOAD_RULES,
type ParsedFileMeta,
} from '../tools/uploadValidate';
const TEMPLATE_NAME = '【优加】门店上架模版-V1.0.1.xlsx'; const TEMPLATE_NAME = '【优加】门店上架模版-V1.0.1.xlsx';
...@@ -54,7 +51,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -54,7 +51,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
} }
}; };
const buildUploadFile = (file: File): UploadFile => ({ const buildUploadFile = (file: RcFile): UploadFile => ({
uid: Date.now().toString(), uid: Date.now().toString(),
name: file.name, name: file.name,
size: file.size, size: file.size,
...@@ -86,7 +83,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -86,7 +83,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
} }
setFileMeta(result.meta); setFileMeta(result.meta);
setFileList([buildUploadFile(rawFile as File)]); setFileList([buildUploadFile(rawFile)]);
message.success('模板已上传,校验通过'); message.success('模板已上传,校验通过');
onUploadSuccess?.(result.meta); onUploadSuccess?.(result.meta);
} catch (e) { } catch (e) {
...@@ -121,7 +118,8 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -121,7 +118,8 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
} }
extra={ extra={
<UText type="secondary" style={{ fontSize: 12 }}> <UText type="secondary" style={{ fontSize: 12 }}>
支持 {UPLOAD_RULES.ALLOW_EXTS.join(' / ')} · 单文件 ≤ 10MB · 单次导入 1 家门店(≤ {UPLOAD_RULES.MAX_ROWS} 行) 支持 {UPLOAD_RULES.ALLOW_EXTS.join(' / ')} · 单文件 ≤ 10MB · 单次导入 1 家门店(≤{' '}
{UPLOAD_RULES.MAX_ROWS} 行)
</UText> </UText>
} }
> >
...@@ -230,9 +228,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -230,9 +228,7 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
> >
{fileMeta.fileName} {fileMeta.fileName}
</span> </span>
<CheckCircleFilled <CheckCircleFilled style={{ color: '#16A34A', fontSize: 16, flex: 'none' }} />
style={{ color: '#16A34A', fontSize: 16, flex: 'none' }}
/>
</div> </div>
<div <div
style={{ style={{
...@@ -240,12 +236,11 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) { ...@@ -240,12 +236,11 @@ export function UploadCard({ onUploadSuccess }: UploadCardProps) {
color: '#6B7280', color: '#6B7280',
}} }}
> >
{fileMeta.sizeKB} KB · 共 {fileMeta.rows} 行数据 {fileMeta.sizeKB} KB · 共 {fileMeta.rows} 行数据 (
({fileMeta.storeName.split('').slice(0, 6).join('')}… × {fileMeta.sceneCount} 个业务场景 × {fileMeta.categoryCount} 个产品分类) {fileMeta.storeName.split('').slice(0, 6).join('')}… × {fileMeta.sceneCount}{' '}
· 模板版本 {fileMeta.templateVersion} 个业务场景 × {fileMeta.categoryCount} 个产品分类) · 模板版本{' '}
<CheckCircleFilled {fileMeta.templateVersion}
style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }} <CheckCircleFilled style={{ color: '#16A34A', fontSize: 12, marginLeft: 6 }} />
/>
</div> </div>
</div> </div>
<UButton <UButton
......
...@@ -23,17 +23,12 @@ export function ValidationActionBar({ ...@@ -23,17 +23,12 @@ export function ValidationActionBar({
paddingTop: 8, paddingTop: 8,
}} }}
> >
<UButton <UButton icon={<ArrowLeftOutlined />} onClick={onBack ?? (() => console.log('返回上一步'))}>
icon={<ArrowLeftOutlined />}
onClick={onBack ?? (() => console.log('返回上一步'))}
>
返回上一步 返回上一步
</UButton> </UButton>
<div style={{ display: 'flex', gap: 12 }}> <div style={{ display: 'flex', gap: 12 }}>
<UButton <UButton onClick={onSubmitPassOnly ?? (() => console.log('仅提交通过行'))}>
onClick={onSubmitPassOnly ?? (() => console.log('仅提交通过行'))}
>
仅提交通过行({passCount}) 仅提交通过行({passCount})
</UButton> </UButton>
<UButton <UButton
......
...@@ -68,11 +68,7 @@ export default function TemplateImport() { ...@@ -68,11 +68,7 @@ export default function TemplateImport() {
<> <>
<PolicyConfirmHeader storeName="巴州强冠东风汽车销售服务有限公司" totalRows={12} /> <PolicyConfirmHeader storeName="巴州强冠东风汽车销售服务有限公司" totalRows={12} />
<PolicyConfirmTable dataSource={mockPolicyRows} /> <PolicyConfirmTable dataSource={mockPolicyRows} />
<ConfirmActionBar <ConfirmActionBar passCount={passCount} onBack={goPrev} onSubmit={goNext} />
passCount={passCount}
onBack={goPrev}
onSubmit={goNext}
/>
</> </>
)} )}
...@@ -80,11 +76,7 @@ export default function TemplateImport() { ...@@ -80,11 +76,7 @@ export default function TemplateImport() {
<> <>
<SubmitConfirmCard /> <SubmitConfirmCard />
<ApprovalChainPreview /> <ApprovalChainPreview />
<SubmitActionBar <SubmitActionBar totalRows={passCount} onBack={goPrev} onSubmit={handleFinalSubmit} />
totalRows={passCount}
onBack={goPrev}
onSubmit={handleFinalSubmit}
/>
</> </>
)} )}
</div> </div>
......
...@@ -12,12 +12,7 @@ export interface ParsedFileMeta { ...@@ -12,12 +12,7 @@ export interface ParsedFileMeta {
export interface ValidateResult { export interface ValidateResult {
ok: boolean; ok: boolean;
code?: code?: 'EXT_ERROR' | 'SIZE_ERROR' | 'ROWS_ERROR' | 'STORE_INCONSISTENT' | 'PARSE_ERROR';
| 'EXT_ERROR'
| 'SIZE_ERROR'
| 'ROWS_ERROR'
| 'STORE_INCONSISTENT'
| 'PARSE_ERROR';
message?: string; message?: string;
meta?: ParsedFileMeta; meta?: ParsedFileMeta;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!