Browse Source

外呼优化

dev01 14 hours ago
parent
commit
6424d03a61

+ 72 - 32
js/component/manageCenter/customer/NEW/components/outbound/index.jsx

@@ -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}次&nbsp;&nbsp;&nbsp;&nbsp;通话时长:{this.state.info.callDuration}</div>
+            <div style={{ marginBottom: 10 }}>累计通话次数:{this.state.info.callCount}次&nbsp;&nbsp;&nbsp;&nbsp;通话时长:{this.isTime(this.state.info.callDuration)}</div>
             <Spin spinning={this.state.loading}>
             <Spin spinning={this.state.loading}>
               <Table
               <Table
                 size="middle"
                 size="middle"

+ 24 - 33
js/component/manageCenter/set/userManagementS/newUser.jsx

@@ -162,6 +162,7 @@ const Newuser = Form.create()(React.createClass({
           managerId: this.state.managerId,
           managerId: this.state.managerId,
           expenseSuperExamine: this.state.expenseSuperExamine, // 报销是否需要上级审核
           expenseSuperExamine: this.state.expenseSuperExamine, // 报销是否需要上级审核
           publicCarbonCopy: this.state.publicCarbonCopy,// 公出抄送
           publicCarbonCopy: this.state.publicCarbonCopy,// 公出抄送
+          callNo: this.state.callNo, // 外呼编号
         }),
         }),
         publicReviewerIds: getNewArray(this.state.Business, "reviewerId").toString(),// 公出审核
         publicReviewerIds: getNewArray(this.state.Business, "reviewerId").toString(),// 公出审核
         assistReviewerIds: getNewArray(this.state.Coorder, "reviewerId").toString(),// 协单审核
         assistReviewerIds: getNewArray(this.state.Coorder, "reviewerId").toString(),// 协单审核
@@ -286,6 +287,7 @@ const Newuser = Form.create()(React.createClass({
             expenseSuperExamine: thisdata.expenseSuperExamine, // 报销是否需要上级主管审核
             expenseSuperExamine: thisdata.expenseSuperExamine, // 报销是否需要上级主管审核
             publicCarbonCopy: thisdata.publicCarbonCopy, // 公出抄送
             publicCarbonCopy: thisdata.publicCarbonCopy, // 公出抄送
             publicCarbonCopyName: thisdata.publicCarbonCopyName,
             publicCarbonCopyName: thisdata.publicCarbonCopyName,
+            callNo:thisdata.callNo, // 外呼编号
           });
           });
         }.bind(this),
         }.bind(this),
       }).always(function () {
       }).always(function () {
@@ -785,40 +787,29 @@ const Newuser = Form.create()(React.createClass({
                   </FormItem>
                   </FormItem>
                 </div>
                 </div>
 
 
-                {/* <FormItem className="half-item"
-                  {...formItemLayout}
-                  label="协单审核"
-                >
-                  <StaffSearch
-                    valueName={this.state.publicCarbonCopyName}
-                    placeholder="输入名称"
-                    onBlurText={e => {
-                      this.setState({
-                        publicCarbonCopyName: e.title
-                      })
-                    }}
-                    onBlurChange={(obj) => {
-                      this.setState({
-                        publicCarbonCopy: obj.value,
-                      })
-                    }}
-                  />
-                </FormItem> */}
-
-                <FormItem className="half-item"
-                  {...formItemLayout}
-                  label="业务员"
-                >
-                  <Select
-                    placeholder="请选择"
-                    value={this.state.publicPurview}
-                    style={{ width: '200px' }}
-                    onChange={(e) => { this.setState({ publicPurview: e }) }}
+                <div className='clearfix'>
+                  <FormItem className="half-item"
+                    {...formItemLayout}
+                    label="业务员"
                   >
                   >
-                    <Select.Option value={0} >否</Select.Option>
-                    <Select.Option value={1} >是</Select.Option>
-                  </Select>
-                </FormItem>
+                    <Select
+                      placeholder="请选择"
+                      value={this.state.publicPurview}
+                      style={{ width: '200px' }}
+                      onChange={(e) => { this.setState({ publicPurview: e }) }}
+                    >
+                      <Select.Option value={0} >否</Select.Option>
+                      <Select.Option value={1} >是</Select.Option>
+                    </Select>
+                  </FormItem>
+
+                  <FormItem className="half-item"
+                    {...formItemLayout}
+                    label="外呼编号" >
+                    <Input placeholder="请输入外呼编号" style={{ width: '200px' }} value={this.state.callNo}
+                      onChange={(e) => { this.setState({ callNo: e.target.value }) }} />
+                  </FormItem>
+                </div>
 
 
                 <div className='clearfix'>
                 <div className='clearfix'>
                   <FormItem className="half-item"
                   <FormItem className="half-item"

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "afanti",
   "name": "afanti",
-  "version": "1.3.28",
+  "version": "1.3.29",
   "description": "",
   "description": "",
   "main": "index.js",
   "main": "index.js",
   "scripts": {
   "scripts": {