曾国涛
authored
11 months ago
1
import ClientDrawer from '@/pages/Client/Components/ClientDrawer';
曾国涛
authored
11 months ago
2
import ClientImportModal from '@/pages/Client/Components/ClientImportModal';
曾国涛
authored
10 months ago
3
import ClientStatistic from '@/pages/Client/Components/ClientStatistic';
曾国涛
authored
11 months ago
4
5
6
import CommunicationHistoryModal from '@/pages/Client/Components/CommunicationHistoryModal';
import {
postAdminClientQueryClientPage,
曾国涛
authored
10 months ago
7
postServiceConstClientGroupFilters,
曾国涛
authored
11 months ago
8
9
10
11
12
postServiceConstClientLevels,
postServiceConstTradeStatus,
} from '@/services';
import { orderExport } from '@/services/order';
import { enumToSelect } from '@/utils';
曾国涛
authored
11 months ago
13
14
import type { ActionType } from '@ant-design/pro-components';
import { ProTable } from '@ant-design/pro-components';
曾国涛
authored
10 months ago
15
16
import { Button, Radio, Space, message } from 'antd';
import { useEffect, useRef, useState } from 'react';
曾国涛
authored
11 months ago
17
曾国涛
authored
11 months ago
18
const columns = [
曾国涛
authored
11 months ago
19
20
21
{
dataIndex: 'index',
valueType: 'indexBorder',
曾国涛
authored
10 months ago
22
ellipsis: true,
曾国涛
authored
11 months ago
23
24
25
width: 48,
},
{
曾国涛
authored
11 months ago
26
27
title: '客户名称',
dataIndex: 'name',
曾国涛
authored
11 months ago
28
width: 100,
曾国涛
authored
10 months ago
29
ellipsis: true,
曾国涛
authored
11 months ago
30
hideInSearch: true,
曾国涛
authored
11 months ago
31
32
},
{
曾国涛
authored
11 months ago
33
title: '单位名称',
曾国涛
authored
11 months ago
34
width: 150,
曾国涛
authored
10 months ago
35
ellipsis: true,
曾国涛
authored
11 months ago
36
dataIndex: 'companyName',
曾国涛
authored
11 months ago
37
hideInSearch: true,
曾国涛
authored
11 months ago
38
39
},
{
曾国涛
authored
11 months ago
40
title: '单位地址',
曾国涛
authored
11 months ago
41
width: 250,
曾国涛
authored
10 months ago
42
ellipsis: true,
曾国涛
authored
11 months ago
43
dataIndex: 'companyAddressText',
曾国涛
authored
11 months ago
44
hideInSearch: true,
曾国涛
authored
11 months ago
45
46
},
{
曾国涛
authored
11 months ago
47
title: '联系电话',
曾国涛
authored
11 months ago
48
width: 150,
曾国涛
authored
10 months ago
49
ellipsis: true,
曾国涛
authored
11 months ago
50
dataIndex: 'phoneNumber',
曾国涛
authored
11 months ago
51
hideInSearch: true,
曾国涛
authored
11 months ago
52
53
54
},
{
title: '客户来源',
曾国涛
authored
11 months ago
55
width: 150,
曾国涛
authored
10 months ago
56
ellipsis: true,
曾国涛
authored
11 months ago
57
58
dataIndex: 'source',
hideInSearch: true,
曾国涛
authored
11 months ago
59
60
61
62
},
{
title: '推荐人',
dataIndex: 'referrers',
曾国涛
authored
11 months ago
63
width: 150,
曾国涛
authored
10 months ago
64
ellipsis: true,
曾国涛
authored
11 months ago
65
hideInSearch: true,
曾国涛
authored
11 months ago
66
67
68
69
},
{
title: '客户需求',
dataIndex: 'requirements',
曾国涛
authored
11 months ago
70
width: 150,
曾国涛
authored
10 months ago
71
ellipsis: true,
曾国涛
authored
11 months ago
72
hideInSearch: true,
曾国涛
authored
11 months ago
73
74
75
},
{
title: '是否已报方案',
曾国涛
authored
11 months ago
76
width: 150,
曾国涛
authored
10 months ago
77
ellipsis: true,
曾国涛
authored
11 months ago
78
dataIndex: 'hasSchemeText',
曾国涛
authored
11 months ago
79
hideInSearch: true,
曾国涛
authored
11 months ago
80
81
82
83
},
{
title: '报价时间',
key: 'since',
曾国涛
authored
11 months ago
84
width: 150,
曾国涛
authored
10 months ago
85
ellipsis: true,
曾国涛
authored
11 months ago
86
87
dataIndex: 'quoteDatetime',
valueType: 'dateTime',
曾国涛
authored
11 months ago
88
hideInSearch: true,
曾国涛
authored
11 months ago
89
90
91
},
{
title: '跟进状态',
曾国涛
authored
11 months ago
92
width: 150,
曾国涛
authored
10 months ago
93
ellipsis: true,
曾国涛
authored
11 months ago
94
dataIndex: 'tradeStatusText',
曾国涛
authored
11 months ago
95
hideInSearch: true,
曾国涛
authored
11 months ago
96
97
98
},
{
title: '客户等级',
曾国涛
authored
11 months ago
99
width: 150,
曾国涛
authored
10 months ago
100
ellipsis: true,
曾国涛
authored
11 months ago
101
dataIndex: 'levelText',
曾国涛
authored
11 months ago
102
hideInSearch: true,
曾国涛
authored
11 months ago
103
104
105
},
{
title: '创建时间',
曾国涛
authored
11 months ago
106
key: 'since',
曾国涛
authored
11 months ago
107
width: 150,
曾国涛
authored
10 months ago
108
ellipsis: true,
曾国涛
authored
11 months ago
109
110
dataIndex: 'createTime',
valueType: 'dateTime',
曾国涛
authored
11 months ago
111
hideInSearch: true,
曾国涛
authored
11 months ago
112
113
114
115
},
{
title: '最新跟进时间',
key: 'since',
曾国涛
authored
11 months ago
116
width: 150,
曾国涛
authored
10 months ago
117
ellipsis: true,
曾国涛
authored
11 months ago
118
119
dataIndex: 'latestCommunicationTime',
valueType: 'dateTime',
曾国涛
authored
11 months ago
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
hideInSearch: true,
},
{
title: '客户名称',
dataIndex: 'nameLike',
valueType: 'Text',
hideInTable: true,
},
{
title: '单位名称',
dataIndex: 'companyNameLike',
valueType: 'Text',
hideInTable: true,
},
{
title: '联系电话',
dataIndex: 'phoneNumberLike',
valueType: 'Text',
hideInTable: true,
},
{
title: '是否已报方案',
dataIndex: 'hasScheme',
valueType: 'select',
valueEnum: {
true: {
text: '是',
value: true,
},
false: {
text: '否',
value: false,
},
},
hideInTable: true,
},
{
title: '客户等级',
dataIndex: 'level',
valueType: 'select',
hideInTable: true,
request: async () => {
const res = await postServiceConstClientLevels();
return enumToSelect(res.data);
},
},
{
title: '跟进状态',
dataIndex: 'tradeStatus',
valueType: 'select',
hideInTable: true,
request: async () => {
const res = await postServiceConstTradeStatus();
return enumToSelect(res.data);
},
},
{
title: '创建时间',
valueType: 'dateRange',
hideInTable: true,
search: {
transform: (value) => {
if (value) {
return {
createTimeGe: value[0],
createTimeLe: value[1],
};
}
},
},
曾国涛
authored
11 months ago
190
191
192
193
194
},
{
title: '操作',
valueType: 'option',
key: 'option',
曾国涛
authored
11 months ago
195
width: 150,
曾国涛
authored
11 months ago
196
render: (text, record, index, action) => {
曾国涛
authored
11 months ago
197
198
199
200
201
202
console.log(JSON.stringify(record));
return [
<CommunicationHistoryModal
key={'communicationHistory'}
clientId={record.id}
/>,
曾国涛
authored
11 months ago
203
204
205
206
<ClientDrawer
key={'detail'}
record={record}
optType={'detail'}
曾国涛
authored
11 months ago
207
208
209
onFinish={() => {
action.reload();
}}
曾国涛
authored
11 months ago
210
211
212
213
214
></ClientDrawer>,
<ClientDrawer
key={'edit'}
record={record}
optType={'edit'}
曾国涛
authored
11 months ago
215
216
217
onFinish={() => {
action.reload();
}}
曾国涛
authored
11 months ago
218
></ClientDrawer>,
曾国涛
authored
11 months ago
219
220
];
},
曾国涛
authored
11 months ago
221
222
223
224
},
];
export default () => {
曾国涛
authored
11 months ago
225
const [messageApi, contextHolder] = message.useMessage();
曾国涛
authored
10 months ago
226
227
const [groupFilter, setGroupFilter] = useState('All');
const [groupFilterOptions, setGroupFilterDataOptions] = useState([]);
曾国涛
authored
11 months ago
228
const actionRef = useRef<ActionType>();
曾国涛
authored
10 months ago
229
230
231
232
233
234
235
236
237
238
239
useEffect(() => {
const pullGroupFilterDataOptions = async () => {
const res = await postServiceConstClientGroupFilters();
console.log('setGroupFilterDataOptions' + JSON.stringify(res.data));
setGroupFilterDataOptions(enumToSelect(res.data));
};
pullGroupFilterDataOptions();
}, []);
useEffect(() => {
actionRef.current?.reload();
}, [groupFilter]);
曾国涛
authored
11 months ago
240
return (
曾国涛
authored
11 months ago
241
<>
曾国涛
authored
10 months ago
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<ClientStatistic></ClientStatistic>
<ProTable
columns={columns}
actionRef={actionRef}
cardBordered
request={async (params) => {
const res = await postAdminClientQueryClientPage({
data: {
...params,
groupFilter: groupFilter,
},
});
const data = res.data;
return data;
}}
search={{
optionRender: (searchConfig, formProps, dom) => [
...dom.reverse(),
<Button
key="out"
onClick={() => {
const values = searchConfig?.form?.getFieldsValue();
messageApi.open({
type: 'loading',
content: '导出中...',
duration: 0,
});
orderExport(
'/api/admin/client/exportClients',
'客户信息.xlsx',
'POST',
values,
() => {
messageApi.destroy();
},
);
}}
>
导出
</Button>,
],
}}
scroll={{
x: 1400,
}}
editable={{
type: 'multiple',
}}
columnsState={{
persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage',
defaultValue: {
option: { fixed: 'right', disable: true },
},
onChange(value) {
console.log('value: ', value);
曾国涛
authored
11 months ago
299
},
曾国涛
authored
10 months ago
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
}}
rowKey="id"
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={() => [
<div key={'groupFilter'}>
<Radio.Group
options={groupFilterOptions}
onChange={(e) => {
setGroupFilter(e.target.value);
}}
value={groupFilter}
optionType="button"
/>
</div>,
<ClientDrawer
optType={'add'}
key="button"
onFinish={() => {
actionRef.current.reload();
曾国涛
authored
11 months ago
341
}}
曾国涛
authored
10 months ago
342
343
344
345
346
></ClientDrawer>,
<ClientImportModal key="import" />,
]}
/>
</Space>
曾国涛
authored
11 months ago
347
348
{contextHolder}
</>
曾国涛
authored
11 months ago
349
350
);
};