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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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
| import { maskPhoneNumber } from '@/utils/utils';
| import { PageContainer, ProTable } from '@ant-design/pro-components';
| import { DatePicker, Input, message, Select, Tag, Typography } from 'antd';
| import moment from 'moment';
| import { useRef } from 'react';
| import { getCallRecords } from './service';
|
| const { RangePicker } = DatePicker;
|
| const callTypeOptions = [
| { label: '呼入', value: 'callin' },
| { label: '外呼', value: 'callout' },
| { label: '双向呼叫', value: 'twoWayCall' },
| { label: '智能外呼', value: 'autoCallout' },
| { label: '外呼任务', value: 'callTask' },
| ];
|
| const callTypeLabels = {
| callin: '呼入',
| callout: '外呼',
| twoWayCall: '双向呼叫',
| autoCallout: '智能外呼',
| callTask: '外呼任务',
| INBOUND: '呼入',
| OUTBOUND: '外呼',
| };
|
| const callStatusLabels = {
| ANSWER: '已接通',
| NO_ANSWER: '未接通',
| };
|
| const hangupPartyLabels = {
| CUSTOMER: '客户',
| ROBOT: '机器人',
| };
|
| const formatDateTime = (value) => {
| if (!value) return '';
| return typeof value.format === 'function' ? value.format('YYYY-MM-DD HH:mm:ss') : value;
| };
|
| const normalizeSearchParams = (params) => {
| const { current, pageSize, timeRange, ...rest } = params;
| const [startTime, endTime] = Array.isArray(timeRange) ? timeRange : [];
|
| return {
| ...rest,
| startTime: formatDateTime(startTime),
| endTime: formatDateTime(endTime),
| page: current > 0 ? current : 1,
| pageSize: pageSize > 0 ? pageSize : 1000,
| };
| };
|
| const renderText = (text) => text || '-';
|
| const CallRecords = () => {
| const actionRef = useRef();
| const defaultTimeRange = [moment().subtract(6, 'days').startOf('day'), moment().endOf('day')];
|
| const columns = [
| {
| title: '查询时间',
| dataIndex: 'timeRange',
| width: 260,
| renderFormItem: () => (
| <RangePicker showTime format="YYYY-MM-DD HH:mm:ss" style={{ width: '100%' }} />
| ),
| formItemProps: { rules: [{ required: true, message: '请选择查询时间' }] },
| hideInTable: true,
| },
| {
| title: '呼叫类型',
| dataIndex: 'callType',
| width: 130,
| renderFormItem: () => (
| <Select mode="multiple" allowClear options={callTypeOptions} placeholder="请选择呼叫类型" />
| ),
| render: (text) => <Tag color="blue">{callTypeLabels[text] || text || '-'}</Tag>,
| },
| {
| title: '客户号码',
| dataIndex: 'customerNumber',
| width: 140,
| render: (text) => maskPhoneNumber(text) || '-',
| },
| { title: '外显号码', dataIndex: 'displayNumber', width: 140, render: renderText },
| { title: '服务号码', dataIndex: 'serviceNumber', width: 140, render: renderText },
| {
| title: '通话状态',
| dataIndex: 'status',
| width: 140,
| renderFormItem: () => <Input placeholder="如 ANSWER" />,
| hideInTable: true,
| },
| {
| title: '通话状态',
| dataIndex: 'callStatus',
| width: 140,
| hideInSearch: true,
| render: (text) => callStatusLabels[text] || text || '-',
| },
| {
| title: '通话 ID',
| dataIndex: 'callId',
| width: 220,
| hideInSearch: true,
| ellipsis: true,
| render: renderText,
| },
| {
| title: '机器人名称',
| dataIndex: 'voiceAgentName',
| width: 120,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '机器人 ID',
| dataIndex: 'voiceAgentId',
| width: 180,
| hideInSearch: true,
| ellipsis: true,
| render: renderText,
| },
| {
| title: '人工坐席号码',
| dataIndex: 'agentNumber',
| width: 120,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '转接队列号码',
| dataIndex: 'queueNumber',
| width: 140,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '开始时间',
| dataIndex: 'startTime',
| width: 180,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '接通时间',
| dataIndex: 'answerTime',
| width: 180,
| hideInSearch: true,
| render: renderText,
| },
| { title: '结束时间', dataIndex: 'endTime', width: 180, hideInSearch: true, render: renderText },
| {
| title: '通话时长(秒)',
| dataIndex: 'durationSeconds',
| width: 130,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '是否转人工',
| dataIndex: 'transferredToAgent',
| width: 130,
| hideInSearch: true,
| render: (value) => (value ? <Tag color="green">是</Tag> : <Tag>否</Tag>),
| },
| {
| title: '转人工类型',
| dataIndex: 'transferType',
| width: 130,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '转人工时间',
| dataIndex: 'transferTime',
| width: 180,
| hideInSearch: true,
| render: renderText,
| },
| {
| title: '挂机方',
| dataIndex: 'hangupParty',
| width: 110,
| hideInSearch: true,
| render: (text) => hangupPartyLabels[text] || text || '-',
| },
| {
| title: '失败原因',
| dataIndex: 'failureReason',
| width: 180,
| hideInSearch: true,
| ellipsis: true,
| render: renderText,
| },
| {
| title: '通话路径',
| dataIndex: 'recordUrl',
| width: 120,
| hideInSearch: true,
| render: (url) =>
| url ? (
| <Typography.Link href={url} download>
| 下载录音
| </Typography.Link>
| ) : (
| '-'
| ),
| },
| {
| title: '通话录音',
| dataIndex: 'recordUrl',
| width: 280,
| hideInSearch: true,
| render: (url) =>
| url ? <audio controls preload="none" src={url} style={{ width: '260px' }} /> : '-',
| },
| {
| title: '任务 ID',
| dataIndex: 'taskId',
| width: 200,
| hideInSearch: true,
| ellipsis: true,
| render: renderText,
| },
| {
| title: '累计呼叫次数',
| dataIndex: 'dialCount',
| width: 130,
| hideInSearch: true,
| render: renderText,
| },
| ];
|
| return (
| <PageContainer title="通话记录">
| <ProTable
| rowKey="callId"
| actionRef={actionRef}
| columns={columns}
| form={{ initialValues: { timeRange: defaultTimeRange } }}
| search={{ defaultCollapsed: false }}
| scroll={{ x: 2900 }}
| sticky={{ offsetScroll: 0 }}
| pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
| request={async (params) => {
| const requestData = normalizeSearchParams(params);
| const start = moment(requestData.startTime, 'YYYY-MM-DD HH:mm:ss', true);
| const end = moment(requestData.endTime, 'YYYY-MM-DD HH:mm:ss', true);
|
| if (!start.isValid() || !end.isValid() || end.isBefore(start)) {
| message.error('请选择有效的查询时间范围');
| return { data: [], total: 0, success: false };
| }
|
| if (end.diff(start, 'seconds') > 7 * 24 * 60 * 60) {
| message.error('查询时间跨度不能超过 7 天');
| return { data: [], total: 0, success: false };
| }
|
| const response = await getCallRecords(requestData);
| return {
| data: response?.data?.list || [],
| total: response?.data?.total || 0,
| success: response?.code === 200 || response?.code === '200',
| };
| }}
| />
| </PageContainer>
| );
| };
|
| export default CallRecords;
|
|