PageHeader.tsx
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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,
},
];
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>
);
}