List.tsx
2.04 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
import React from "react";
import { message, Popconfirm, Table, Space } from "antd";
import { useStore } from '../index';
import { fetchDeleteConfigApi, List } from '../api';
import { isNil } from 'lodash';
const Column = Table.Column;
export default function TableList() {
const {data, loading, setLoading, setVisible, setCurrent, setStatusData } = useStore();
function handleDelete(id?: number) {
fetchDeleteConfigApi(id)
.then(res => {
message.success(res.result);
setLoading(true);
})
.catch(e => {
message.error(e.message);
});
}
function handleEdit(value?: List) {
setCurrent(value || {});
setVisible(true);
}
function handleLookShop(value: any = {}) {
setStatusData({visible: true, data: value.shopList || []});
}
return (
<div>
<Table
dataSource={data}
pagination={false}
loading={loading}
rowKey="id"
>
<Column
title="适用门店"
align="left"
dataIndex="displayName"
render={(_text, record) => <span onClick={() => handleLookShop(record)} style={{color: "#4189FD"}}>{_text}</span>}
/>
<Column
title="线索到店零售台数占比"
align="left"
dataIndex="retailRate"
render={(_text, record: any) => <span>{isNil(record?.retailRate) ? "--" : `${record.retailRate}%`}</span>}
/>
<Column
title="操作"
align="left"
render={(_text, record: any) => {
return (
<Space>
<a onClick={() => handleEdit(record)} style={{ display: "block", color: "#4189FD" }}>编辑</a>
<Popconfirm
title="是否删除?"
okText="确定"
cancelText="取消"
onConfirm={() => handleDelete(record.id)}
>
<a style={{color: "#EC3F2F"}}>删除</a>
</Popconfirm>
</Space>
);
}}
/>
</Table>
</div>
);
}