diff --git a/static/ivr/index.js b/static/ivr/index.js
new file mode 100644
index 0000000..da068a9
--- /dev/null
+++ b/static/ivr/index.js
@@ -0,0 +1,220 @@
+/* eslint-disable */
+function OnConnect_cb() {
+ showQueueStatusTitle
+ showTitle('已连接')
+ buttonSwitch('btnLogin')
+ return true
+}
+function OnDisconnect_cb() {
+ showTitle('连接已断开')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+ clearInterval(web_hearbeartID)
+}
+function OnLoginSuccess_cb() {
+ showTitle('登录成功')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut')
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnDial')
+ buttonSwitch('btnAgentList')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+ buttonSwitch('btnVersion')
+ buttonSwitch('btnGetExtension')
+ buttonSwitch('btnGetAgentStaffid')
+ buttonSwitch('btnGetAgentName')
+ buttonSwitch('btnGetSkill')
+ buttonSwitch('btnGetNumber')
+ buttonSwitch('btnGetBusyState')
+ buttonSwitch('btnGetAgentState')
+ buttonSwitch('btnGetCallState')
+ buttonSwitch('btnGetRegState')
+ buttonSwitch('btnInject')
+}
+
+function OnLoginFail_cb(result) {
+ showTitle(result)
+ web_extension = null
+ web_agentStaffid = null
+ web_agentName = null
+ web_skill = null
+ buttonSwitch('btnLogin')
+}
+function OnErrorNotice_cb(resultText) {
+ alert(resultText)
+}
+function OnLogOutSuccess_cb() {
+ showTitle('注销登录成功')
+
+ buttonSwitch('btnLogin')
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+}
+function extensionList_cb(list) {
+ alert(list)
+}
+function OnIncommingRing_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入振铃,通话编号[' + callid + '],随路数据[' + data + ']')
+}
+function OnIncommingAnswer_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入通话,通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnOutbound_cb(phone, callid, province, city, isp) {
+ showTitle('外呼 [' + phone + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnHangup_cb() {
+ showTitle('通话挂断')
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnHangUp', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+
+ buttonSwitch('btnBusy')
+}
+function OnBusy_cb(reason) {
+ showTitle('忙碌[' + reason + ']')
+
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnFree_cb() {
+ showTitle('空闲')
+
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+}
+function OnOutboundRinging_cb(number, callid) {
+ showTitle('外呼振铃 [' + number + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnStatusChanged_cb(reg, call, agent, busy, number) {
+ showStatusChangedTitle('分机状态 [' + reg + '],通话状态[' + call + '],座席状态[' + agent + '],置忙原因[' + busy + '],对方号码[' + number + ']')
+}
+function OnCallStatus_cb(call, number) {
+ showCallStatusTitle('通话状态[' + call + '],对方号码[' + number + ']')
+}
+function OnQueueStatusChanged_cb(idle, agent, guest, queue) {
+ showQueueStatusTitle('队列:' + queue + ';坐席数:' + agent + ';空闲坐席数:' + idle + ';队列排队数' + guest)
+}
+
+/**
+ * 显示设置状态标题
+*/
+function showTitle(title) {
+ document.getElementById('div_state').innerHTML = '
状态:' + title + '
'
+}
+function showStatusChangedTitle(title) {
+ document.getElementById('div_statusChanged').innerHTML = '状态改变:' + title + '
'
+}
+function showCallStatusTitle(title) {
+ document.getElementById('div_callStatus').innerHTML = '通话状态:' + title + '
'
+}
+function showQueueStatusTitle(title) {
+ document.getElementById('div_queueStatus').innerHTML = '队列状态:' + title + '
'
+}
+/**
+ * 切换按钮可用状态
+ * @param {String} id 按钮id
+ * @param {String} able 是否启用(可选),空或true时为启用,false为停用
+ */
+function buttonSwitch(id, able) {
+ if (able == null) { able = true }
+ document.getElementById(id).disabled = !able
+}
diff --git a/static/ivr/index.js b/static/ivr/index.js
new file mode 100644
index 0000000..da068a9
--- /dev/null
+++ b/static/ivr/index.js
@@ -0,0 +1,220 @@
+/* eslint-disable */
+function OnConnect_cb() {
+ showQueueStatusTitle
+ showTitle('已连接')
+ buttonSwitch('btnLogin')
+ return true
+}
+function OnDisconnect_cb() {
+ showTitle('连接已断开')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+ clearInterval(web_hearbeartID)
+}
+function OnLoginSuccess_cb() {
+ showTitle('登录成功')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut')
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnDial')
+ buttonSwitch('btnAgentList')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+ buttonSwitch('btnVersion')
+ buttonSwitch('btnGetExtension')
+ buttonSwitch('btnGetAgentStaffid')
+ buttonSwitch('btnGetAgentName')
+ buttonSwitch('btnGetSkill')
+ buttonSwitch('btnGetNumber')
+ buttonSwitch('btnGetBusyState')
+ buttonSwitch('btnGetAgentState')
+ buttonSwitch('btnGetCallState')
+ buttonSwitch('btnGetRegState')
+ buttonSwitch('btnInject')
+}
+
+function OnLoginFail_cb(result) {
+ showTitle(result)
+ web_extension = null
+ web_agentStaffid = null
+ web_agentName = null
+ web_skill = null
+ buttonSwitch('btnLogin')
+}
+function OnErrorNotice_cb(resultText) {
+ alert(resultText)
+}
+function OnLogOutSuccess_cb() {
+ showTitle('注销登录成功')
+
+ buttonSwitch('btnLogin')
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+}
+function extensionList_cb(list) {
+ alert(list)
+}
+function OnIncommingRing_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入振铃,通话编号[' + callid + '],随路数据[' + data + ']')
+}
+function OnIncommingAnswer_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入通话,通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnOutbound_cb(phone, callid, province, city, isp) {
+ showTitle('外呼 [' + phone + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnHangup_cb() {
+ showTitle('通话挂断')
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnHangUp', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+
+ buttonSwitch('btnBusy')
+}
+function OnBusy_cb(reason) {
+ showTitle('忙碌[' + reason + ']')
+
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnFree_cb() {
+ showTitle('空闲')
+
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+}
+function OnOutboundRinging_cb(number, callid) {
+ showTitle('外呼振铃 [' + number + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnStatusChanged_cb(reg, call, agent, busy, number) {
+ showStatusChangedTitle('分机状态 [' + reg + '],通话状态[' + call + '],座席状态[' + agent + '],置忙原因[' + busy + '],对方号码[' + number + ']')
+}
+function OnCallStatus_cb(call, number) {
+ showCallStatusTitle('通话状态[' + call + '],对方号码[' + number + ']')
+}
+function OnQueueStatusChanged_cb(idle, agent, guest, queue) {
+ showQueueStatusTitle('队列:' + queue + ';坐席数:' + agent + ';空闲坐席数:' + idle + ';队列排队数' + guest)
+}
+
+/**
+ * 显示设置状态标题
+*/
+function showTitle(title) {
+ document.getElementById('div_state').innerHTML = '状态:' + title + '
'
+}
+function showStatusChangedTitle(title) {
+ document.getElementById('div_statusChanged').innerHTML = '状态改变:' + title + '
'
+}
+function showCallStatusTitle(title) {
+ document.getElementById('div_callStatus').innerHTML = '通话状态:' + title + '
'
+}
+function showQueueStatusTitle(title) {
+ document.getElementById('div_queueStatus').innerHTML = '队列状态:' + title + '
'
+}
+/**
+ * 切换按钮可用状态
+ * @param {String} id 按钮id
+ * @param {String} able 是否启用(可选),空或true时为启用,false为停用
+ */
+function buttonSwitch(id, able) {
+ if (able == null) { able = true }
+ document.getElementById(id).disabled = !able
+}
diff --git a/static/ivr/sapoOCX.js b/static/ivr/sapoOCX.js
new file mode 100644
index 0000000..c009aab
--- /dev/null
+++ b/static/ivr/sapoOCX.js
@@ -0,0 +1,284 @@
+/* eslint-disable */
+var sapoOcx = {
+}
+var webSocket = null
+sapoOcx.api = {
+ config: {
+ serverIp: '124.205.241.254', // CTI服务器地址
+ commuPort: 8081, // CTI服务器通讯端口
+ policyPort: 1209, // CTI服务器安全认证端口(不修改)
+ debug: true, // 调试模式
+ waitFlag: 10, // 加载通信组件重新加载次数
+ initFinish: false, // 初始化是否完成
+ callBackArray: [], // 事件通知回调函数
+ connectToServer: function(callback) {
+ if (!this.initFinish) {
+ this.initFinish = true
+ setTimeout('sapoOcx.api.config.connectToServer()', 200)
+ } else {
+ callback
+ // this.getOcx().initConnection(this.serverIp, this.commuPort)
+ }
+ },
+ getOcx: function() {
+ return socket.api
+ }
+ },
+ /**
+ * 设置调试运行模式
+ */
+ setDebugMode: function() {
+ this.config.debug = true
+ },
+ /**
+ * 设置事件通知函数
+ * @param {String} event 事件类型
+ * @param {String} funName 回调函数名
+ */
+ setCallBack: function(event, funName) {
+ if (!this.config.initFinish) {
+ this.config.callBackArray.push([event, funName])
+ } else {
+ this.config.getOcx().setCallBack(event, funName)
+ }
+ },
+ /**
+ * 连接到CTI服务器
+ * @param {String} server 服务器IP地址
+ * @param {String} port 服务端口(可选)
+ */
+ connect: function(server, port, callback) {
+ this.config.serverIp = server
+ if (port != null && port != '') { this.config.commuPort = port }
+ this.config.connectToServer(callback)
+ },
+ /**
+ * 坐席登录
+ * @param {String} agent 姓名
+ * @param {String} extension 分机号
+ * @param {String} queue 技能组
+ * @param {String} staffid 工号
+ * @param {String} skill 技能值
+ * @param {String} busyString 置忙原因
+ * @param {String} sectorId 部门id
+ * @param {String} sectorName 部门名称
+ * @param {String} autoAcw 自动话后
+ */
+ login: function(agent, extension, queue, staffid, skill, busyString, sectorId, sectorName, autoAcw, hearbeartInterval, domain, security) {
+ if (busyString == null) { busyString = '' }
+ if (sectorId == null) { sectorId = '' }
+ if (sectorName == null) { sectorName = '' }
+ if (autoAcw != '0' && autoAcw != '1' && autoAcw != '2' && autoAcw != '3') {
+ autoAcw = '0'
+ }
+ if (domain == null) { domain = '' }
+ if (security == null) { security = '' }
+ if (hearbeartInterval == null || hearbeartInterval <= 0) {
+ hearbeartInterval = 0
+ }
+ web_hearbeartInterval = hearbeartInterval
+ web_extension = extension
+ web_agentStaffid = staffid
+ web_agentName = agent
+ web_skill = skill
+ this.config.getOcx().login(agent, extension, queue, staffid, skill, busyString, sectorId, sectorName, autoAcw, domain, security)
+ },
+ /**
+ * 注销登录
+ */
+ loginOut: function() {
+ this.config.getOcx().loginOut()
+ },
+ /**
+ * 获取分机/坐席列表
+ * @param {String} type 获取类型
+ * all:全部分机/idle:空闲分机/agent:全部已登录坐席/agentidle:空闲坐席
+ * @param {String} secid
+ * @param {String} group
+ */
+ getExtenList: function(type, secid, queue) {
+ if (type == null || type == '') { type = 'all' }
+ if (secid == null) { secid = '' }
+ if (queue == null) { queue = '' }
+ this.config.getOcx().getExtenList(type, secid, queue)
+ },
+ /**
+ * 外拨
+ * @param {String} phone 呼叫号码
+ */
+ dial: function(phone, cusid, cusname, proid, proname) {
+ if (cusid == null) { cusid = '' }
+ if (cusname == null) { cusname = '' }
+ if (proid == null) { proid = '' }
+ if (proname == null) { proname = '' }
+ this.config.getOcx().dial(phone, cusid, cusname, proid, proname)
+ },
+ /**
+ * 保持
+ */
+ hold: function() {
+ this.config.getOcx().hold()
+ },
+ /**
+ * 解除保持
+ */
+ unhold: function() {
+ this.config.getOcx().unhold()
+ },
+ /**
+ * 挂机
+ */
+ hangup: function() {
+ this.config.getOcx().hangup()
+ },
+ /**
+ * 置闲
+ */
+ free: function() {
+ this.config.getOcx().idle()
+ },
+ /**
+ * 置忙
+ * @param {String} busy 置忙原因
+ */
+ busy: function(busy) {
+ if (busy == null) { busy = '' }
+ this.config.getOcx().busy(busy)
+ },
+ /**
+ * 三方
+ * @param {String} phone 三方号码
+ */
+ threeWay: function(phone) {
+ this.config.getOcx().threeWay(phone)
+ },
+ /**
+ * 转接
+ * @param {String} phone 转接号码
+ */
+ transfer: function(phone) {
+ this.config.getOcx().transfer(phone)
+ },
+ /**
+ * 磋商转接
+ * @param {String} phone 转接号码
+ */
+ transferC: function(phone) {
+ this.config.getOcx().transferC(phone)
+ },
+ /**
+ * 转接组
+ * @param {String} queue 组号
+ */
+ transferQueue: function(queue) {
+ this.config.getOcx().transferQueue(queue)
+ },
+ /**
+ * 转接IVR节点
+ * @param {String} ivr 节点编号
+ */
+ transferIvr: function(ivr) {
+ this.config.getOcx().transferIvr(ivr)
+ },
+ /**
+ * 抢接(盲抢)
+ */
+ pickUp: function() {
+ this.config.getOcx().pickUp()
+ },
+ /**
+ * 抢接分机
+ * @param {String} exten 分机号
+ */
+ extenPickUp: function(exten) {
+ this.config.getOcx().extenPickUp(exten)
+ },
+ /**
+ * 组抢接
+ * @param {String} group 组号
+ */
+ groupPickUp: function(group) {
+ this.config.getOcx().groupPickUp(group)
+ },
+ /**
+ * 分机监听
+ * @param {String} extension 分机号
+ */
+ spy: function(extension) {
+ this.config.getOcx().spy(extension)
+ },
+ /**
+ * 组监听
+ * @param {String} group 组
+ */
+ groupSpy: function(group) {
+ this.config.getOcx().groupSpy(group)
+ },
+ /**
+ * 版本信息
+ */
+ getVersion: function() {
+ return web_version
+ },
+ /**
+ * 获取当前分机号码
+ */
+ getExtension: function() {
+ return web_extension
+ },
+ /**
+ * 获取当前座席工号
+ */
+ getAgentStaffid: function() {
+ return web_agentStaffid
+ },
+ /**
+ * 获取当前座席姓名
+ */
+ getAgentName: function() {
+ return web_agentName
+ },
+ /**
+ * 获取当前座席技能组
+ */
+ getSkill: function() {
+ return web_skill
+ },
+ /**
+ * 获取当前通话号码
+ */
+ getNumber: function() {
+ return web_number
+ },
+ /**
+ * 获取置忙原因
+ */
+ getBusyState: function() {
+ return web_busyStatue
+ },
+ /**
+ * 获取坐席注册状态
+ */
+ getAgentState: function() {
+ return web_agentStatue
+ },
+ /**
+ * 获取通话状态
+ */
+ getCallState: function() {
+ return web_callStatue
+ },
+ /**
+ * 获取话机注册状态
+ */
+ getRegState: function() {
+ return web_reg
+ },
+ /**
+ * 取消IVR监听
+ */
+ Inject: function() {
+ this.config.getOcx().Inject()
+ }
+}
+
diff --git a/static/ivr/index.js b/static/ivr/index.js
new file mode 100644
index 0000000..da068a9
--- /dev/null
+++ b/static/ivr/index.js
@@ -0,0 +1,220 @@
+/* eslint-disable */
+function OnConnect_cb() {
+ showQueueStatusTitle
+ showTitle('已连接')
+ buttonSwitch('btnLogin')
+ return true
+}
+function OnDisconnect_cb() {
+ showTitle('连接已断开')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+ clearInterval(web_hearbeartID)
+}
+function OnLoginSuccess_cb() {
+ showTitle('登录成功')
+ buttonSwitch('btnLogin', false)
+ buttonSwitch('btnLogOut')
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnDial')
+ buttonSwitch('btnAgentList')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+ buttonSwitch('btnVersion')
+ buttonSwitch('btnGetExtension')
+ buttonSwitch('btnGetAgentStaffid')
+ buttonSwitch('btnGetAgentName')
+ buttonSwitch('btnGetSkill')
+ buttonSwitch('btnGetNumber')
+ buttonSwitch('btnGetBusyState')
+ buttonSwitch('btnGetAgentState')
+ buttonSwitch('btnGetCallState')
+ buttonSwitch('btnGetRegState')
+ buttonSwitch('btnInject')
+}
+
+function OnLoginFail_cb(result) {
+ showTitle(result)
+ web_extension = null
+ web_agentStaffid = null
+ web_agentName = null
+ web_skill = null
+ buttonSwitch('btnLogin')
+}
+function OnErrorNotice_cb(resultText) {
+ alert(resultText)
+}
+function OnLogOutSuccess_cb() {
+ showTitle('注销登录成功')
+
+ buttonSwitch('btnLogin')
+ buttonSwitch('btnLogOut', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnAgentList', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+ buttonSwitch('btnVersion', false)
+ buttonSwitch('btnGetExtension', false)
+ buttonSwitch('btnGetAgentStaffid', false)
+ buttonSwitch('btnGetAgentName', false)
+ buttonSwitch('btnGetSkill', false)
+ buttonSwitch('btnGetNumber', false)
+ buttonSwitch('btnGetBusyState', false)
+ buttonSwitch('btnGetAgentState', false)
+ buttonSwitch('btnGetCallState', false)
+ buttonSwitch('btnGetRegState', false)
+}
+function extensionList_cb(list) {
+ alert(list)
+}
+function OnIncommingRing_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入振铃,通话编号[' + callid + '],随路数据[' + data + ']')
+}
+function OnIncommingAnswer_cb(phone, callid, autodial, province, city, isp, data) {
+ showTitle('[' + phone + '] 呼入通话,通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnOutbound_cb(phone, callid, province, city, isp) {
+ showTitle('外呼 [' + phone + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHold')
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay')
+ buttonSwitch('btnTransfer')
+ buttonSwitch('btnTransferQueue')
+ buttonSwitch('btnTransferIvr')
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+}
+function OnHangup_cb() {
+ showTitle('通话挂断')
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnHangUp', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+
+ buttonSwitch('btnBusy')
+}
+function OnBusy_cb(reason) {
+ showTitle('忙碌[' + reason + ']')
+
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnIdle')
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnFree_cb() {
+ showTitle('空闲')
+
+ buttonSwitch('btnBusy')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnDial')
+ buttonSwitch('btnPickUp')
+ buttonSwitch('btnExtenPickUp')
+ buttonSwitch('btnGroupPickUp')
+ buttonSwitch('btnSpy')
+ buttonSwitch('btnGroupSpy')
+}
+function OnOutboundRinging_cb(number, callid) {
+ showTitle('外呼振铃 [' + number + '],通话编号[' + callid + ']')
+
+ buttonSwitch('btnHangUp')
+ buttonSwitch('btnIdle', false)
+ buttonSwitch('btnBusy', false)
+ buttonSwitch('btnHold', false)
+ buttonSwitch('btnUnhold', false)
+ buttonSwitch('btnDial', false)
+ buttonSwitch('btnThreeWay', false)
+ buttonSwitch('btnTransfer', false)
+ buttonSwitch('btnTransferQueue', false)
+ buttonSwitch('btnTransferIvr', false)
+ buttonSwitch('btnPickUp', false)
+ buttonSwitch('btnExtenPickUp', false)
+ buttonSwitch('btnGroupPickUp', false)
+ buttonSwitch('btnSpy', false)
+ buttonSwitch('btnGroupSpy', false)
+}
+function OnStatusChanged_cb(reg, call, agent, busy, number) {
+ showStatusChangedTitle('分机状态 [' + reg + '],通话状态[' + call + '],座席状态[' + agent + '],置忙原因[' + busy + '],对方号码[' + number + ']')
+}
+function OnCallStatus_cb(call, number) {
+ showCallStatusTitle('通话状态[' + call + '],对方号码[' + number + ']')
+}
+function OnQueueStatusChanged_cb(idle, agent, guest, queue) {
+ showQueueStatusTitle('队列:' + queue + ';坐席数:' + agent + ';空闲坐席数:' + idle + ';队列排队数' + guest)
+}
+
+/**
+ * 显示设置状态标题
+*/
+function showTitle(title) {
+ document.getElementById('div_state').innerHTML = '状态:' + title + '
'
+}
+function showStatusChangedTitle(title) {
+ document.getElementById('div_statusChanged').innerHTML = '状态改变:' + title + '
'
+}
+function showCallStatusTitle(title) {
+ document.getElementById('div_callStatus').innerHTML = '通话状态:' + title + '
'
+}
+function showQueueStatusTitle(title) {
+ document.getElementById('div_queueStatus').innerHTML = '队列状态:' + title + '
'
+}
+/**
+ * 切换按钮可用状态
+ * @param {String} id 按钮id
+ * @param {String} able 是否启用(可选),空或true时为启用,false为停用
+ */
+function buttonSwitch(id, able) {
+ if (able == null) { able = true }
+ document.getElementById(id).disabled = !able
+}
diff --git a/static/ivr/sapoOCX.js b/static/ivr/sapoOCX.js
new file mode 100644
index 0000000..c009aab
--- /dev/null
+++ b/static/ivr/sapoOCX.js
@@ -0,0 +1,284 @@
+/* eslint-disable */
+var sapoOcx = {
+}
+var webSocket = null
+sapoOcx.api = {
+ config: {
+ serverIp: '124.205.241.254', // CTI服务器地址
+ commuPort: 8081, // CTI服务器通讯端口
+ policyPort: 1209, // CTI服务器安全认证端口(不修改)
+ debug: true, // 调试模式
+ waitFlag: 10, // 加载通信组件重新加载次数
+ initFinish: false, // 初始化是否完成
+ callBackArray: [], // 事件通知回调函数
+ connectToServer: function(callback) {
+ if (!this.initFinish) {
+ this.initFinish = true
+ setTimeout('sapoOcx.api.config.connectToServer()', 200)
+ } else {
+ callback
+ // this.getOcx().initConnection(this.serverIp, this.commuPort)
+ }
+ },
+ getOcx: function() {
+ return socket.api
+ }
+ },
+ /**
+ * 设置调试运行模式
+ */
+ setDebugMode: function() {
+ this.config.debug = true
+ },
+ /**
+ * 设置事件通知函数
+ * @param {String} event 事件类型
+ * @param {String} funName 回调函数名
+ */
+ setCallBack: function(event, funName) {
+ if (!this.config.initFinish) {
+ this.config.callBackArray.push([event, funName])
+ } else {
+ this.config.getOcx().setCallBack(event, funName)
+ }
+ },
+ /**
+ * 连接到CTI服务器
+ * @param {String} server 服务器IP地址
+ * @param {String} port 服务端口(可选)
+ */
+ connect: function(server, port, callback) {
+ this.config.serverIp = server
+ if (port != null && port != '') { this.config.commuPort = port }
+ this.config.connectToServer(callback)
+ },
+ /**
+ * 坐席登录
+ * @param {String} agent 姓名
+ * @param {String} extension 分机号
+ * @param {String} queue 技能组
+ * @param {String} staffid 工号
+ * @param {String} skill 技能值
+ * @param {String} busyString 置忙原因
+ * @param {String} sectorId 部门id
+ * @param {String} sectorName 部门名称
+ * @param {String} autoAcw 自动话后
+ */
+ login: function(agent, extension, queue, staffid, skill, busyString, sectorId, sectorName, autoAcw, hearbeartInterval, domain, security) {
+ if (busyString == null) { busyString = '' }
+ if (sectorId == null) { sectorId = '' }
+ if (sectorName == null) { sectorName = '' }
+ if (autoAcw != '0' && autoAcw != '1' && autoAcw != '2' && autoAcw != '3') {
+ autoAcw = '0'
+ }
+ if (domain == null) { domain = '' }
+ if (security == null) { security = '' }
+ if (hearbeartInterval == null || hearbeartInterval <= 0) {
+ hearbeartInterval = 0
+ }
+ web_hearbeartInterval = hearbeartInterval
+ web_extension = extension
+ web_agentStaffid = staffid
+ web_agentName = agent
+ web_skill = skill
+ this.config.getOcx().login(agent, extension, queue, staffid, skill, busyString, sectorId, sectorName, autoAcw, domain, security)
+ },
+ /**
+ * 注销登录
+ */
+ loginOut: function() {
+ this.config.getOcx().loginOut()
+ },
+ /**
+ * 获取分机/坐席列表
+ * @param {String} type 获取类型
+ * all:全部分机/idle:空闲分机/agent:全部已登录坐席/agentidle:空闲坐席
+ * @param {String} secid
+ * @param {String} group
+ */
+ getExtenList: function(type, secid, queue) {
+ if (type == null || type == '') { type = 'all' }
+ if (secid == null) { secid = '' }
+ if (queue == null) { queue = '' }
+ this.config.getOcx().getExtenList(type, secid, queue)
+ },
+ /**
+ * 外拨
+ * @param {String} phone 呼叫号码
+ */
+ dial: function(phone, cusid, cusname, proid, proname) {
+ if (cusid == null) { cusid = '' }
+ if (cusname == null) { cusname = '' }
+ if (proid == null) { proid = '' }
+ if (proname == null) { proname = '' }
+ this.config.getOcx().dial(phone, cusid, cusname, proid, proname)
+ },
+ /**
+ * 保持
+ */
+ hold: function() {
+ this.config.getOcx().hold()
+ },
+ /**
+ * 解除保持
+ */
+ unhold: function() {
+ this.config.getOcx().unhold()
+ },
+ /**
+ * 挂机
+ */
+ hangup: function() {
+ this.config.getOcx().hangup()
+ },
+ /**
+ * 置闲
+ */
+ free: function() {
+ this.config.getOcx().idle()
+ },
+ /**
+ * 置忙
+ * @param {String} busy 置忙原因
+ */
+ busy: function(busy) {
+ if (busy == null) { busy = '' }
+ this.config.getOcx().busy(busy)
+ },
+ /**
+ * 三方
+ * @param {String} phone 三方号码
+ */
+ threeWay: function(phone) {
+ this.config.getOcx().threeWay(phone)
+ },
+ /**
+ * 转接
+ * @param {String} phone 转接号码
+ */
+ transfer: function(phone) {
+ this.config.getOcx().transfer(phone)
+ },
+ /**
+ * 磋商转接
+ * @param {String} phone 转接号码
+ */
+ transferC: function(phone) {
+ this.config.getOcx().transferC(phone)
+ },
+ /**
+ * 转接组
+ * @param {String} queue 组号
+ */
+ transferQueue: function(queue) {
+ this.config.getOcx().transferQueue(queue)
+ },
+ /**
+ * 转接IVR节点
+ * @param {String} ivr 节点编号
+ */
+ transferIvr: function(ivr) {
+ this.config.getOcx().transferIvr(ivr)
+ },
+ /**
+ * 抢接(盲抢)
+ */
+ pickUp: function() {
+ this.config.getOcx().pickUp()
+ },
+ /**
+ * 抢接分机
+ * @param {String} exten 分机号
+ */
+ extenPickUp: function(exten) {
+ this.config.getOcx().extenPickUp(exten)
+ },
+ /**
+ * 组抢接
+ * @param {String} group 组号
+ */
+ groupPickUp: function(group) {
+ this.config.getOcx().groupPickUp(group)
+ },
+ /**
+ * 分机监听
+ * @param {String} extension 分机号
+ */
+ spy: function(extension) {
+ this.config.getOcx().spy(extension)
+ },
+ /**
+ * 组监听
+ * @param {String} group 组
+ */
+ groupSpy: function(group) {
+ this.config.getOcx().groupSpy(group)
+ },
+ /**
+ * 版本信息
+ */
+ getVersion: function() {
+ return web_version
+ },
+ /**
+ * 获取当前分机号码
+ */
+ getExtension: function() {
+ return web_extension
+ },
+ /**
+ * 获取当前座席工号
+ */
+ getAgentStaffid: function() {
+ return web_agentStaffid
+ },
+ /**
+ * 获取当前座席姓名
+ */
+ getAgentName: function() {
+ return web_agentName
+ },
+ /**
+ * 获取当前座席技能组
+ */
+ getSkill: function() {
+ return web_skill
+ },
+ /**
+ * 获取当前通话号码
+ */
+ getNumber: function() {
+ return web_number
+ },
+ /**
+ * 获取置忙原因
+ */
+ getBusyState: function() {
+ return web_busyStatue
+ },
+ /**
+ * 获取坐席注册状态
+ */
+ getAgentState: function() {
+ return web_agentStatue
+ },
+ /**
+ * 获取通话状态
+ */
+ getCallState: function() {
+ return web_callStatue
+ },
+ /**
+ * 获取话机注册状态
+ */
+ getRegState: function() {
+ return web_reg
+ },
+ /**
+ * 取消IVR监听
+ */
+ Inject: function() {
+ this.config.getOcx().Inject()
+ }
+}
+
diff --git a/static/ivr/webSocket.js b/static/ivr/webSocket.js
new file mode 100644
index 0000000..5616729
--- /dev/null
+++ b/static/ivr/webSocket.js
@@ -0,0 +1,441 @@
+/**
+ * webSocket支持类,和服务器通信
+ */
+/* eslint-disable */
+var socket = {}
+var webSocket = null
+var web_version = '2.17.0505'
+var web_extension = null
+var web_agentStaffid = null
+var web_agentName = null
+var web_skill = null
+var web_reg = null
+var web_callStatue = null
+var web_agentStatue = null
+var web_busyStatue = null
+var web_number = null
+var web_hearbeatCount = 0
+var web_hearbeartInterval = 0
+var web_hearbeartID = 0
+socket.api = {
+ // 初始创建webSocket连接
+ initConnection: function(ip, port) {
+ var wsUrl = 'ws://' + ip + ':' + port + '/spcc/cti'
+ webSocket = new WebSocket(wsUrl)
+ webSocket.onopen = function(event) {
+ OnConnect_cb()
+ console.log('connection success!')
+ }
+ webSocket.onclose = function(event) {
+ OnDisconnect_cb()
+ web_extension = null
+ web_agentStaffid = null
+ web_agentName = null
+ web_skill = null
+
+ web_reg = null
+ web_callStatue = null
+ web_agentStatue = null
+ web_busyStatue = null
+ web_number = null
+
+ clearInterval(web_hearbeartID)
+
+ console.log('quit success!')
+ }
+ // 发送一个消息
+ var busy = ''
+ webSocket.onmessage = function(event) {
+ var obj = event.data
+ var data = obj.split('\n')
+ var object = {}
+ data.forEach(function(value) {
+ if (value != '') {
+ var objData = value.split(':')
+ object[objData[0]] = objData[1]
+ }
+ })
+ // console.dir(object);
+ var messageType = object.messageType
+ if (messageType == 'event') {
+ showConsole('2', obj)
+ var name = object.name
+ if (name == 'agent status') {
+
+ }
+ if (name == 'call status') {
+ OnCallStatus_cb(object.call, object.number)
+ }
+ if (name == 'outbound ringing') {
+ OnOutboundRinging_cb(object.number, object.callid)
+ }
+ if (name == 'outbound answered') {
+ OnOutbound_cb(object.number, object.callid, object.province, object.city, object.isp)
+ }
+ if (name == 'incomming ringing') {
+ OnIncommingRing_cb(object.number, object.callid, object.autodial, object.province, object.city, object.isp, object.data)
+ // alert(object.data);
+ }
+ if (name == 'incomming answered') {
+ OnIncommingAnswer_cb(object.number, object.callid, object.autodial, object.province, object.city, object.isp, object.data)
+ }
+ if (name == 'hangup') {
+ OnHangup_cb()
+ OnFree_cb()
+ }
+ if (name == 'status changed') {
+ busy = object.busy
+ var number = ''
+ if (object.number) {
+ number = object.number
+ }
+ OnStatusChanged_cb(object.reg, object.call, object.agent, object.busy, number)
+ web_reg = object.reg
+ web_callStatue = object.call
+ web_agentStatue = object.agent
+ web_busyStatue = object.busy
+ web_number = object.number
+ }
+ if (name == 'queue status') {
+ OnQueueStatusChanged_cb(object.idle, object.agent, object.guest, object.queue)
+ }
+ if (name == 'busy status') {
+ busy = object.busy
+ if (busy == '') {
+ OnFree_cb()
+ } else {
+ OnBusy_cb(busy)
+ }
+ }
+ } else if (messageType == 'heartbeat response') {
+ showConsole('3', obj)
+ web_hearbeatCount = 0
+ } else if (messageType == 'command response') {
+ showConsole('3', obj)
+ var command = object.command
+ if (command == 'login') {
+ if (object.success == 'true') {
+ OnLoginSuccess_cb()
+ if (web_hearbeartInterval > 0) {
+ web_hearbeartID = setInterval('sendHearbeatMessage()', web_hearbeartInterval * 1000)
+ }
+ if (busy == '') {
+ OnFree_cb()
+ } else {
+ OnBusy_cb(busy)
+ }
+ } else {
+ OnLoginFail_cb(object.resultText)
+ }
+ }
+ if (command == 'logout') {
+ if (object.success) {
+ OnLogOutSuccess_cb()
+ web_extension = null
+ web_agentStaffid = null
+ web_agentName = null
+ web_skill = null
+
+ web_reg = null
+ web_callStatue = null
+ web_agentStatue = null
+ web_busyStatue = null
+ web_number = null
+
+ clearInterval(web_hearbeartID)
+ }
+ }
+ if (command == 'getExtensionList') {
+ if (object.success) {
+ var test = object.resultText
+ var index = test.indexOf(',')
+ var message = ''
+ message += '['
+ if (index > 0) {
+ var messageList = test.split(',')
+ console.log(messageList.length)
+ for (var i = 0; i < messageList.length; i++) {
+ var tList = messageList[i].split('|')
+ if (i == messageList.length - 1) {
+ message += '{exten:' + tList[0] + ',name:' + tList[1] + ',loginId:' + tList[2] + ',sector:' + tList[3] + ',group:' + tList[4] + ',state:' +
+ tList[5] + ',busy:' + tList[6] + '}'
+ } else {
+ message += '{exten:' + tList[0] + ',name:' + tList[1] + ',loginId:' + tList[2] + ',sector:' + tList[3] + ',group:' + tList[4] + ',state:' +
+ tList[5] + ',busy:' + tList[6] + '},'
+ }
+ }
+ } else {
+ var testList = test.split('|')
+ message += '{exten:' + testList[0] + ',name:' + testList[1] + ',loginId:' + testList[2] + ',sector:' + testList[3] + ',group:' + testList[4] + ',state:' +
+ testList[5] + ',busy:' + testList[6] + '}'
+ }
+ message += ']'
+ extensionList_cb(message)
+ }
+ }
+ }
+ }
+ webSocket.onerror = function(event) {
+ console.log(event)
+ }
+ },
+ /**
+ * 坐席登录
+ * @param {String} agent 姓名
+ * @param {String} extension 分机号
+ * @param {String} queue 技能组
+ * @param {String} staffid 工号
+ * @param {String} skill 技能值
+ * @param {String} busyString 置忙原因
+ * @param {String} sectorId 部门id
+ * @param {String} sectorName 部门名称
+ * @param {String} autoAcw 自动话后
+ */
+ login: function(agent, extension, queue, staffid, skill, busyString, sectorId, sectorName, autoAcw, domain, security) {
+ var strSend = ''
+ strSend = 'command:login\nagent:' + agent + '\nextension:' + extension +
+ '\nqueue:' + queue + '\nstaffid:' + staffid + '\nbusyString:' + busyString +
+ '\nskill:' + skill + '\nsecid:' + sectorId + '\nsecname:' + sectorName + '\nautoacw:' + autoAcw +
+ '\ndomain:' + domain + '\nsecurity:' + security + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 座席注销
+ */
+ loginOut: function() {
+ var strSend = ''
+ strSend = 'command:logout\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 保持
+ */
+ hold: function() {
+ var strSend = ''
+ strSend = 'command:hold\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 解除保持
+ */
+ unhold: function() {
+ var strSend = ''
+ strSend = 'command:unhold\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 挂机
+ */
+ hangup: function() {
+ var strSend = ''
+ strSend = 'command:hangup\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 获取座席列表
+ * @param type
+ * @param secid
+ * @param queue
+ */
+ getExtenList: function(type, secid, queue) {
+ var strSend = ''
+ strSend = 'command:getExtensionList\ntype:' + type + '\nsecid:' + secid + '\nqueue:' + queue + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 置闲
+ */
+ idle: function() {
+ var strSend = ''
+ strSend = 'command:idle\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 置忙
+ */
+ busy: function(reason) {
+ var strSend = ''
+ strSend = 'command:busy\nbusyString:' + reason + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 外呼
+ * @param phone
+ * @param cusid
+ * @param cusname
+ * @param proid
+ * @param proname
+ */
+ dial: function(phone, cusid, cusname, proid, proname) {
+ var strSend = ''
+ strSend = 'command:dial\ndialString:' + phone + '\ncusid:' + cusid + '\ncusname:' + cusname + '\nproid:' + proid + '\nproname:' + proname + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 三方
+ * @param phone
+ */
+ threeWay: function(phone) {
+ var strSend = ''
+ strSend = 'command:threeWay\ndialString:' + phone + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 转接分机
+ * @param phone
+ */
+ transfer: function(phone) {
+ var strSend = ''
+ strSend = 'command:transfer\ndialString:' + phone + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 磋商转接分机
+ * @param phone
+ */
+ transferC: function(phone) {
+ var strSend = ''
+ strSend = 'command:transfer\ndialString:' + phone + '\ntype:att' + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 转接组
+ * @param {String} queue 组号
+ */
+ transferQueue: function(queue) {
+ var strSend = ''
+ strSend = 'command:transferQueue\nqueue:' + queue + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 转接IVR节点
+ * @param {String} ivr 节点编号
+ */
+ transferIvr: function(ivr) {
+ var strSend = ''
+ strSend = 'command:transferIvr\nivr:' + ivr + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 组抢接
+ * @param {String} group 组号
+ */
+ groupPickUp: function(group) {
+ var strSend = ''
+ strSend = 'command:groupPickup\ngroup:' + group + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 抢接分机
+ * @param {String} exten 分机号
+ */
+ extenPickUp: function(exten) {
+ var strSend = ''
+ strSend = 'command:pickupExtension\nextension:' + exten + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 抢接(盲抢)
+ */
+ pickUp: function() {
+ var strSend = ''
+ strSend = 'command:pickup\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 分机监听
+ * @param {String} extension 分机号
+ */
+ spy: function(extension) {
+ var strSend = ''
+ strSend = 'command:spy\nextension:' + extension + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 组监听
+ * @param {String} group 组
+ */
+ groupSpy: function(group) {
+ var strSend = ''
+ strSend = 'command:groupSpy\ngroup:' + group + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ },
+ /**
+ * 取消IVR监听
+ */
+ Inject: function() {
+ var strSend = ''
+ strSend = 'command:Inject\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ }
+}
+function getTime() {
+ var myDate = new Date()
+ var time = myDate.getHours() + ':'
+ time += (myDate.getMinutes() < 10 ? '0' : '') + myDate.getMinutes() + ':'
+ time += (myDate.getSeconds() < 10 ? '0' : '') + myDate.getSeconds()
+ return '[' + time + ']'
+}
+function sendHearbeatMessage() {
+ if (web_hearbeatCount >= 3) {
+ webSocket.close()
+ /* OnDisconnect_cb();
+ web_extension=null;
+ web_agentStaffid=null;
+ web_agentName=null;
+ web_skill=null;
+
+ web_reg=null;
+ web_callStatue=null;
+ web_agentStatue=null;
+ web_busyStatue=null;
+ web_number=null;
+ web_hearbeatCount=0;*/
+ } else {
+ web_hearbeatCount = web_hearbeatCount + 1
+ var strSend = ''
+ strSend = 'command:heartbeat' + '\n\n'
+ showConsole('1', strSend)
+ webSocket.send(strSend)
+ }
+}
+/**
+ * 发送指令
+ * @param message
+ */
+function showConsole(num, message) {
+ if (sapoOcx.api.config.debug) {
+ message = message.replace(/\n/g, '|')
+ message = message.substring(0, message.length - 2)
+ if (num == '1') {
+ message = getTime() + '[发送指令]:{' + message + '}'
+ } else if (num == '2') {
+ message = getTime() + '[事件通知]:{' + message + '}'
+ } else if (num == '3') {
+ message = getTime() + '[指令响应]:{' + message + '}'
+ }
+
+ console.log(message)
+ }
+}
+