Nessuna descrizione

TelephoneDetails.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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", function(result) {
  281. if(result.state.toLowerCase() == "success") {
  282. goodslist = result.data;
  283. // 第五屏
  284. $(".areaOne").empty();
  285. $(goodslist).each(function(i, n) {
  286. $('<option value="' + n.F_Code +
  287. '">' + n.F_Name +
  288. '</option>').appendTo($(".areaOne"));
  289. });
  290. if(areaOneVal) {
  291. $(".areaOne").val(areaOneVal);
  292. }
  293. }
  294. });
  295. }
  296. function partOne(starts, ends, areaOneVal) {
  297. $.ajax({
  298. type: "get",
  299. url: huayi.config.callcenter_url + "SeatMonitoring/getlist",
  300. async: true,
  301. dataType: 'json',
  302. data: {
  303. // start: starts,
  304. // end: ends,
  305. // branchcode:areaOneVal
  306. },
  307. success: function(data) {
  308. if(data.state.toLowerCase() == 'success') {
  309. // layer.close(index);
  310. cons = data.data;
  311. $(".users").html('')
  312. $(cons).each(function(i, n) {
  313. var str = ' <li class="touxiang"><ol class="tx"><li class="person"><span class="yuan_one ">' +
  314. '</span><span class="yuan_two"></span></li><li class="userid">' +
  315. n.F_UserCode + '</li></ol></li>';
  316. var a = $(str)
  317. a.appendTo($(".users"))
  318. })
  319. }
  320. }
  321. });
  322. }
  323. // 开始检测
  324. $(".kqc").click(function() {
  325. // if (!$(this).hasClass("dis")) {
  326. $('.kqc').addClass('kqc_active')
  327. $('.jqc').removeClass('dis')
  328. $(cons).each(function(i, n) {
  329. obj.Type = "SubScribe";
  330. obj.SubParmer = n.F_WorkNumber * 1;
  331. obj.SubType = "0"; //根据工号订阅坐席状态
  332. Send();
  333. obj.SubType = "1"; //根据工号订阅线路状态
  334. Send();
  335. })
  336. //top.obj.Type = "SubScribe";
  337. //top.obj.SubParmer = "8003";
  338. //top.obj.SubType = "0";//根据工号订阅坐席状态
  339. //top.Send();
  340. //top.obj.SubType = "1";//根据工号订阅线路状态
  341. //top.Send();
  342. // }
  343. })
  344. //停止监测
  345. $(".jqc").click(function() {
  346. $('.kqc').removeClass('kqc_active')
  347. $('.jqc').addClass('dis')
  348. //$(user).each(function (i, n) {
  349. // obj.Type = "SubScribeCancel";
  350. // obj.SubParmer = n.F_WorkNumber;
  351. // obj.SubType = "0";//根据工号取消订阅坐席状态
  352. // Send();
  353. // obj.SubType = "1";//根据工号取消订阅线路状态
  354. // Send();
  355. //})
  356. obj.Type = "SubScribeCancel";
  357. obj.SubParmer = "-1";
  358. obj.SubType = "0"; //根据工号取消订阅坐席状态
  359. Send();
  360. obj.SubType = "1"; //根据工号取消订阅线路状态
  361. Send();
  362. })
  363. //part 2
  364. var phoneTimeCount = echarts.init(document.getElementById('phoneTimeCount'));
  365. phoneTimeCount.setOption({
  366. color: ['#ceba5f', '#4da991', '#f06e84', '#6a91e0'],
  367. tooltip: {
  368. trigger: 'axis',
  369. axisPointer: {
  370. type: 'cross',
  371. label: {
  372. show: true,
  373. backgroundColor: '#333'
  374. }
  375. }
  376. },
  377. grid: {
  378. left: '2%',
  379. right: '5%',
  380. bottom: '6%',
  381. containLabel: true
  382. },
  383. legend: {
  384. top: 'top',
  385. left: '180px',
  386. data: ["来电数量", "接通数量", "放弃数量", "黑名单拒接数量"],
  387. textStyle: {
  388. color: '#00e9ff'
  389. }
  390. },
  391. xAxis: {
  392. name: '时',
  393. data: [],
  394. axisLine: {
  395. lineStyle: {
  396. color: '#3061a2'
  397. }
  398. },
  399. axisTick: {
  400. alignWithLabel: true,
  401. show: false
  402. },
  403. axisLabel: { //横轴字体颜色
  404. show: true,
  405. textStyle: {
  406. color: '#eff0f4'
  407. }
  408. }
  409. },
  410. yAxis: {
  411. name: '数量',
  412. splitLine: {
  413. show: false
  414. },
  415. axisLine: {
  416. lineStyle: {
  417. color: '#3061a2'
  418. }
  419. },
  420. axisLabel: { //横轴字体颜色
  421. show: true,
  422. textStyle: {
  423. color: '#eff0f4'
  424. }
  425. }
  426. },
  427. series: []
  428. });
  429. function partTwo(dates, areaOneVal) {
  430. // var index = layer.load(1, {
  431. // shade: [0.5, '#030303'] //0.1透明度的白色背景
  432. // });
  433. $.ajax({
  434. type: "get",
  435. url: huayi.config.callcenter_url + "info/GetTelCount24ByDate",
  436. async: true,
  437. dataType: "json",
  438. data: {
  439. date: dates,
  440. branchcode: areaOneVal
  441. },
  442. success: function(data) {
  443. if(data.state.toLowerCase() == "success") {
  444. // layer.close(index);
  445. var con = data.data;
  446. phoneTimeCount.setOption({
  447. xAxis: {
  448. data: con.hours
  449. },
  450. series: [{
  451. name: "来电数量",
  452. type: "line",
  453. smooth: true,
  454. showAllSymbol: true,
  455. symbol: "emptyCircle",
  456. symbolSize: 10,
  457. data: con.rcounts
  458. }, {
  459. name: "接通数量",
  460. type: "line",
  461. smooth: true,
  462. showAllSymbol: true,
  463. symbol: "emptyCircle",
  464. symbolSize: 10,
  465. data: con.ccounts
  466. },
  467. {
  468. name: "放弃数量",
  469. type: "line",
  470. smooth: true,
  471. showAllSymbol: true,
  472. symbol: "emptyCircle",
  473. symbolSize: 10,
  474. data: con.gcounts
  475. },
  476. {
  477. name: "黑名单拒接数量",
  478. type: "line",
  479. smooth: true,
  480. showAllSymbol: true,
  481. symbol: "emptyCircle",
  482. symbolSize: 10,
  483. data: con.scounts
  484. }
  485. ]
  486. })
  487. }
  488. }
  489. });
  490. }
  491. //part3
  492. var todyPhoneCount = echarts.init(document.getElementById('todyPhoneCount'));
  493. todyPhoneCount.setOption({
  494. tooltip: {
  495. trigger: 'axis',
  496. axisPointer: {
  497. type: false,
  498. label: {
  499. show: true,
  500. backgroundColor: '#030917'
  501. }
  502. },
  503. },
  504. xAxis: {
  505. name: '类型',
  506. data: ["话务量(通)", "来电(通)", "接通量(通)", "平均通话时长(秒)", "排队人数"],
  507. axisLine: {
  508. lineStyle: {
  509. color: '#3061a2'
  510. }
  511. },
  512. axisTick: {
  513. alignWithLabel: true,
  514. show: false
  515. },
  516. axisLabel: { //横轴字体颜色
  517. show: true,
  518. textStyle: {
  519. color: '#eff0f4'
  520. }
  521. }
  522. },
  523. yAxis: {
  524. name: '数量',
  525. splitLine: {
  526. show: false
  527. },
  528. axisLine: {
  529. lineStyle: {
  530. color: '#3061a2'
  531. }
  532. },
  533. axisLabel: { //横轴字体颜色
  534. show: true,
  535. textStyle: {
  536. color: '#eff0f4'
  537. }
  538. }
  539. },
  540. series: [{
  541. name: '数量',
  542. type: 'bar',
  543. barWidth: 18,
  544. itemStyle: {
  545. normal: {
  546. color: function(params) {
  547. // build a color map as your need.
  548. var colorList = [
  549. '#368cab', '#54b793', '#4b6ab0', '#2531a9', '#a93d19'
  550. ];
  551. return colorList[params.dataIndex]
  552. }
  553. }
  554. },
  555. label: {
  556. normal: {
  557. show: true,
  558. position: 'top', //顶部数据显示位置
  559. textStyle: {
  560. color: '#fff' //顶部数据颜色
  561. },
  562. formatter: '{c}' // 这里是数据展示的时候显示的数据
  563. }
  564. },
  565. data: []
  566. }]
  567. });
  568. function partThree(dates, areaOneVal) {
  569. $.ajax({
  570. type: "get",
  571. url: huayi.config.callcenter_url + "info/GetTelCountByDate",
  572. async: true,
  573. dataType: "json",
  574. data: {
  575. date: dates,
  576. branchcode: areaOneVal
  577. },
  578. success: function(data) {
  579. if(data.state.toLowerCase() == "success") {
  580. // layer.close(index);
  581. var con = data.data;
  582. console.log(con)
  583. todyPhoneCount.setOption({
  584. series: [{
  585. data: [con.hwcon, con.lhcon, con.jtcon, con.pjthtimes, person]
  586. }]
  587. })
  588. }
  589. }
  590. });
  591. }
  592. function Ajax() {
  593. var areaOneVal = helper.cookies.get("areaOneVal");
  594. var areaOneText = helper.cookies.get("areaOneText");
  595. //partOne($('#time1').val() && $('#time1').val().split(' ~ ')[0], $('#time1').val() && $('#time1').val().split(' ~ ')[1],areaOneVal);
  596. partTwo($('#time2').val(), areaOneVal)
  597. partThree($('#time3').val(), areaOneVal);
  598. }