index.tsx
5.26 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import React, { useState } from "react";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import { Button, Card, Table, Row, message, Space, Typography, Divider, Switch, Upload } from "antd";
import usePagination from "@/hooks/usePagination";
import useInitial from "@/hooks/useInitail";
import { evaDataListApi, upLoadStaffApi, upLoadShopApi } from "./api";
import { UploadOutlined } from "@ant-design/icons";
import type { UploadProps } from "antd";
import { history } from "umi";
import moment from "moment";
import Filter from './components/Filter';
import FileDatailsModal from './components/FileDatailsModal';
const Column = Table.Column;
export default () => {
const { loading, list, paginationConfig, setParams, innerParams } = usePagination(evaDataListApi, {
pageSize: 10,
});
const { data: upLoadStaff, loading: upLoadStaffLoading } = useInitial(upLoadStaffApi, [], {});
const { data: upLoadShop, loading: upLoadShopLoading } = useInitial(upLoadShopApi, [], {});
const [fileData, setFileData] = useState({});
const [visible, setVisible] = useState<boolean>(false);
console.log("upLoadStaff", upLoadStaff);
console.log("upLoadShop", upLoadShop);
const uploadPerson: UploadProps = {
name: "file",
action: "/api/morax/erp/eval-indicator/analysis-staff",
maxCount: 1,
showUploadList: false,
onChange(info) {
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
setFileData(info.file.response.data);
setVisible(true);
} else if (info.file.status === "error") {
message.error(`${info.file.name} 上传失败`);
}
},
};
const uploadShop: UploadProps = {
name: "file",
action: "/api/morax/erp/eval-indicator/analysis-shop",
maxCount: 1,
showUploadList: false,
onChange(info) {
if (info.file.status !== "uploading") {
console.log(info.file, info.fileList);
}
if (info.file.status === "done") {
setFileData(info.file.response.data);
setVisible(true);
} else if (info.file.status === "error") {
message.error(`${info.file.name} 上传失败`);
}
},
};
return (
<PageHeaderWrapper title="考评数据导入">
<Card>
<Row style={{ marginBottom: 10 }} justify="space-between">
<Filter setParams={setParams} />
<div>
<Button type="default" style={{ marginRight: 10 }} loading={upLoadStaffLoading}>
<a href={upLoadStaff} target="_blank" rel="noreferrer">
下载人员模板
</a>
</Button>
<Button type="default" style={{ marginRight: 10 }} loading={upLoadShopLoading}>
<a href={upLoadShop} target="_blank" rel="noreferrer">
下载门店模板
</a>
</Button>
<Upload {...uploadPerson}>
<Button type="primary" style={{ marginRight: 10 }}>
按人员导入
</Button>
</Upload>
<Upload {...uploadShop}>
<Button type="primary">按门店导入</Button>
</Upload>
</div>
</Row>
<Table loading={loading} rowKey={(row) => `id${row.id}`} dataSource={list} pagination={paginationConfig}>
<Column
title="导入时间"
dataIndex="createTime"
align="center"
render={(time: number) => (time ? moment(time).format("YYYY-MM-DD") : "--")}
/>
<Column
title="导入人员"
dataIndex="importUserName"
align="center"
render={(name) => <span>{name || "--"}</span>}
/>
<Column
title="指标名称"
dataIndex="indicatorName"
align="center"
render={(name) => <span>{name || "--"}</span>}
/>
<Column
title="导入数据"
dataIndex="num"
align="center"
render={(num) => <span>{num !== undefined ? `${num}条` : "--"}</span>}
/>
<Column
title="成功"
dataIndex="successNum"
align="center"
render={(num) => <span>{num !== undefined ? `${num}条` : "--"}</span>}
/>
<Column
title="失败"
dataIndex="errorNum"
align="center"
render={(num) => <span>{num !== undefined ? `${num}条` : "--"}</span>}
/>
<Column
title="数据清单"
align="center"
dataIndex="enable"
width={150}
render={(text: boolean, record: any) => (
<Space split={<Divider type="vertical" />}>
<Typography.Link
onClick={() => {
history.push(`/morax/evaDataImport/edit/${record.id}/${record.num}`);
}}
>
查看
</Typography.Link>
</Space>
)}
/>
</Table>
<FileDatailsModal
visible={visible}
tarOnCancel={() => setVisible(false)}
fileData={fileData}
setParams={setParams}
innerParams={innerParams}
/>
</Card>
</PageHeaderWrapper>
);
};