Nenhuma Descrição

index.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /**
  2. * 首页js
  3. * */
  4. var $storages = window.localStorage;
  5. var taskRealInfoTimer = null;
  6. var isTaskTimerOn = false; //定时器是否开启
  7. //录音的路径
  8. var recordpath = '';
  9. $(document).ready(function() {
  10. if (/mobile/i.test(navigator.userAgent) || /android/i.test(navigator.userAgent)) {
  11. $(".title-box").hide();
  12. }
  13. // 判断大屏按钮
  14. console.log($storages.getItem('roleCode'))
  15. if ($storages.getItem('roleCode') == "CJGL") {
  16. $('#bgview').show()
  17. } else {
  18. $('#bgview').hide()
  19. }
  20. if (window.localStorage.getItem('token') == null) {
  21. window.location.href = "./login.html";
  22. }
  23. //获取当前用户的信息
  24. getUserInfo();
  25. //加载左侧导航菜单
  26. loadMenu();
  27. //话务相关
  28. $("#top-search li").click(function(event) {
  29. event.stopPropagation();
  30. if ($(this).find("i").hasClass("active")) {
  31. if (!window.localStorage.getItem('extno')) {
  32. layer.confirm('分机号不存在,请重新登录...', {
  33. icon: 7,
  34. closeBtn: 0,
  35. btn: ['确定'], //按钮
  36. yes: function() {
  37. window.location.href = "login.html";
  38. }
  39. });
  40. return;
  41. }
  42. //坐席工号
  43. if (window.localStorage.getItem('userCode')) {
  44. var fun = $(this).attr("datafun");
  45. switch (fun) {
  46. case "Login": //签入
  47. scoketDatas = {
  48. "Type": fun,
  49. "AgentID": window.localStorage.getItem('userCode'),
  50. "AgentExten": window.localStorage.getItem("extno"),
  51. "AgentGroup": window.localStorage.getItem('group'), //坐席组id
  52. "AgentType": "0",
  53. "DisposeTime": "0", //话后处理时长设置,0代表一致话后处理,除非发送置闲 (按照历史习惯,字符串形式)
  54. };
  55. Send();
  56. break;
  57. case "MakeCall": //外呼
  58. // $(".hidCallID").val("");
  59. $("#hidwhtype").val(fun);
  60. whtp();
  61. break;
  62. case "Meeting": //多方通话
  63. $("#hidwhtype").val(fun);
  64. whtp();
  65. break;
  66. case "Transfer": //转移
  67. $("#hidwhtype").val(fun);
  68. whtp();
  69. break;
  70. case "Consult": //协商呼叫
  71. $("#hidwhtype").val(fun);
  72. whtp();
  73. break;
  74. default:
  75. scoketDatas = {
  76. "Type": fun,
  77. "AgentID": window.localStorage.getItem('userCode'),
  78. "AgentExten": window.localStorage.getItem("extno"),
  79. };
  80. Send();
  81. break;
  82. }
  83. }
  84. }
  85. });
  86. //关闭外呼弹屏
  87. $(".closes").click(function() {
  88. $(".WH").removeClass("fadeInDown").addClass("fadeOutUp");
  89. $(".WH").addClass("hidens");
  90. });
  91. //外呼呼出
  92. $(".CallOut").click(function(event) {
  93. // 813811115503
  94. event.stopPropagation();
  95. if ($("#Result").val()) {
  96. $.ajax({
  97. type: "get",
  98. url: huayi.config.call_url + "CallOutOpt/GetCallOutprefix",
  99. async: true,
  100. dataType: 'json',
  101. data: {
  102. phone: $("#Result").val()
  103. },
  104. success: function(result) {
  105. //result = $.parseJSON(result);
  106. if (result.state.toLowerCase() == "success") {
  107. switch ($("#hidwhtype").val()) {
  108. case "MakeCall":
  109. scoketDatas = {
  110. "Type": $("#hidwhtype").val(),
  111. "AgentID": window.localStorage.getItem('userCode'),
  112. "AgentExten": window.localStorage.getItem("extno"),
  113. "Header": result.data.fix, //号码前缀 用于截断前缀得到真实号码
  114. "DestinationNumber": result.data.phone, //
  115. };
  116. break;
  117. case "Meeting":
  118. scoketDatas = {
  119. "Type": $("#hidwhtype").val(),
  120. "AgentID": window.localStorage.getItem('userCode'),
  121. "AgentExten": window.localStorage.getItem("extno"),
  122. "DestinationNumber": result.data.phone, //会议目标号码
  123. };
  124. break;
  125. case "Transfer":
  126. scoketDatas = {
  127. "Type": $("#hidwhtype").val(),
  128. "AgentID": window.localStorage.getItem('userCode'),
  129. "AgentExten": window.localStorage.getItem("extno"),
  130. "DestinationNumber": result.data.phone, //转移目标号码
  131. };
  132. break;
  133. case "Consult": //协商呼叫
  134. scoketDatas = {
  135. "Type": $("#hidwhtype").val(),
  136. "AgentID": window.localStorage.getItem('userCode'),
  137. "AgentExten": window.localStorage.getItem("extno"),
  138. "Callee": result.data.phone, //对方号码
  139. "Caller": window.localStorage.getItem("extno") //自己的号码(分机号)
  140. };
  141. break;
  142. default:
  143. break;
  144. }
  145. Send();
  146. $(".closes").trigger('click'); //关闭弹屏
  147. }
  148. }
  149. });
  150. } else {
  151. layer.confirm('请输入外呼号码', {
  152. icon: 7,
  153. closeBtn: 0,
  154. btn: ['确定'] //按钮
  155. })
  156. }
  157. })
  158. //外呼弹屏数字键盘点击样式
  159. $(".Num_ul .dNum").mousedown(function() {
  160. $(this).addClass("actives");
  161. $(".img").removeClass("hidens");
  162. }).mouseup(function() {
  163. $(this).removeClass("actives");
  164. });
  165. //外呼弹屏数字键盘号码输入
  166. $(".Num_ul li .dNum").click(function() {
  167. var rt = $("#Result").val() + "";
  168. if (rt.length < 17) {
  169. rt = rt + $(this).find("a").text();
  170. $("#Result").val(rt);
  171. } else {
  172. layer.msg('号码长度不能超过16位!');
  173. }
  174. });
  175. //外呼弹屏数字键盘号码截取(删除)
  176. $(".img").click(function() {
  177. var Result = $("#Result").val() + "";
  178. Result = Result.substr(0, Result.length - 1);
  179. $("#Result").val(Result);
  180. if (Result.length == 0) {
  181. $(".img").addClass("hidens");
  182. }
  183. });
  184. //外呼电话列表
  185. $(".bg_title li").click(function() {
  186. $(this).addClass("lactive").siblings().removeClass("lactive");
  187. loadWH();
  188. });
  189. //搜索
  190. $(".sc_btns").click(function() {
  191. loadWH();
  192. });
  193. });
  194. //验证拨号长度
  195. function regTelNums() {
  196. var rt = $("#Result").val() + "";
  197. if (rt.length === 0) {
  198. $(".img").addClass("hidens");
  199. } else {
  200. $(".img").removeClass("hidens");
  201. if (rt.length < 17) {
  202. $("#Result").val(rt);
  203. } else {
  204. $("#Result").val(rt.substring(0, 16));
  205. layer.msg('号码长度不能超过16位!');
  206. }
  207. }
  208. }
  209. //菜单数字
  210. workcount()
  211. //setInterval(function() {
  212. // workcount();
  213. //}, huayi.config.menuworktime);
  214. function workcount() {
  215. $.post(huayi.config.callcenter_url + "equipmentapi/api/worepairbase/Getinfotx", {
  216. "token": $.cookie("token")
  217. }, function(result) {
  218. result = JSON.parse(result);
  219. if (result.state.toLowerCase() == "success") {
  220. if (result.data.total) {
  221. $(".bxgd").text(result.data.total)
  222. }
  223. }
  224. })
  225. }
  226. //外呼弹屏
  227. function whtp() {
  228. $("#Result").val("");
  229. if ($(".WH").hasClass("fadeOutUp")) {
  230. $(".WH").removeClass("fadeOutUp").addClass("fadeInDown");
  231. }
  232. $(".WH").removeClass("hidens");
  233. $('.first').removeClass('first');
  234. $('.WH').addClass('first');
  235. //键盘事件外呼
  236. document.onkeydown = function(e) {
  237. var theEvent = window.event || e;
  238. var code = theEvent.keyCode || theEvent.which;
  239. if (code == 13) {
  240. $(".CallOut").click();
  241. }
  242. }
  243. loadWH();
  244. }
  245. //加载外呼电话列表
  246. function loadWH() {
  247. var loadWHindex = $('.bg_title').find('.lactive').attr('itemid');
  248. $(".phonediv").eq(loadWHindex).addClass('show_phonediv').siblings().removeClass('show_phonediv');
  249. var table = $(".phonediv").eq(loadWHindex).find(".phonelist");
  250. switch (loadWHindex) {
  251. case '0':
  252. //先销毁表格
  253. table.bootstrapTable('destroy');
  254. //初始化表格,动态从服务器加载数据
  255. table.bootstrapTable({
  256. method: "get", //使用get请求到服务器获取数据
  257. url: huayi.config.callcenter_url + "callcenterapi/api/CallRecords/getlistbypage", //获取数据的Servlet地址
  258. contentType: 'application/x-www-form-urlencoded',
  259. striped: true, //表格显示条纹
  260. pagination: true, //启动分页
  261. pageSize: 10, //每页显示的记录数
  262. pageNumber: 1, //当前第几页
  263. pageList: [10, 20, 50, 100], //记录数可选列表
  264. search: false, //是,//否启用查询
  265. showColumns: false, //显示下拉框勾选要显示的列
  266. showRefresh: false, //显示刷新按钮
  267. sidePagination: "server", //表示服务端请求
  268. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  269. //设置为limit可以获取limit, offset, search, sort, order
  270. queryParamsType: "undefined",
  271. queryParams: function queryParams(params) { //设置查询参数
  272. var param = {
  273. pageindex: params.pageNumber, //否 string 当前页
  274. pagesize: params.pageSize, //否 string 每页记录数
  275. keyword: $('#sc_tel').val(), // 否 string 模糊查询(呼叫号码)
  276. // stime: $("#old_scTime").val() && $("#old_scTime").val().split(' ~ ')[0], //否 string 工单起止时间
  277. // etime: $("#old_scTime").val() && $("#old_scTime").val().split(' ~ ')[1], //否 string 工单起止时间
  278. };
  279. return param;
  280. },
  281. onLoadSuccess: function(res) { //加载成功时执行
  282. //layer.msg("加载成功");
  283. if (res.state.toLowerCase() === "success") {
  284. var newData = {};
  285. newData.state = res.state;
  286. newData.message = res.message;
  287. newData.rows = res.data.rows;
  288. newData.total = res.data.total;
  289. recordpath = res.data.recordpath;
  290. table.bootstrapTable('load', newData);
  291. }
  292. },
  293. onLoadError: function() { //加载失败时执行
  294. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  295. }
  296. });
  297. break;
  298. case '1':
  299. break;
  300. case '2':
  301. table.bootstrapTable('destroy');
  302. //初始化表格,动态从服务器加载数据
  303. table.bootstrapTable({
  304. method: "get", //使用get请求到服务器获取数据
  305. url: huayi.config.callcenter_url + "callcenterapi/api/CusUser/getlistbypage", //获取数据的Servlet地址
  306. contentType: "application/x-www-form-urlencoded",
  307. striped: true, //表格显示条纹
  308. pagination: true, //启动分页
  309. pageSize: 10, //每页显示的记录数
  310. pageNumber: 1, //当前第几页
  311. pageList: [10, 20, 50, 100], //记录数可选列表
  312. search: false, //是否启用查询
  313. showColumns: false, //显示下拉框勾选要显示的列
  314. showRefresh: false, //显示刷新按钮
  315. sidePagination: "server", //表示服务端请求
  316. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  317. //设置为limit可以获取limit, offset, search, sort, order
  318. queryParamsType: "undefined",
  319. queryParams: function queryParams(params) { //设置查询参数
  320. var param = {
  321. pageindex: params.pageNumber, //否 string 当前页
  322. pagesize: params.pageSize, //否 string 每页记录数
  323. key: $('#sc_key').val(), //否 string 模糊查询(姓名,手机号码,固话)
  324. //typeid 否 string 类型id
  325. // stime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[0], //开始时间
  326. // etime: $('#sc_times').val() && $('#sc_times').val().split(' ~ ')[1], //结束时间
  327. };
  328. return param;
  329. },
  330. responseHandler: function(res) {
  331. return {
  332. "total": res.data && res.data.total, //总页数
  333. "rows": res.data && res.data.rows //数据
  334. };
  335. },
  336. onLoadSuccess: function(res) { //加载成功时执行
  337. //layer.msg("加载成功");
  338. },
  339. onLoadError: function() { //加载失败时执行
  340. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  341. }
  342. });
  343. break;
  344. }
  345. }
  346. //格式化手机号码
  347. function formatterCallTel(val) {
  348. if (val) {
  349. return '<a href="javascript:;" class="xg" onclick="btn_call(\'' + val + '\')">' + val + '</a>';
  350. }
  351. }
  352. //给外呼键盘赋值
  353. function btn_call(cphone) {
  354. if (cphone.indexOf('-') != -1) {
  355. cphone = cphone.replace('-', '');
  356. }
  357. $('#Result').val(cphone);
  358. $('#Result').trigger('keyup');
  359. }
  360. //格式化 呼叫类型
  361. function formatterCalltype(val, row) {
  362. //(0:呼入,1:呼出)
  363. var str = '-';
  364. if (val === 0) {
  365. str = '呼入';
  366. } else {
  367. str = '呼出';
  368. }
  369. return str;
  370. }
  371. //格式化 呼叫状态
  372. function formatterCallstate(val, row) {
  373. //(0:未接通,1:已接通)
  374. var str = '-';
  375. var stateClass = 'timeout_default';
  376. if (val === 0) {
  377. str = '未接通';
  378. stateClass = 'timeout_termination';
  379. } else {
  380. str = '已接通';
  381. stateClass = 'timeout_success';
  382. }
  383. return '<span class="' + stateClass + '">' + str + '</span>';
  384. }
  385. //格式化处理方式
  386. function formatterDealtype(val, row) {
  387. //(0:IVR处理 1:骚扰电话 2:自助服务 3:转值班电话 4:留言 5:呼损 6:人工处理)
  388. var str = '-';
  389. switch (val) {
  390. case 0:
  391. str = "IVR处理"
  392. break;
  393. case 1:
  394. str = "骚扰电话"
  395. break;
  396. case 2:
  397. str = "自助服务"
  398. break;
  399. case 3:
  400. str = "转值班电话"
  401. break;
  402. case 4:
  403. str = "留言"
  404. break;
  405. case 5:
  406. str = "呼损"
  407. break;
  408. case 6:
  409. str = "人工处理"
  410. break;
  411. default:
  412. str = "-"
  413. break;
  414. }
  415. return str;
  416. }
  417. //格式化外呼类型
  418. function formatterCallopttype(val, row) {
  419. //( 0:拨号外呼 1:回访外呼)
  420. var str = '-';
  421. switch (val) {
  422. case 0:
  423. str = "拨号外呼"
  424. break;
  425. case 1:
  426. str = "回访外呼"
  427. break;
  428. default:
  429. str = "-"
  430. break;
  431. }
  432. return str;
  433. }
  434. //音频
  435. function formatterAudio(val) {
  436. var audioUrl = recordpath + val;
  437. if (val && val.length > 0) {
  438. return '<div class="imgs" style="cursor: pointer;">' +
  439. '<img src="img/vice.png" alt="录音" onclick="seeAudio(\'' + audioUrl + '\')" />' +
  440. '</div>';
  441. } else {
  442. return '-';
  443. }
  444. }
  445. //查看录音详情
  446. function seeAudio(audioUrl) {
  447. layer.open({
  448. type: 2,
  449. content: "templateHtml/audioPlayer.html?audioUrl=" + audioUrl, //iframe的url,no代表不显示滚动条
  450. title: '录音详情',
  451. area: ['50%', '280px'], //宽高
  452. });
  453. }
  454. //格式化地址
  455. function formatterAddress(val, row) {
  456. var locations = '';
  457. var address = '';
  458. if (val) {
  459. locations = val + row.cityname;
  460. }
  461. if (row.address) {
  462. address = row.address;
  463. }
  464. return locations + address;
  465. }
  466. //格式化创建人
  467. function formatterCreateuser(val, row) {
  468. return val + '-' + row.createusername;
  469. }
  470. //左侧菜单
  471. function loadMenu() {
  472. var menuData = top.clients.authorizeMenu.Result;
  473. var _html = "";
  474. $.each(menuData, function(i) {
  475. var row = menuData[i];
  476. if (-(row.parent_id) == 0) {
  477. _html += '<li>';
  478. var childNodes = row.childnodes; //二级
  479. if (childNodes.length > 0) {
  480. _html += '<a class="Click" data-id="Menu_' + row.id + '" data-target="' + row.target + '" href="' + row.opt_url +
  481. '"><i class="fa iconfont">' + row.img_url + '</i><span class="nav-label">' + row.module_name +
  482. '</span><span class="fa arrows iconfont"></span></a>';
  483. _html += '<ul class="nav nav-second-level">';
  484. $.each(childNodes, function(i) {
  485. var subrow = childNodes[i];
  486. var childNodsThird = subrow.childnodes; //三级
  487. if (childNodsThird.length > 0) {
  488. _html += '<li>';
  489. _html += '<a href="' + subrow.opt_url + '">';
  490. _html += '<span class="nav-label">' + subrow.module_name + '</span>';
  491. _html += '<span class="fa arrows iconfont"></span>';
  492. _html += '</a>';
  493. _html += '<ul class="nav nav-third-level">';
  494. $.each(childNodsThird, function(i) {
  495. var subrowThird = childNodsThird[i];
  496. _html += '<li>';
  497. _html += '<a class="J_menuItem" data-id="Menu_' + subrowThird.id + '" data-target="' + subrowThird.target +
  498. '" href="' + subrowThird.opt_url + '" >' + subrowThird.module_name + '</a>';
  499. _html += '</li>';
  500. });
  501. _html += '</ul>';
  502. } else {
  503. _html += '<li>';
  504. _html += '<a class="J_menuItem" data-id="Menu_' + subrow.id + '" data-target="' + subrow.target + '" href="' +
  505. subrow.opt_url + '" >' + subrow.module_name + '</a>';
  506. if (subrow.module_name == '报修工单') {
  507. _html += '<span class="label label-warning pull-right lblcount bxgd"></span>';
  508. }
  509. _html += '</li>';
  510. }
  511. });
  512. _html += '</ul>';
  513. } else {
  514. _html += '<a class="Click"data-id="Menu_' + row.id + '" href="' + row.opt_url + '"><i class="fa iconfont">' + row
  515. .img_url + '</i><span class="nav-label">' + row.module_name + '</span></a>';
  516. }
  517. _html += '</li>';
  518. }
  519. });
  520. $(_html).appendTo("#side-menu");
  521. //绑定点击事件 添加点击的样式
  522. $('#side-menu').find('.J_menuItem').on('click', function() {
  523. $(this).parent().addClass('sub_active').siblings().removeClass('sub_active');
  524. });
  525. }
  526. //跳转
  527. function jumps() {
  528. $("iframe:visible")[0].src = "widgets.html"
  529. $(".J_menuTab").eq(0).addClass("active").text('首页');
  530. $(".J_menuTab").eq(0).attr("data-id", 'widgets.html');
  531. $(".J_mainContent .J_iframe0").attr("data-id", "widgets.html");
  532. }
  533. // 大屏跳转
  534. function enterbg() {
  535. window.open('http://192.168.5.46/WebChart/index.html')
  536. }
  537. //设置
  538. function settings() {
  539. layer.open({
  540. type: 2,
  541. content: "./templateHtml/personalCenter.html", //iframe的url,no代表不显示滚动条
  542. title: '设置',
  543. resize: false,
  544. area: ['50%', '60%'], //宽高
  545. });
  546. }
  547. //退出
  548. function logout() {
  549. window.localStorage.removeItem('token');
  550. window.localStorage.removeItem('headImg');
  551. window.localStorage.removeItem('userName');
  552. window.localStorage.removeItem('userCode');
  553. window.localStorage.removeItem('roleName');
  554. window.localStorage.removeItem('seatFlag');
  555. window.localStorage.removeItem('extno');
  556. window.localStorage.removeItem('group');
  557. window.localStorage.removeItem('deptId');
  558. window.localStorage.removeItem('teamId');
  559. window.localStorage.removeItem('mobile');
  560. location.href = "./login.html";
  561. }
  562. //获取当前用户信息
  563. function getUserInfo() {
  564. //用户名
  565. $(".username").text(window.localStorage.getItem('userName'));
  566. //用户角色
  567. $(".rolename").text(window.localStorage.getItem('roleName'));
  568. //用户头像
  569. if (window.localStorage.getItem('headImg')) {
  570. $('#head_img').attr('src', window.localStorage.getItem('headImg'));
  571. } else {
  572. $('#head_img').attr('src', './img/zxPhone.png');
  573. }
  574. //话务标志,意思是否具备接听和呼叫电话的功能(false:非话务;true 话务标志)
  575. var seatFlag = window.localStorage.getItem('seatFlag');
  576. if (seatFlag === "true") {
  577. //话务控制条
  578. $('#navbarTopLinks').css('display', 'block');
  579. //分机号
  580. if (window.localStorage.getItem("extno")) {
  581. $(".Gnum").text('(' + window.localStorage.getItem("extno") + ')');
  582. }
  583. Connect();
  584. //话机、坐席状态
  585. $(".zts .phoneType").show();
  586. }
  587. }
  588. //签入成功后并且分配有任务的时候 弹出 相关计划任务
  589. function btn_joinTask() {
  590. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  591. $.ajax({
  592. type: "get",
  593. url: huayi.config.call_url + "callcenterapi/api/autocallouttask/getqrjoinlist",
  594. dataType: 'json',
  595. async: true,
  596. data: {
  597. //agentid 否 string 坐席工号(不传值默认登录坐席工号)
  598. //joinflag 否 int 参与标志(不传值获取分配给坐席的全部任务,传值0获取未参与任务,传值1获取参与任务)
  599. },
  600. success: function(data) {
  601. if (data.state.toLowerCase() === "success") {
  602. data = data.data;
  603. if (data && data.length > 0) {
  604. //弹出任务信息(签入时传参数)
  605. switchingTask(true);
  606. }
  607. dtd.resolve(); // 改变Deferred对象的执行状态
  608. }
  609. },
  610. error: function(textStatus) {
  611. layer.confirm('网络繁忙,请稍后再试...', {
  612. icon: 7,
  613. closeBtn: 0,
  614. btn: ['确定'] //按钮
  615. });
  616. },
  617. complete: function(XMLHttpRequest, textStatus) {
  618. if (textStatus == 'timeout') {
  619. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  620. xmlhttp.abort();
  621. layer.confirm('网络超时,请稍后再试...', {
  622. icon: 7,
  623. closeBtn: 0,
  624. btn: ['确定'] //按钮
  625. });
  626. }
  627. },
  628. });
  629. return dtd.promise(); // 返回promise对象
  630. }
  631. //签入成功后 显示右上角 当前参与任务信息
  632. function getTaskRealInfo() {
  633. $.ajax({
  634. type: "get",
  635. url: huayi.config.call_url + "callcenterapi/api/autocallouttask/getjoinlist",
  636. dataType: 'json',
  637. async: true,
  638. data: {
  639. // agentid: window.localStorage.getItem('userCode'),// 否 string 坐席工号(不传值默认登录坐席工号)
  640. joinflag: 1, //否 int 参与标志(不传值获取分配给坐席的全部任务,传值0获取未参与任务,传值1获取参与任务)
  641. },
  642. success: function(data) {
  643. if (data.state.toLowerCase() === "success") {
  644. // console.log('...............右上角信息...................');
  645. // console.log(data);
  646. data = data.data;
  647. if (data && data.length > 0) {
  648. $('#task_real_info').find('.task_num').text(data[0].totalnum); //任务量
  649. $('#task_real_info').find('.task_surNum').text(data[0].surplusnum); //剩余量
  650. $('#task_real_info').find('.task_name').text(data[0].taskname); //计划名称
  651. } else {
  652. $('#task_real_info').find('.task_num').text('0');
  653. $('#task_real_info').find('.task_surNum').text('0');
  654. $('#task_real_info').find('.task_name').text('当前没有参与任务');
  655. }
  656. }
  657. },
  658. error: function(textStatus) {
  659. layer.confirm('网络繁忙,请稍后再试...', {
  660. icon: 7,
  661. closeBtn: 0,
  662. btn: ['确定'] //按钮
  663. });
  664. },
  665. complete: function(XMLHttpRequest, textStatus) {
  666. if (textStatus == 'timeout') {
  667. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  668. xmlhttp.abort();
  669. layer.confirm('网络超时,请稍后再试...', {
  670. icon: 7,
  671. closeBtn: 0,
  672. btn: ['确定'] //按钮
  673. });
  674. }
  675. },
  676. });
  677. }
  678. /**
  679. * 刷新数据 右上角 当前参与任务信息
  680. * platformTime 刷新时间的间隔;
  681. *
  682. * */
  683. var refreshTaskRealInfo = function(platformTime) {
  684. var objTime = {
  685. init: 0,
  686. time: function() {
  687. if ($(document).find('.layui-layer').length === 0 && top.$("iframe:visible").contents().find('.layui-layer').length ===
  688. 0) {
  689. objTime.init += 1000;
  690. //console.log(objTime.init);
  691. //当页面layer 弹窗时;每间隔 huayi.config.taskRealInfoTime 刷新数据;
  692. if (objTime.init == platformTime) {
  693. getTaskRealInfo();
  694. objTime.init = 0;
  695. }
  696. }
  697. },
  698. eventFun: function() {
  699. clearInterval(taskRealInfoTimer);
  700. objTime.init = 0;
  701. if (isTaskTimerOn) {
  702. taskRealInfoTimer = setInterval(objTime.time, 1000);
  703. }
  704. },
  705. }
  706. taskRealInfoTimer = setInterval(objTime.time, 1000);
  707. var body = document.querySelector('html');
  708. var bodyIframe = top.$("iframe:visible").contents()[0].querySelector('html');
  709. body.addEventListener("click", objTime.eventFun);
  710. body.addEventListener("keydown", objTime.eventFun);
  711. body.addEventListener("mousemove", objTime.eventFun);
  712. body.addEventListener("mousewheel", objTime.eventFun);
  713. bodyIframe.addEventListener("click", objTime.eventFun);
  714. bodyIframe.addEventListener("keydown", objTime.eventFun);
  715. bodyIframe.addEventListener("mousemove", objTime.eventFun);
  716. bodyIframe.addEventListener("mousewheel", objTime.eventFun);
  717. }
  718. //切换任务
  719. //isLogin true(签入时传参数)
  720. function switchingTask(isLogin) {
  721. layer.open({
  722. // maxmin: true, //开启最大化最小化按钮
  723. type: 2,
  724. id: 'layer_switch_info',
  725. content: "templateHtml/joinTask.html?isLogin=" + isLogin, //iframe的url,no代表不显示滚动条
  726. title: '任务信息',
  727. area: ['50%', '86%'], //宽高
  728. end: function() {
  729. getTaskRealInfo(); //更新右上角任务信息
  730. },
  731. });
  732. }