Bez popisu

TelephoneDetails.js 15KB

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