Keine Beschreibung

main.js 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. if (typeof console == "undefined") {
  2. this.console = { log: function (msg) { } };
  3. }
  4. // 如果浏览器不支持websocket,会使用这个flash自动模拟websocket协议,此过程对开发者透明
  5. WEB_SOCKET_SWF_LOCATION = "./js/websocket/WebSocketMain.swf";
  6. // 开启flash的websocket debug
  7. WEB_SOCKET_DEBUG = true;
  8. var ws, n = 0,
  9. timer;
  10. var lockReconnect = false; //避免重复连接
  11. var obj = {};
  12. var Statess;
  13. var cls = 0;
  14. var lasttime = new Date().getTime();
  15. //创建scoket连接
  16. function createWebSocket() {
  17. try {
  18. $("#top-search li i").removeClass("active");
  19. Connect();
  20. } catch (e) {
  21. reconnect();
  22. }
  23. }
  24. //连接
  25. function Connect() {
  26. ws = new WebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  27. ws.onopen = function () {
  28. console.log(new Date() + " " + "建立连接");
  29. //心跳检测重置
  30. heartCheck.reset().start();
  31. cls = 0;
  32. $(".Login").addClass("active");
  33. lasttime = new Date().getTime();
  34. //自动签入
  35. // if ($.cookie("socket_state") != null) {
  36. // SetLogin($.cookie("socket_state"));
  37. // }
  38. //$(".hwzt").text('连接成功!');
  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. if (rlt == true) {
  51. var type = data.Type;
  52. switch (type.toLowerCase()) {
  53. //case "heart": HeartBack(); break;//心跳
  54. case "login":
  55. LoginBack();
  56. break; //签入
  57. case "logout":
  58. LogoutBack();
  59. break; //签出
  60. case "dropcall":
  61. DropCallBack();
  62. break; //挂断
  63. case "makecall":
  64. MakeCallBack();
  65. break; //外呼
  66. case "setstate":
  67. SetState(data);
  68. break; //置忙置闲
  69. //case "saybusy": SayBusyBack(data); break;
  70. //case "sayfree": SayFreeBack(data); break;
  71. case "meeting":
  72. MeetingBack();
  73. break; //多方通话
  74. case "meetingtakeback":
  75. MeetingTakeBackFun();
  76. break; //多方通话回签
  77. case "transfer":
  78. TransferBack();
  79. break; //转移
  80. case "hold":
  81. HoldBack();
  82. break; //保持
  83. case "retrieve":
  84. RetrieveBack();
  85. break; //接回
  86. case "incoming":
  87. IncomingBack(data);
  88. break; //来电
  89. case "subscribe":
  90. SubScribeBack();
  91. break; //监测
  92. case "subscribecancel":
  93. SubScribeCancelBack();
  94. break; //停止监测
  95. case "agentstate":
  96. AgentStateBack(data);
  97. break; //坐席状态
  98. case "linestate":
  99. LineStateBack(data);
  100. break; //线路状态
  101. case "motorsetstate":
  102. SayFreeBack();
  103. break; //班长置闲
  104. case "linestateagent":
  105. LineStateAgentBack(data);
  106. break; //线路状态通知
  107. case "agentstateagent":
  108. AgentStateAgentBack(data);
  109. break; //坐席状态通知
  110. //case "callid":
  111. // CallIDBack(data);
  112. // break; //获取callid
  113. case "recordpath":
  114. RecordPathBack(data);
  115. break; //录音返回
  116. case "getagentlist":
  117. GetAgentListBack(data);
  118. break;//在线坐席信息
  119. case "confirmtransfer":
  120. ConfirmTransfer(data);
  121. break;//确认转移 取消转移
  122. case "consult":
  123. ConsultationCall();
  124. break;//协商呼叫
  125. }
  126. } else {
  127. if (rlt == false) {
  128. //layer.confirm('操作失败!', {
  129. // btn: ['确定']
  130. //});
  131. $(".hwzt").text('操作失败!');
  132. } else {
  133. $(".hwzt").text(rlt);
  134. //layer.confirm(rlt, {
  135. // btn: ['确定']
  136. //});
  137. switch (data.Type.toLowerCase()) {
  138. case "waitcount":
  139. backstageQueue(data);
  140. break;//后台排队
  141. }
  142. }
  143. }
  144. }
  145. };
  146. //连接关闭的回调方法
  147. ws.onclose = function (evt) {
  148. if (cls == 0) {
  149. cls = 1;
  150. //console.log("连接关闭!");
  151. //layer.confirm('连接关闭!', {
  152. // btn: ['确定']
  153. //});
  154. $(".hwzt").text('连接关闭!');
  155. $("#top-search li i").removeClass("active");
  156. reconnect();
  157. }
  158. };
  159. //连接发生错误的回调方法
  160. ws.onerror = function (evt) {
  161. //产生异常
  162. $(".hwzt").text('连接出现异常!');
  163. console.log(ws);
  164. if (ws == null || ws.readyState != ws.OPEN) {
  165. console.log(new Date() + "开始重连");
  166. reconnect();
  167. }
  168. };
  169. }
  170. //重连
  171. function reconnect() {
  172. if (lockReconnect) return;
  173. lockReconnect = true;
  174. //没连接上会一直重连,设置延迟避免请求过多
  175. setTimeout(function () {
  176. console.log(new Date() + " " + "重连中……");
  177. createWebSocket("ws://" + huayi.config.socket_ip + ":" + huayi.config.socket_port);
  178. lockReconnect = false;
  179. }, 2000);
  180. }
  181. //发送
  182. function Send() {
  183. if (ws.readyState != ws.OPEN) {
  184. reconnect();
  185. }
  186. if (ws.readyState == ws.OPEN) {
  187. console.log(new Date() + " send " + JSON.stringify(obj));
  188. ws.send(JSON.stringify(obj));
  189. }
  190. }
  191. //心跳检测
  192. var heartCheck = {
  193. timeout: 25000, //25秒
  194. timeoutObj: null,
  195. serverTimeoutObj: null,
  196. reset: function () {
  197. clearTimeout(this.timeoutObj);
  198. clearTimeout(this.serverTimeoutObj);
  199. return this;
  200. },
  201. start: function () {
  202. var self = this;
  203. this.timeoutObj = setTimeout(function () {
  204. //这里发送一个心跳,后端收到后,返回一个心跳消息,
  205. //onmessage拿到返回的心跳就说明连接正常
  206. obj.Type = "Heart";
  207. Send();
  208. self.serverTimeoutObj = setTimeout(function () { //如果超过一定时间还没重置,说明后端主动断开了
  209. ws.close(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
  210. }, self.timeout)
  211. }, this.timeout)
  212. }
  213. }
  214. //签入
  215. function LoginBack() {
  216. $("#top-search li i").removeClass("active");
  217. $(".Logout").addClass("active");
  218. $(".SayBusy").addClass("active");
  219. $(".MakeCall").addClass("active");
  220. $(".zxzt").removeClass("br").addClass("bl");
  221. $(".fwzt").removeClass("br").addClass("bl");
  222. $(".hwzt").text('');
  223. $('.Consult').addClass("active");
  224. // if($.cookie("socket_state") == null){
  225. // SetStateCookie(0);
  226. // }
  227. $("#isml").val(1);
  228. // SetStateCookie(1);
  229. obj.Type = "SayBusy";
  230. Send();
  231. }
  232. //签出
  233. function LogoutBack() {
  234. $("#top-search li i").removeClass("active");
  235. $(".Login").addClass("active");
  236. $(".zxzt").removeClass("bl").addClass("br");
  237. $(".fwzt").removeClass("bl").addClass("br");
  238. $(".hwzt").text('');
  239. // SetStateCookie(2);
  240. }
  241. //来电
  242. function IncomingBack(data) {
  243. $(".ldhm").val(data.Number);
  244. $(".hidTel").val(data.Number);
  245. $(".tel").text(data.Number);
  246. $(".ldtime").text(getNowFormatDate());
  247. $(".thsc").text("00:00");
  248. $(".hidCallID").val(data.CallID);
  249. $("#phonetype").val(data.TrunkNumber);
  250. //获取电话所属地
  251. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetPhoneLocation', {
  252. "tel": $(".hidTel").val(),
  253. "token": $.cookie("token")
  254. }, function (result) {
  255. if (result.state.toLowerCase() == "success") {
  256. $(".ldlocation").text(result.data[0].F_Name);
  257. $(".khgsd").text(result.data[0].F_Name);
  258. }
  259. })
  260. //获取客户信息
  261. $(".ttsdh").text($(".hidTel").val());
  262. $(".tsdh").val($(".hidTel").val());
  263. $.getJSON(huayi.config.callcenter_url + 'CallInScreen/GetCustomerByTel', {
  264. "tel": $(".hidTel").val(),
  265. "token": $.cookie("token")
  266. }, function (result) {
  267. if (result.state.toLowerCase() == "success") {
  268. if (result.data.length > 0) {
  269. $(".khmc").val(result.data[0].F_CustomerName);
  270. $(".tkhmc").text(result.data[0].F_CustomerName);
  271. $("#khid").val(result.data[0].F_CustomerId);
  272. $(".lxdh").val(result.data[0].F_Telephone);
  273. //$(".tsdh").val(result.data[0].F_Mobile);
  274. //$(".ttsdh").text(result.data[0].F_Mobile);
  275. $(".lxr").val(result.data[0].F_CustomerEName);
  276. $(".postcode").val(result.data[0].F_PostCode);
  277. $(".email").val(result.data[0].F_Email);
  278. }
  279. else {
  280. $(".khmc").val("");
  281. $(".tkhmc").text("");
  282. $("#khid").val("");
  283. $(".lxr").val("");
  284. $(".postcode").val("");
  285. $(".email").val("");
  286. }
  287. }
  288. })
  289. $('.maxOpen').trigger("click");
  290. $('.head-pic .lahei .la-before').show();
  291. //触发来电类型第一个 点击;
  292. $("#dicValueList li:first-child").find("label").trigger('click');
  293. $('.head-pic .lahei .la-after').hide();
  294. $(".Bacha").hide();
  295. /*
  296. 弹屏状态
  297. bounceScreenStatus
  298. 0、关闭
  299. 1、打开
  300. */
  301. $("#bounceScreenStatus").val("1")
  302. // 历史记录 历史工单
  303. loadOld()
  304. }
  305. //挂断
  306. function DropCallBack() {
  307. $("#top-search li i").removeClass("active");
  308. $(".Logout").addClass("active");
  309. $(".SayBusy").removeClass("active");
  310. // $(".SayFree").addClass("active");
  311. $(".MakeCall").addClass("active");
  312. $(".td-call").hide();
  313. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  314. $(".hwzt").text('忙碌');
  315. $("#isml").val(1);
  316. // SetStateCookie(1);
  317. obj.Type = "SayBusy";
  318. Send();
  319. //$('.ldtp-con').css("display", 'none');
  320. }
  321. //线路状态通知
  322. function LineStateAgentBack(data) {
  323. //0分机不可用,1空闲,2摘机等待拨号,3正在拨号,4呼出振铃,5来电振铃,6通话中,7播放忙音中,8移除IP分机,9通话保持中
  324. if (data.State == '0') {
  325. $(".hwzt").text('分机不可用'); //左下角状态显示
  326. $(".fwzt").removeClass("br").removeClass("bl");
  327. }
  328. if (data.State == '1') {
  329. if($("#isml").val()==1){
  330. // isml=1;
  331. $(".hwzt").text('置忙'); //左下角状态显示
  332. $(".fwzt").removeClass("bl").addClass("br");
  333. }
  334. else{
  335. if ($("#RoleCode").val()=='ZJZY') {
  336. $(".hwzt").text('置忙'); //左下角状态显示
  337. $(".fwzt").removeClass("bl").addClass("br");
  338. }else{
  339. $(".hwzt").text('空闲'); //左下角状态显示
  340. $(".fwzt").removeClass("br").addClass("bl");
  341. }
  342. }
  343. // $(".hwzt").text('空闲'); //左下角状态显示
  344. // $(".fwzt").removeClass("br").addClass("bl");
  345. clearInterval(timer);
  346. //2018-10-13 clq 作废挂机
  347. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  348. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateGJ', {
  349. // callid: $(".hidCallID").val(),
  350. // "token": $.cookie("token")
  351. // }, function (result) {
  352. // result = JSON.parse(result);
  353. // if (result.state.toLowerCase() == "success") { }
  354. // })
  355. //}
  356. $("#top-search li i").removeClass("active");
  357. $(".Logout").addClass("active");
  358. if($("#isml").val()==0){
  359. $(".SayBusy").addClass("active");
  360. } else {
  361. $(".SayFree").addClass("active");
  362. }
  363. // $(".SayBusy").addClass("active");
  364. $(".MakeCall").addClass("active");
  365. $(".td-call").hide();
  366. $(".Bacha").show();
  367. //$(".hidTel").val("");
  368. //$(".hidCallID").val("");
  369. }
  370. if (data.State == '2') {
  371. $(".hwzt").text('摘机等待拨号'); //左下角状态显示
  372. }
  373. if (data.State == '3') {
  374. $(".hwzt").text('正在拨号'); //左下角状态显示
  375. }
  376. if (data.State == '4') {
  377. $(".hwzt").text('呼出振铃'); //左下角状态显示
  378. }
  379. if (data.State == '5') {
  380. $(".hwzt").text('来电振铃'); //左下角状态显示
  381. $(".fwzt").removeClass("bl").addClass("br");
  382. if ($(".hidTel").val() && $(".hidCallID").val()) {
  383. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZL', {
  384. callid: $(".hidCallID").val(),
  385. "token": $.cookie("token")
  386. }, function (result) {
  387. result = JSON.parse(result);
  388. if (result.state.toLowerCase() == "success") { }
  389. })
  390. }
  391. }
  392. if (data.State == '6') {
  393. $(".hwzt").text('通话中'); //左下角状态显示
  394. $(".fwzt").removeClass("bl").addClass("br");
  395. $(".zxzt").removeClass("bl").addClass("br");
  396. if ($(".hidTel").val() && $(".hidCallID").val()) {
  397. $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateZJ', {
  398. callid: $(".hidCallID").val(),
  399. "token": $.cookie("token")
  400. }, function (result) {
  401. result = JSON.parse(result);
  402. if (result.state.toLowerCase() == "success") { }
  403. })
  404. }
  405. $(".td-call").show();
  406. n = 0;
  407. $("#top-search li i").removeClass("active");
  408. $(".DropCall").addClass("active");
  409. $(".Hold").addClass("active");
  410. $(".Transfer").addClass("active");
  411. $(".Meeting").addClass("active");
  412. $('.TurnIvr').addClass("active");
  413. $('.Consult').addClass("active");
  414. $('.satisfactionEvaluation').addClass("active");
  415. clearInterval(timer);
  416. timer = setInterval(function () {
  417. n++;
  418. var m = parseInt(n / 60 % 60);
  419. var s = parseInt(n % 60);
  420. $(".thsc").text(toDub(m) + ":" + toDub(s));
  421. }, 1000);
  422. }
  423. if (data.State == '7') {
  424. $(".hwzt").text('播放忙音中'); //左下角状态显示
  425. }
  426. if (data.State == '8') {
  427. $(".hwzt").text('移除IP分机'); //左下角状态显示
  428. }
  429. if (data.State == '9') {
  430. $(".hwzt").text('通话保持中'); //左下角状态显示
  431. }
  432. }
  433. //坐席状态通知
  434. function AgentStateAgentBack(data) {
  435. var strr = '';
  436. console.log('坐席状态'+ data.State );
  437. switch (data.State+"") {
  438. case "0":
  439. strr = "离线";
  440. $(".zxzt").removeClass("br").removeClass("bl").removeClass("by");
  441. break; //离线
  442. case "1":
  443. break; //登录中
  444. case "2":
  445. strr = "空闲";
  446. $(".zxzt").removeClass("br").removeClass("by").addClass("bl");
  447. break; //空闲
  448. case "3":
  449. strr = "通话中";
  450. $(".zxzt").removeClass("bl").removeClass("by").addClass("br");
  451. break; //通话中
  452. case "4":
  453. strr = "话后处理中";
  454. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  455. break; //话后处理中
  456. case "5":
  457. strr = "忙碌";
  458. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  459. break; //小休
  460. case "6":
  461. strr = "振铃";
  462. break; //被请求
  463. case "7":
  464. strr = "注销";
  465. $(".zxzt").removeClass("br").removeClass("bl").removeClass("by");
  466. break; //注销
  467. }
  468. $(".hxzt").text(strr);
  469. }
  470. function toDub(i) {
  471. return i < 10 ? "0" + i : "" + i;
  472. }
  473. //外呼
  474. function MakeCallBack() {
  475. $("#top-search li i").removeClass("active");
  476. $(".DropCall").addClass("active");
  477. $(".Meeting").addClass("active");
  478. $('.satisfactionEvaluation').addClass("active");
  479. }
  480. //默认记忆上次是否签入,是否置忙置闲 0表示已签入 空闲,1表示签入置忙,2表示签出
  481. function SetStateCookie(state) {
  482. $.cookie("socket_state", state);
  483. }
  484. //置忙 置闲
  485. function SetState(obj) {
  486. if (obj.State == '5') {
  487. $(".SayBusy").removeClass("active");
  488. $(".zxzt").removeClass("bl").removeClass("br").addClass("by");
  489. $(".hwzt").text('忙碌');
  490. $("#isml").val(1);
  491. if($("#bounceScreenStatus").val() === "1"){
  492. $(".SayFree").removeClass("active");
  493. } else {
  494. $(".SayFree").addClass("active");
  495. }
  496. $("#bounceScreenStatus").val("0")
  497. // SetStateCookie(1);
  498. }
  499. if (obj.State == '2') {
  500. $(".SayBusy").addClass("active");
  501. $(".SayFree").removeClass("active");
  502. $(".zxzt").removeClass("br").removeClass("by").addClass("bl");
  503. $(".hwzt").text('空闲');
  504. $("#isml").val(0);
  505. // SetStateCookie(0);
  506. }
  507. }
  508. // 自动签入
  509. // function SetLogin(state) {
  510. // if (state == 2) { return; }
  511. // if (obj.AgentID) {
  512. // obj.Type = "Login";
  513. // if( $("#RoleCode").val()=='DBHWY'){
  514. // obj.AgentGroup = "1";
  515. // }
  516. // else if($("#RoleCode").val()=='ZJZY'){
  517. // obj.AgentGroup = "2";
  518. // }
  519. // else{
  520. // obj.AgentGroup = "364";
  521. // }
  522. // obj.AgentType = "0";
  523. // Send();
  524. // }
  525. // if (state == 1) {
  526. // setTimeout('SayBusy()', 500);
  527. // }
  528. // }
  529. //置忙
  530. function SayBusy() {
  531. if (obj.AgentID) {
  532. obj.Type = "SayBusy";
  533. Send();
  534. }
  535. }
  536. //置忙
  537. function SayBusyBack() {
  538. $(".SayBusy").removeClass("active");
  539. $(".SayFree").addClass("active");
  540. $("#isml").val(1)
  541. }
  542. //置闲
  543. function SayFreeBack() {
  544. $(".SayBusy").addClass("active");
  545. $(".SayFree").removeClass("active");
  546. $(".zxzt").removeClass("br").addClass("bl"); //坐席状态指示
  547. $(".hwzt").text('空闲');// 增加坐席状态指示
  548. $("#isml").val(0)
  549. }
  550. //多方通话
  551. function MeetingBack() {
  552. $(".MeetingTakeBack").addClass("active");
  553. }
  554. //多方通话回签
  555. function MeetingTakeBackFun() {
  556. $(".MeetingTakeBack").removeClass("active");
  557. }
  558. //转移
  559. function TransferBack() {
  560. $("#top-search li i").removeClass("active");
  561. $(".Logout").addClass("active");
  562. $(".SayBusy").addClass("active");
  563. $(".MakeCall").addClass("active");
  564. }
  565. //保持
  566. function HoldBack() {
  567. $(".Hold").removeClass("active");
  568. $(".Retrieve").addClass("active");
  569. }
  570. //接回
  571. function RetrieveBack() {
  572. $(".Hold").addClass("active");
  573. $(".Retrieve").removeClass("active");
  574. }
  575. //协商呼叫
  576. function ConsultationCall() {
  577. $('.Consult').removeClass("active");
  578. $('.ConfirmTransfer').addClass("active");//确认转移
  579. $('.CancelTransfer').addClass("active");//取消转移
  580. }
  581. //确认转移&取消转移
  582. function ConfirmTransfer(data) {
  583. if (data.State == 3) {//取消转移
  584. $('.Consult').addClass("active");
  585. $(".CancelTransfer").removeClass("active");
  586. $(".ConfirmTransfer").removeClass("active");
  587. } else {
  588. //确认转移
  589. $('.Consult').removeClass("active");
  590. $(".CancelTransfer").removeClass("active");
  591. $(".ConfirmTransfer").removeClass("active");
  592. }
  593. }
  594. //监测
  595. function SubScribeBack() {
  596. var obj = $("iframe:visible")
  597. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  598. window.frames[obj.attr("name")].Start();
  599. }
  600. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  601. window.frames[obj.attr("name")].Start();
  602. }
  603. }
  604. //取消监测
  605. function SubScribeCancelBack() {
  606. var obj = $("iframe:visible")
  607. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  608. window.frames[obj.attr("name")].Stop();
  609. }
  610. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  611. window.frames[obj.attr("name")].Stop();
  612. }
  613. }
  614. //班长监测返回状态
  615. //坐席状态
  616. function AgentStateBack(data) {
  617. var obj = $("iframe:visible")
  618. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  619. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  620. }
  621. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  622. window.frames[obj.attr("name")].UpdateAgentState(data.AgentID, data.State);
  623. }
  624. }
  625. //线路状态
  626. function LineStateBack(data) {
  627. var obj = $("iframe:visible")
  628. if (obj.attr("data-id") == "./TelCall/SeatMonitor.html") {
  629. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  630. }
  631. if (obj.attr("data-id") == "./TelCall/zxKong.html") {
  632. window.frames[obj.attr("name")].UpdateLineState(data.AgentID, data.State);
  633. }
  634. }
  635. //后台排队
  636. function backstageQueue(data) {
  637. var obj = $("iframe:visible")
  638. // if (obj.attr("data-id") == "index_v1.html") {
  639. window.frames[obj.attr("name")].realTimeMonitorQueue(data.WaitCount);
  640. // }
  641. }
  642. //录音返回
  643. function RecordPathBack(data) {
  644. //if ($(".hidTel").val() && $(".hidCallID").val()) {
  645. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', { callid: $(".hidCallID").val(),path:data.RecPath, "token": $.cookie("token") }, function (result) {
  646. // result = JSON.parse(result);
  647. // if (result.state.toLowerCase() == "success") {
  648. // }
  649. // })
  650. //}
  651. // if ($(".hidTel").val()) {
  652. // $.post(huayi.config.callcenter_url + 'CallInScreen/UpdateLY', {
  653. // callid: data.CallID,
  654. // path: data.RecPath,
  655. // "token": $.cookie("token")
  656. // }, function (result) {
  657. // result = JSON.parse(result);
  658. // if (result.state.toLowerCase() == "success") { }
  659. // })
  660. // }
  661. $.cookie("makeCallId", data.CallID)
  662. }
  663. //在线坐席信息
  664. function GetAgentListBack(data) {
  665. console.log(data)
  666. $.ajax({
  667. type: "get",
  668. url: huayi.config.callcenter_url + "SeatMonitoring/GetAgentList",
  669. async: true,
  670. dataType: 'json',
  671. data: {
  672. "token": $.cookie("token")
  673. },
  674. success: function (result) {
  675. var user = result.data;
  676. $(user).each(function (j, m) {
  677. $(data.AgentList).each(function (k, g) {
  678. if (g.AgentID == m.UserCode) {
  679. g.userName = m.UserName;
  680. }
  681. })
  682. })
  683. $(data.AgentList).each(function (k, m) {
  684. var strr = '';
  685. switch (m.State) {
  686. case "0":
  687. strr = "离线";
  688. break; //离线
  689. case "1":
  690. break; //登录中
  691. case "2":
  692. strr = "空闲";
  693. break; //空闲
  694. case "3":
  695. strr = "通话中";
  696. break; //通话中
  697. case "4":
  698. strr = "话后处理中";
  699. break; //话后处理中
  700. case "5":
  701. strr = "忙碌";
  702. break; //小休
  703. case "6":
  704. strr = "振铃";
  705. break; //被请求
  706. case "7":
  707. strr = "注销";
  708. break; //注销
  709. }
  710. var html = '<tr fjh="' + m.AgentExten + '">' +
  711. '<td>' + (m.userName ? '' : m.userName) + '</td>' //姓名
  712. +
  713. '<td>' + m.AgentID + '</td>' //工号
  714. +
  715. '<td>' + m.AgentExten + '</td>'//分机号
  716. +
  717. '<td class=" ' + m.UserCode + 'state">' + strr + '</td>' //状态
  718. +
  719. '</tr>';
  720. $(html).appendTo("#zxTable tbody");
  721. })
  722. }
  723. });
  724. }
  725. //获取当前的日期时间 格式“yyyy-MM-dd HH:mm:ss”
  726. function getNowFormatDate() {
  727. var date = new Date();
  728. var seperator1 = "-";
  729. var seperator2 = ":";
  730. var month = date.getMonth() + 1;
  731. var strDate = date.getDate();
  732. if (month >= 1 && month <= 9) {
  733. month = "0" + month;
  734. }
  735. if (strDate >= 0 && strDate <= 9) {
  736. strDate = "0" + strDate;
  737. }
  738. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
  739. " " + date.getHours() + seperator2 + date.getMinutes() +
  740. seperator2 + date.getSeconds();
  741. return currentdate;
  742. }
  743. var iswebcloase = 1;
  744. window.onunload = function () {
  745. if (iswebcloase) {
  746. iswebcloase = 0;
  747. if (ws.readyState == ws.OPEN) {
  748. obj.Type = 'Logout';
  749. Send();
  750. ws.onclose();
  751. }
  752. }
  753. }
  754. window.onbeforeunload = function () {
  755. if (iswebcloase) {
  756. iswebcloase = 0;
  757. if (ws.readyState == ws.OPEN) {
  758. obj.Type = 'Logout';
  759. Send();
  760. ws.onclose();
  761. }
  762. }
  763. }