Нет описания

TelephoneDetails.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. var areaOneVal = helper.cookies.get("areaOneVal");
  2. var areaOneText = helper.cookies.get("areaOneText");
  3. // 如果浏览器不支持websocket,会使用这个flash自动模拟websocket协议,此过程对开发者透明
  4. WEB_SOCKET_SWF_LOCATION = "./js/websocket/WebSocketMain.swf";
  5. // 开启flash的websocket debug
  6. WEB_SOCKET_DEBUG = true;
  7. var ws, n = 0,
  8. timer;
  9. var lockReconnect = false; //避免重复连接
  10. var obj = {};
  11. var Statess;
  12. var cls = 0;
  13. var lasttime = new Date().getTime();
  14. var cons;
  15. var person = '';
  16. if(areaOneVal) {
  17. var areaOneVal = helper.cookies.get("areaOneVal");
  18. } else {
  19. var areaOneVal = "sqs12345"
  20. }
  21. //创建scoket连接
  22. function createWebSocket() {
  23. try {
  24. Connect();
  25. } catch(e) {
  26. reconnect();
  27. }
  28. }
  29. //连接
  30. function Connect() {
  31. // debugger
  32. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  33. ws.onopen = function() {
  34. console.log(new Date() + " " + "建立连接");
  35. cls = 0;
  36. lasttime = new Date().getTime();
  37. join()
  38. SayBusy()
  39. };
  40. //接收到消息的回调方法
  41. ws.onmessage = function(evt) {
  42. //如果获取到消息,心跳检测重置
  43. //拿到任何消息都说明当前连接是正常的
  44. //heartCheck.reset().start();
  45. var myDate = new Date();
  46. console.log(myDate + " receive " + evt.data);
  47. var data = JSON.parse(evt.data)[0];
  48. if(data) {
  49. var rlt = data.Result;
  50. var type = data.Type;
  51. if(rlt == true) {
  52. switch(type.toLowerCase()) {
  53. //case "heart": HeartBack(); break;//心跳
  54. case "login":
  55. LoginBack();
  56. break; //签入
  57. case "subscribecancel":
  58. SubScribeCancelBack();
  59. break; //停止监测
  60. case "agentstate":
  61. AgentStateBack(data);
  62. break; //坐席状态
  63. }
  64. } else {
  65. if(rlt == false) {
  66. $(".hwzt").text('操作失败!');
  67. } else {
  68. $(".hwzt").text(rlt);
  69. if(type.toLowerCase() == 'waitcount') {
  70. backstageQueue(data);
  71. }
  72. }
  73. }
  74. }
  75. };
  76. //连接关闭的回调方法
  77. ws.onclose = function(evt) {
  78. if(cls == 0) {
  79. cls = 1;
  80. $(".hwzt").text('连接关闭!');
  81. $("#top-search li i").removeClass("active");
  82. reconnect();
  83. }
  84. };
  85. //连接发生错误的回调方法
  86. ws.onerror = function(evt) {
  87. //产生异常
  88. $(".hwzt").text('连接出现异常!');
  89. console.log(ws);
  90. if(ws == null || ws.readyState != ws.OPEN) {
  91. console.log(new Date() + "开始重连");
  92. reconnect();
  93. }
  94. };
  95. }
  96. //重连
  97. function reconnect() {
  98. if(lockReconnect) return;
  99. lockReconnect = true;
  100. //没连接上会一直重连,设置延迟避免请求过多
  101. setTimeout(function() {
  102. console.log(new Date() + " " + "重连中……");
  103. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  104. lockReconnect = false;
  105. SayBusy()
  106. }, 2000);
  107. }
  108. //发送
  109. function Send() {
  110. if(ws.readyState != ws.OPEN) {
  111. //reconnect();
  112. }
  113. if(ws.readyState == ws.OPEN) {
  114. console.log(new Date() + " send " + JSON.stringify(obj));
  115. ws.send(JSON.stringify(obj));
  116. }
  117. }
  118. //心跳检测
  119. var heartCheck = {
  120. timeout: 25000, //25秒
  121. timeoutObj: null,
  122. serverTimeoutObj: null,
  123. reset: function() {
  124. clearTimeout(this.timeoutObj);
  125. clearTimeout(this.serverTimeoutObj);
  126. return this;
  127. },
  128. start: function() {
  129. var self = this;
  130. this.timeoutObj = setTimeout(function() {
  131. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  132. //onmessage拿到返回的心跳就说明连接正常
  133. obj.Type = "Heart";
  134. Send();
  135. self.serverTimeoutObj = setTimeout(function() { //如果超过一定时间还没重置,说明后端主动断开了
  136. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  137. }, self.timeout)
  138. }, this.timeout)
  139. }
  140. }
  141. // 签入
  142. function SayBusy() {
  143. obj.Type = "SayBusy";
  144. Send();
  145. }
  146. //签入
  147. function LoginBack() {
  148. obj.Type = "SayBusy";
  149. Send();
  150. }
  151. // 点击签入
  152. function join() {
  153. obj.Type = 'Login',
  154. obj.AgentID = '9898',
  155. obj.AgentExten = '1015',
  156. obj.AgentType = '0',
  157. obj.AgentGroup = '364'
  158. Send()
  159. }
  160. //取消监测
  161. function SubScribeCancelBack() {
  162. $('.yuan_one').addClass("lx")
  163. $('.yuan_two').addClass("lx")
  164. }
  165. //坐席状态
  166. function AgentStateBack(data) {
  167. $(cons).each(function(i, n) {
  168. if(n.F_UserCode == data.AgentID) {
  169. $('.yuan_one').eq(i).removeClass("lx")
  170. $('.yuan_two').eq(i).removeClass("lx")
  171. $('.yuan_one').eq(i).removeClass("kx")
  172. $('.yuan_two').eq(i).removeClass("kx")
  173. $('.yuan_one').eq(i).removeClass("hc")
  174. $('.yuan_two').eq(i).removeClass("hc")
  175. $('.yuan_one').eq(i).removeClass("hh")
  176. $('.yuan_two').eq(i).removeClass("hh")
  177. $('.yuan_one').eq(i).removeClass("ml")
  178. $('.yuan_two').eq(i).removeClass("ml")
  179. $('.yuan_one').eq(i).removeClass("zl")
  180. $('.yuan_two').eq(i).removeClass("zl")
  181. if(data.State == '0') {
  182. $('.yuan_one').eq(i).addClass("lx")
  183. $('.yuan_two').eq(i).addClass("lx")
  184. } else if(data.State == '2') {
  185. $('.yuan_one').eq(i).addClass("kx")
  186. $('.yuan_two').eq(i).addClass("kx")
  187. } else if(data.State == '3') {
  188. $('.yuan_one').eq(i).addClass("hc")
  189. $('.yuan_two').eq(i).addClass("hc")
  190. } else if(data.State == '4') {
  191. $('.yuan_one').eq(i).addClass("hh")
  192. $('.yuan_two').eq(i).addClass("hh")
  193. } else if(data.State == '5') {
  194. $('.yuan_one').eq(i).addClass("ml")
  195. $('.yuan_two').eq(i).addClass("ml")
  196. } else if(data.State == '6') {
  197. $('.yuan_one').eq(i).addClass("zl")
  198. $('.yuan_two').eq(i).addClass("zl")
  199. }
  200. }
  201. })
  202. }
  203. //后台排队
  204. function backstageQueue(data) {
  205. person = data.WaitCount
  206. console.log(person)
  207. }
  208. $(function() {
  209. createWebSocket()
  210. SayBusy()
  211. partOne($('#time1').val() && $('#time1').val().split(' ~ ')[0], $('#time1').val() && $('#time1').val().split(' ~ ')[1], areaOneVal);
  212. laydate.render({
  213. elem: '#time1',
  214. range: '~',
  215. theme: '#114a97',
  216. done: function(value, date) {
  217. var areaOneVal = $(".areaOne").val();
  218. partOne(value && value.split(' ~ ')[0], value && value.split(' ~ ')[1], areaOneVal);
  219. }
  220. });
  221. laydate.render({
  222. elem: '#time2',
  223. theme: '#114a97',
  224. done: function(value, date) {
  225. var areaOneVal = $(".areaOne").val();
  226. partTwo(value, areaOneVal)
  227. }
  228. });
  229. laydate.render({
  230. elem: '#time3',
  231. theme: '#114a97',
  232. done: function(value, date) {
  233. var areaOneVal = $(".areaOne").val();
  234. partThree(value, areaOneVal)
  235. }
  236. });
  237. Ajax();
  238. $(".areaOne").change(function() {
  239. var areaOneVal = $(this).val();
  240. var areaOneText = $(".areaOne").find("option:selected").text();
  241. helper.cookies.set("areaOneVal", areaOneVal, 7);
  242. helper.cookies.set("areaOneText", areaOneText, 7);
  243. partOne($('#time1').val() && $('#time1').val().split(' ~ ')[0], $('#time1').val() && $('#time1').val().split(' ~ ')[1], areaOneVal);
  244. partTwo($('#time2').val(), areaOneVal);
  245. partThree($('#time3').val(), areaOneVal);
  246. // Ajax()
  247. });
  248. })
  249. // 跳轉
  250. $(".index").click(function() {
  251. window.open('detail.html', '_self')
  252. })
  253. $(".second").click(function() {
  254. window.open('second.html', '_self')
  255. })
  256. $(".third").click(function() {
  257. window.open('third.html', '_self')
  258. })
  259. $(".fourth").click(function() {
  260. window.open('fourth.html', '_self')
  261. })
  262. $(".nav_middle").click(function() {
  263. window.open('index.html', '_self')
  264. })
  265. $("#department").click(function() {
  266. window.open('receiptDepartment.html', '_self')
  267. })
  268. $("#sourceChannel").click(function() {
  269. window.open('sourceChannel.html', '_self')
  270. })
  271. // $("#call").click(function(){
  272. // window.open('TelephoneDetails.html','_self')
  273. // })
  274. $("#complaint").click(function() {
  275. window.open('complaintsReport.html', '_self')
  276. })
  277. //区县筛选
  278. //deprtment();
  279. function deprtment() {
  280. $.getJSON(huayi.config.callcenter_url + "CountyBranch/GetBranchListS",
  281. {token: $.cookie("token"),}, function(result) {
  282. if(result.state.toLowerCase() == "success") {
  283. goodslist = result.data;
  284. // 第五屏
  285. $(".areaOne").empty();
  286. $(goodslist).each(function(i, n) {
  287. $('<option value="' + n.F_Code +
  288. '">' + n.F_Name +
  289. '</option>').appendTo($(".areaOne"));
  290. });
  291. if(areaOneVal) {
  292. $(".areaOne").val(areaOneVal);
  293. }
  294. }
  295. });
  296. }
  297. function partOne(starts, ends, areaOneVal) {
  298. $.ajax({
  299. type: "get",
  300. url: huayi.config.callcenter_url + "SeatMonitoring/getlist",
  301. async: true,
  302. dataType: 'json',
  303. data: {
  304. token: $.cookie("token"),
  305. // start: starts,
  306. // end: ends,
  307. // branchcode:areaOneVal
  308. },
  309. success: function(data) {
  310. if(data.state.toLowerCase() == 'success') {
  311. // layer.close(index);
  312. var newdatas=[]
  313. cons = data.data;
  314. for(var i=0;i<cons.length;i++){
  315. console.log(cons[i].F_RoleCode)
  316. if(cons[i].F_RoleCode=="ZXHWY"){
  317. newdatas.push(cons[i])
  318. }
  319. }
  320. console.log(newdatas)
  321. $(".users").html('')
  322. $(newdatas).each(function(i, n) {
  323. var str = ' <li class="touxiang"><ol class="tx"><li class="person"><span class="yuan_one ">' +
  324. '</span><span class="yuan_two"></span></li><li class="userid">' +
  325. n.F_UserCode + '</li></ol></li>';
  326. var a = $(str)
  327. a.appendTo($(".users"))
  328. })
  329. }
  330. }
  331. });
  332. }
  333. // 开始检测
  334. $(".kqc").click(function() {
  335. // if (!$(this).hasClass("dis")) {
  336. $('.kqc').addClass('kqc_active')
  337. $('.jqc').removeClass('dis')
  338. $(cons).each(function(i, n) {
  339. obj.Type = "SubScribe";
  340. obj.SubParmer = n.F_WorkNumber * 1;
  341. obj.SubType = "0"; //根据工号订阅坐席状态
  342. Send();
  343. obj.SubType = "1"; //根据工号订阅线路状态
  344. Send();
  345. })
  346. //top.obj.Type = "SubScribe";
  347. //top.obj.SubParmer = "8003";
  348. //top.obj.SubType = "0";//根据工号订阅坐席状态
  349. //top.Send();
  350. //top.obj.SubType = "1";//根据工号订阅线路状态
  351. //top.Send();
  352. // }
  353. })
  354. //停止监测
  355. $(".jqc").click(function() {
  356. $('.kqc').removeClass('kqc_active')
  357. $('.jqc').addClass('dis')
  358. //$(user).each(function (i, n) {
  359. // obj.Type = "SubScribeCancel";
  360. // obj.SubParmer = n.F_WorkNumber;
  361. // obj.SubType = "0";//根据工号取消订阅坐席状态
  362. // Send();
  363. // obj.SubType = "1";//根据工号取消订阅线路状态
  364. // Send();
  365. //})
  366. obj.Type = "SubScribeCancel";
  367. obj.SubParmer = "-1";
  368. obj.SubType = "0"; //根据工号取消订阅坐席状态
  369. Send();
  370. obj.SubType = "1"; //根据工号取消订阅线路状态
  371. Send();
  372. })
  373. //part 2
  374. var phoneTimeCount = echarts.init(document.getElementById('phoneTimeCount'));
  375. phoneTimeCount.setOption({
  376. color: ['#ceba5f', '#4da991', '#f06e84', '#6a91e0'],
  377. tooltip: {
  378. trigger: 'axis',
  379. axisPointer: {
  380. type: 'cross',
  381. label: {
  382. show: true,
  383. backgroundColor: '#333'
  384. }
  385. }
  386. },
  387. grid: {
  388. left: '2%',
  389. right: '5%',
  390. bottom: '6%',
  391. containLabel: true
  392. },
  393. legend: {
  394. top: 'top',
  395. left: '180px',
  396. data: ["来电数量", "接通数量", "放弃数量", "黑名单拒接数量"],
  397. textStyle: {
  398. color: '#00e9ff'
  399. }
  400. },
  401. xAxis: {
  402. name: '时',
  403. data: [],
  404. axisLine: {
  405. lineStyle: {
  406. color: '#3061a2'
  407. }
  408. },
  409. axisTick: {
  410. alignWithLabel: true,
  411. show: false
  412. },
  413. axisLabel: { //横轴字体颜色
  414. show: true,
  415. textStyle: {
  416. color: '#eff0f4'
  417. }
  418. }
  419. },
  420. yAxis: {
  421. name: '数量',
  422. splitLine: {
  423. show: false
  424. },
  425. axisLine: {
  426. lineStyle: {
  427. color: '#3061a2'
  428. }
  429. },
  430. axisLabel: { //横轴字体颜色
  431. show: true,
  432. textStyle: {
  433. color: '#eff0f4'
  434. }
  435. }
  436. },
  437. series: []
  438. });
  439. function partTwo(dates, areaOneVal) {
  440. // var index = layer.load(1, {
  441. // shade: [0.5, '#030303'] //0.1透明度的白色背景
  442. // });
  443. $.ajax({
  444. type: "get",
  445. url: huayi.config.callcenter_url + "info/GetTelCount24ByDate",
  446. async: true,
  447. dataType: "json",
  448. data: {
  449. token: $.cookie("token"),
  450. date: dates,
  451. branchcode: areaOneVal
  452. },
  453. success: function(data) {
  454. if(data.state.toLowerCase() == "success") {
  455. // layer.close(index);
  456. var con = data.data;
  457. phoneTimeCount.setOption({
  458. xAxis: {
  459. data: con.hours
  460. },
  461. series: [{
  462. name: "来电数量",
  463. type: "line",
  464. smooth: true,
  465. showAllSymbol: true,
  466. symbol: "emptyCircle",
  467. symbolSize: 10,
  468. data: con.rcounts
  469. }, {
  470. name: "接通数量",
  471. type: "line",
  472. smooth: true,
  473. showAllSymbol: true,
  474. symbol: "emptyCircle",
  475. symbolSize: 10,
  476. data: con.ccounts
  477. },
  478. {
  479. name: "放弃数量",
  480. type: "line",
  481. smooth: true,
  482. showAllSymbol: true,
  483. symbol: "emptyCircle",
  484. symbolSize: 10,
  485. data: con.gcounts
  486. },
  487. {
  488. name: "黑名单拒接数量",
  489. type: "line",
  490. smooth: true,
  491. showAllSymbol: true,
  492. symbol: "emptyCircle",
  493. symbolSize: 10,
  494. data: con.scounts
  495. }
  496. ]
  497. })
  498. }
  499. }
  500. });
  501. }
  502. //part3
  503. var todyPhoneCount = echarts.init(document.getElementById('todyPhoneCount'));
  504. todyPhoneCount.setOption({
  505. tooltip: {
  506. trigger: 'axis',
  507. axisPointer: {
  508. type: false,
  509. label: {
  510. show: true,
  511. backgroundColor: '#030917'
  512. }
  513. },
  514. },
  515. xAxis: {
  516. name: '类型',
  517. data: ["话务量(通)", "来电(通)", "接通量(通)", "平均通话时长(秒)", "排队人数"],
  518. axisLine: {
  519. lineStyle: {
  520. color: '#3061a2'
  521. }
  522. },
  523. axisTick: {
  524. alignWithLabel: true,
  525. show: false
  526. },
  527. axisLabel: { //横轴字体颜色
  528. show: true,
  529. textStyle: {
  530. color: '#eff0f4'
  531. }
  532. }
  533. },
  534. yAxis: {
  535. name: '数量',
  536. splitLine: {
  537. show: false
  538. },
  539. axisLine: {
  540. lineStyle: {
  541. color: '#3061a2'
  542. }
  543. },
  544. axisLabel: { //横轴字体颜色
  545. show: true,
  546. textStyle: {
  547. color: '#eff0f4'
  548. }
  549. }
  550. },
  551. series: [{
  552. name: '数量',
  553. type: 'bar',
  554. barWidth: 18,
  555. itemStyle: {
  556. normal: {
  557. color: function(params) {
  558. // build a color map as your need.
  559. var colorList = [
  560. '#368cab', '#54b793', '#4b6ab0', '#2531a9', '#a93d19'
  561. ];
  562. return colorList[params.dataIndex]
  563. }
  564. }
  565. },
  566. label: {
  567. normal: {
  568. show: true,
  569. position: 'top', //顶部数据显示位置
  570. textStyle: {
  571. color: '#fff' //顶部数据颜色
  572. },
  573. formatter: '{c}' // 这里是数据展示的时候显示的数据
  574. }
  575. },
  576. data: []
  577. }]
  578. });
  579. function partThree(dates, areaOneVal) {
  580. $.ajax({
  581. type: "get",
  582. url: huayi.config.callcenter_url + "info/GetTelCountByDate",
  583. async: true,
  584. dataType: "json",
  585. data: {
  586. token: $.cookie("token"),
  587. date: dates,
  588. branchcode: areaOneVal
  589. },
  590. success: function(data) {
  591. if(data.state.toLowerCase() == "success") {
  592. // layer.close(index);
  593. var con = data.data;
  594. console.log(con)
  595. todyPhoneCount.setOption({
  596. series: [{
  597. data: [con.hwcon, con.lhcon, con.jtcon, con.pjthtimes, person]
  598. }]
  599. })
  600. }
  601. }
  602. });
  603. }
  604. function Ajax() {
  605. var areaOneVal = helper.cookies.get("areaOneVal");
  606. var areaOneText = helper.cookies.get("areaOneText");
  607. //partOne($('#time1').val() && $('#time1').val().split(' ~ ')[0], $('#time1').val() && $('#time1').val().split(' ~ ')[1],areaOneVal);
  608. partTwo($('#time2').val(), areaOneVal)
  609. partThree($('#time3').val(), areaOneVal);
  610. }