郑州第一人民医院UI

index.js 23KB

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