Sin descripción

index.js 26KB

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