|
@@ -1,6 +1,7 @@
|
|
import React, { Component } from "react";
|
|
import React, { Component } from "react";
|
|
import { Table, Spin, Button, message, Select, Modal, Icon } from "antd";
|
|
import { Table, Spin, Button, message, Select, Modal, Icon } from "antd";
|
|
import $ from "jquery/src/ajax";
|
|
import $ from "jquery/src/ajax";
|
|
|
|
+import moment from 'moment';
|
|
import "./index.less";
|
|
import "./index.less";
|
|
|
|
|
|
class Outbound extends Component {
|
|
class Outbound extends Component {
|
|
@@ -11,6 +12,7 @@ class Outbound extends Component {
|
|
pVisible: false,
|
|
pVisible: false,
|
|
rVisible: false,
|
|
rVisible: false,
|
|
tVisible: false,
|
|
tVisible: false,
|
|
|
|
+ status: false,
|
|
uList: [],
|
|
uList: [],
|
|
tList: [],
|
|
tList: [],
|
|
transAgent: "",
|
|
transAgent: "",
|
|
@@ -23,7 +25,7 @@ class Outbound extends Component {
|
|
showQuickJumper: true,
|
|
showQuickJumper: true,
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
onChange: function (page) {
|
|
onChange: function (page) {
|
|
- this.loadData(page);
|
|
|
|
|
|
+ this.userCallList(page);
|
|
}.bind(this),
|
|
}.bind(this),
|
|
showTotal: function (total) {
|
|
showTotal: function (total) {
|
|
return '共' + total + '条数据';
|
|
return '共' + total + '条数据';
|
|
@@ -47,9 +49,12 @@ class Outbound extends Component {
|
|
width: 100,
|
|
width: 100,
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- title: '时长(秒)',
|
|
|
|
|
|
+ title: '时长',
|
|
dataIndex: 'duration',
|
|
dataIndex: 'duration',
|
|
key: 'duration',
|
|
key: 'duration',
|
|
|
|
+ render: (text) => {
|
|
|
|
+ return this.isTime(text)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
{
|
|
{
|
|
title: '时间',
|
|
title: '时间',
|
|
@@ -59,53 +64,76 @@ class Outbound extends Component {
|
|
],
|
|
],
|
|
};
|
|
};
|
|
this.onOk = this.onOk.bind(this);
|
|
this.onOk = this.onOk.bind(this);
|
|
- this.onCancel = this.onCancel.bind(this);
|
|
|
|
this.blindTransferByAgent = this.blindTransferByAgent.bind(this);
|
|
this.blindTransferByAgent = this.blindTransferByAgent.bind(this);
|
|
this.webSocket = null;
|
|
this.webSocket = null;
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
- this.webSocket = new WebSocket('wss://uat.jishutao.com/webSocketServer');
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ componentWillUnmount() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ isTime(second) {
|
|
|
|
+ let time = "0秒"
|
|
|
|
+ if (second > 3600) {
|
|
|
|
+ time = moment.utc(second * 1000).format('h小时m分s秒')
|
|
|
|
+ } else if (second > 60) {
|
|
|
|
+ time = moment.utc(second * 1000).format('m分s秒')
|
|
|
|
+ } else {
|
|
|
|
+ time = moment.utc(second * 1000).format('s秒')
|
|
|
|
+ }
|
|
|
|
+ return time
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getWebSocket() {
|
|
|
|
+ const _this = this
|
|
|
|
+ if (typeof (WebSocket) == "undefined") {
|
|
|
|
+ console.log('\x1b[31m您的浏览器不支持WebSocket\x1b[0m')
|
|
|
|
+ } else {
|
|
|
|
+ console.log('\x1b[32m您的浏览器支持WebSocket\x1b[0m')
|
|
|
|
+ }
|
|
|
|
+ // 测试
|
|
|
|
+ // this.webSocket = new WebSocket('ws://uat.jishutao.com/webSocketServer');
|
|
|
|
+ // 生产
|
|
|
|
+ this.webSocket = new WebSocket('wss://bm.jishutao.com/webSocketServer');
|
|
// 处理WebSocket打开事件
|
|
// 处理WebSocket打开事件
|
|
this.webSocket.onopen = () => {
|
|
this.webSocket.onopen = () => {
|
|
- console.log('WebSocket connection opened');
|
|
|
|
|
|
+ console.log('WebSocke已打开');
|
|
};
|
|
};
|
|
-
|
|
|
|
// 处理收到消息的事件
|
|
// 处理收到消息的事件
|
|
this.webSocket.onmessage = (event) => {
|
|
this.webSocket.onmessage = (event) => {
|
|
const newMessage = event.data;
|
|
const newMessage = event.data;
|
|
- this.setState((prevState) => ({
|
|
|
|
- messages: [...prevState.messages, newMessage],
|
|
|
|
- }));
|
|
|
|
|
|
+ console.log('WebSocke已连接', newMessage);
|
|
|
|
+ _this.setState({
|
|
|
|
+ status: false
|
|
|
|
+ })
|
|
|
|
+ // const newMessage = event.data;
|
|
|
|
+ // this.setState((prevState) => ({
|
|
|
|
+ // messages: [...prevState.messages, newMessage],
|
|
|
|
+ // }));
|
|
|
|
+ if (this.webSocket) {
|
|
|
|
+ console.log("关闭WebSocket连接")
|
|
|
|
+ this.webSocket.close();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
-
|
|
|
|
// 处理WebSocket关闭事件
|
|
// 处理WebSocket关闭事件
|
|
this.webSocket.onclose = () => {
|
|
this.webSocket.onclose = () => {
|
|
- console.log('WebSocket connection closed');
|
|
|
|
|
|
+ console.log('WebSocket已关闭');
|
|
};
|
|
};
|
|
-
|
|
|
|
// 处理WebSocket错误事件
|
|
// 处理WebSocket错误事件
|
|
this.webSocket.onerror = (error) => {
|
|
this.webSocket.onerror = (error) => {
|
|
- console.error('WebSocket error:', error);
|
|
|
|
|
|
+ console.error('WebSocket出错了', error);
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
- componentWillUnmount() {
|
|
|
|
- // 在组件卸载前关闭WebSocket连接
|
|
|
|
- if (this.webSocket) {
|
|
|
|
- this.webSocket.close();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
onOk() {
|
|
onOk() {
|
|
- this.callNumber()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- onCancel() {
|
|
|
|
this.setState({
|
|
this.setState({
|
|
- pVisible: false
|
|
|
|
|
|
+ status: true
|
|
})
|
|
})
|
|
|
|
+ this.callNumber()
|
|
}
|
|
}
|
|
// 公共库-默认联系人
|
|
// 公共库-默认联系人
|
|
getDefaultMobile() {
|
|
getDefaultMobile() {
|
|
@@ -217,16 +245,20 @@ class Outbound extends Component {
|
|
// 呼叫转移
|
|
// 呼叫转移
|
|
blindTransferByAgent() {
|
|
blindTransferByAgent() {
|
|
const { transAgent } = this.state
|
|
const { transAgent } = this.state
|
|
|
|
+ const _this = this
|
|
$.ajax({
|
|
$.ajax({
|
|
method: "post",
|
|
method: "post",
|
|
dataType: "json",
|
|
dataType: "json",
|
|
crossDomain: false,
|
|
crossDomain: false,
|
|
- url: globalConfig.context + "/api/admblindTransferByAgentin/userOutbound",
|
|
|
|
|
|
+ url: globalConfig.context + "/api/admin/userOutbound/blindTransferByAgent",
|
|
data: {
|
|
data: {
|
|
transAgent,
|
|
transAgent,
|
|
}
|
|
}
|
|
}).done(function (data) {
|
|
}).done(function (data) {
|
|
if (!data.error.length) {
|
|
if (!data.error.length) {
|
|
|
|
+ _this.setState({
|
|
|
|
+ tVisible: false
|
|
|
|
+ })
|
|
message.success(data.data)
|
|
message.success(data.data)
|
|
} else {
|
|
} else {
|
|
message.warning(data.error[0].message);
|
|
message.warning(data.error[0].message);
|
|
@@ -289,23 +321,27 @@ class Outbound extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- const { pVisible, rVisible, tVisible, transAgent, tList, mobile, uList } = this.state
|
|
|
|
|
|
+ const { status, pVisible, rVisible, tVisible, transAgent, tList, mobile, uList } = this.state
|
|
const { type, } = this.props
|
|
const { type, } = this.props
|
|
|
|
|
|
return (
|
|
return (
|
|
<span>
|
|
<span>
|
|
{type != "history" &&
|
|
{type != "history" &&
|
|
<Button
|
|
<Button
|
|
- style={{ background: !pVisible ? "green" : "red", border: 0 }}
|
|
|
|
|
|
+ style={{ background: !status ? "green" : "red", border: 0 }}
|
|
type="primary"
|
|
type="primary"
|
|
loading={pVisible}
|
|
loading={pVisible}
|
|
onClick={() => {
|
|
onClick={() => {
|
|
|
|
+ if (status) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.getWebSocket();
|
|
type == "public"
|
|
type == "public"
|
|
? this.getDefaultMobile()
|
|
? this.getDefaultMobile()
|
|
: this.findCustomerContacts()
|
|
: this.findCustomerContacts()
|
|
}}
|
|
}}
|
|
- >{!pVisible && <Icon type="phone" />} {!pVisible ? '呼叫' : '正在通话中'}</Button>}
|
|
|
|
- {type == "private" &&
|
|
|
|
|
|
+ >{!pVisible && <Icon type="phone" />} {!status ? '呼叫' : '正在通话中'}</Button>}
|
|
|
|
+ {type == "private" && status &&
|
|
<Button
|
|
<Button
|
|
style={{ background: "green", border: 0, marginLeft: 20 }}
|
|
style={{ background: "green", border: 0, marginLeft: 20 }}
|
|
type="primary"
|
|
type="primary"
|
|
@@ -329,7 +365,11 @@ class Outbound extends Component {
|
|
maskClosable={false}
|
|
maskClosable={false}
|
|
okText="呼叫"
|
|
okText="呼叫"
|
|
onOk={this.onOk}
|
|
onOk={this.onOk}
|
|
- onCancel={this.onCancel}
|
|
|
|
|
|
+ onCancel={() => {
|
|
|
|
+ this.setState({
|
|
|
|
+ pVisible: false
|
|
|
|
+ })
|
|
|
|
+ }}
|
|
>
|
|
>
|
|
<div className="contacts">
|
|
<div className="contacts">
|
|
<Select
|
|
<Select
|
|
@@ -394,7 +434,7 @@ class Outbound extends Component {
|
|
>
|
|
>
|
|
<div>
|
|
<div>
|
|
<div style={{ marginBottom: 5 }}>公司名称:{this.state.info.name}</div>
|
|
<div style={{ marginBottom: 5 }}>公司名称:{this.state.info.name}</div>
|
|
- <div style={{ marginBottom: 10 }}>累计通话次数:{this.state.info.callCount}次 通话时长:{this.state.info.callDuration}秒</div>
|
|
|
|
|
|
+ <div style={{ marginBottom: 10 }}>累计通话次数:{this.state.info.callCount}次 通话时长:{this.isTime(this.state.info.callDuration)}</div>
|
|
<Spin spinning={this.state.loading}>
|
|
<Spin spinning={this.state.loading}>
|
|
<Table
|
|
<Table
|
|
size="middle"
|
|
size="middle"
|