FileDatailsModal.tsx
3.61 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
import React, { useState, useEffect } from "react";
import {
Table,
Input,
InputNumber,
Popconfirm,
Form,
Typography,
Button,
message,
Space,
Divider,
Modal,
Card,
} from "antd";
import { cloneDeep } from "lodash";
import { KpiGroupSetteing } from "@/pages/performance/KpiGroupSetting/interface";
import { TargetType, TargetTypeEnum } from "@/pages/performance/entity";
import { render } from "react-dom";
import moment from "moment";
import { ReasonsEnum } from "../entity";
import { saveEvaImportData } from "../api";
import { history } from "umi";
import st from "./style.less";
const Column = Table.Column;
interface Props {
visible: boolean;
fileData: any;
tarOnCancel: Function;
setParams: Function;
innerParams: any;
}
const TargetModal = ({ visible, fileData, tarOnCancel, setParams, innerParams }: Props) => {
const [loading, setLoading] = useState<boolean>(false);
const onOk = async (key: string) => {
const pa = { key };
setLoading(true);
try {
const { success } = await saveEvaImportData(pa);
if (success) {
setLoading(false);
message.success(`数据上传成功`, 5);
// 重新刷新列表
setParams({ ...innerParams }, true);
tarOnCancel && tarOnCancel();
}
} catch (error: any) {
setLoading(false);
message.error(error.message);
}
};
return (
<>
<Modal
title="导入数据详情"
visible={visible}
onCancel={() => tarOnCancel()}
maskClosable={false}
width={1500}
onOk={() => onOk(fileData.key)}
confirmLoading={loading}
>
<Table bordered dataSource={fileData.details} pagination={{ total: fileData.num }}>
<Column title="归属人员" dataIndex="userName" align="center" render={(name) => <span>{name || "--"}</span>} />
<Column title="归属门店" dataIndex="shopName" align="center" render={(name) => <span>{name || "--"}</span>} />
<Column
title="指标名称"
dataIndex="indicatorName"
align="center"
render={(name) => <span>{name || "--"}</span>}
/>
{/* <Column
title="指标值"
dataIndex="indicatorValue"
align="center"
render={(num, record: any) => (
<span>
{num !== undefined
? `${num}${
record.dataType == 1 ? "台" : record.dataType == 2 ? "%" : record.dataType == 3 ? "元" : ""
}`
: "--"}
</span>
)}
/> */}
<Column
title="考核周期"
dataIndex="dataDate"
align="center"
render={(time: number) => (time ? moment(time).format("YYYY-MM-DD") : "--")}
/>
<Column
title="是否导入"
dataIndex="errorType"
align="center"
render={(_: any, record: any) =>
record.errorType ? <div className={st.no}>未导入</div> : <div className={st.yes}>已导入</div>
}
/>
<Column
title="未导入原因"
dataIndex="errorType"
align="center"
render={(_: any, record: any) => (record.errorType ? ReasonsEnum[record.errorType] : "--")}
/>
</Table>
<div>
成功条数: <span style={{ color: "#20c688" }}>{fileData.successNum}</span> 条
</div>
<div>
失败条数: <span style={{ color: "#f4333c" }}>{fileData.errorNum}</span> 条
</div>
</Modal>
</>
);
};
export default TargetModal;