index.tsx
4.02 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import ClientDrawer from '@/pages/Client/Components/ClientDrawer';
import { postAdminClientQueryClientPage } from '@/services';
import { EllipsisOutlined } from '@ant-design/icons';
import type { ActionType } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
import { Button, Dropdown } from 'antd';
import { useRef } from 'react';
export const waitTimePromise = async (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
export const waitTime = async (time: number = 100) => {
await waitTimePromise(time);
};
const columns = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '客户名称',
dataIndex: 'name',
},
{
title: '单位名称',
dataIndex: 'companyName',
},
{
title: '单位地址',
dataIndex: 'companyName',
},
{
title: '联系电话',
dataIndex: 'phoneNumber',
},
{
title: '客户来源',
dataIndex: 'sourceText',
},
{
title: '推荐人',
dataIndex: 'referrers',
},
{
title: '客户需求',
dataIndex: 'requirements',
},
{
title: '是否已报方案',
dataIndex: 'hasSchemeText',
},
{
title: '报价时间',
key: 'since',
dataIndex: 'quoteDatetime',
valueType: 'dateTime',
},
{
title: '跟进状态',
dataIndex: 'tradeStatusText',
},
{
title: '客户等级',
dataIndex: 'levelText',
},
{
title: '创建时间',
key: 'since',
dataIndex: 'createTime',
valueType: 'dateTime',
},
{
title: '最新跟进时间',
key: 'since',
dataIndex: 'latestCommunicationTime',
valueType: 'dateTime',
},
{
title: '操作',
valueType: 'option',
key: 'option',
render: (text, record, _, action) => [
<a
key="editable"
onClick={() => {
action?.startEditable?.(record.id);
}}
>
查询详情
</a>,
<a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
跟进记录
</a>,
],
},
];
export default () => {
const actionRef = useRef<ActionType>();
return (
<ProTable
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params) => {
const res = await postAdminClientQueryClientPage({
data: {
...params,
},
});
const data = res.data.data;
return data;
}}
editable={{
type: 'multiple',
}}
columnsState={{
persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage',
defaultValue: {
option: { fixed: 'right', disable: true },
},
onChange(value) {
console.log('value: ', value);
},
}}
rowKey="id"
search={{
labelWidth: 'auto',
}}
options={{
setting: {
listsHeight: 400,
},
}}
form={{
// 由于配置了 transform,提交的参与与定义的不同这里需要转化一下
syncToUrl: (values, type) => {
if (type === 'get') {
return {
...values,
created_at: [values.startTime, values.endTime],
};
}
return values;
},
}}
pagination={{
pageSize: 5,
onChange: (page) => console.log(page),
}}
dateFormatter="string"
headerTitle="高级表格"
toolBarRender={() => [
<ClientDrawer key="button" />,
<Dropdown
key="menu"
menu={{
items: [
{
label: '1st item',
key: '1',
},
{
label: '2nd item',
key: '1',
},
{
label: '3rd item',
key: '1',
},
],
}}
>
<Button>
<EllipsisOutlined />
</Button>
</Dropdown>,
]}
/>
);
};