开封利通水务前端

index.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. var isFirstShowTopMsg = true;
  2. $(document).ready(function() {
  3. if (/mobile/i.test(navigator.userAgent) || /android/i.test(navigator.userAgent)) {
  4. $(".title-box").hide();
  5. }
  6. if ($.cookie("token") == null) {
  7. window.location.href = "login.html";
  8. }
  9. obj.AgentExten = $.cookie("extno");
  10. if (obj.AgentExten == undefined) {
  11. $(".Gnumbox").hide();
  12. }
  13. $(".Gnum").text(obj.AgentExten);
  14. // 获取顶部获取消息
  15. getTopMsgs();
  16. setInterval(function() {
  17. getTopMsgs();
  18. }, huayi.config.topMsgTime);
  19. $.getJSON(huayi.config.callcenter_url + 'UserAccount/GetNowUser', {
  20. "token": $.cookie("token")
  21. }, function(result) {
  22. if (result.state.toLowerCase() == "success") {
  23. // console.log(result);
  24. // $.cookie("userType", result.data.usertype, {
  25. // expires: 7
  26. // });
  27. $.cookie("userRoleId", result.data.role.F_RoleId, {
  28. expires: 7
  29. });
  30. $.cookie("userRoleCode", result.data.role.F_RoleCode, {
  31. expires: 7
  32. });
  33. $(".username").text(result.data.user.F_UserName);
  34. $('.user_code').text(result.data.user.F_UserCode);
  35. localStorage.setItem('F_UserCode', result.data.user.F_UserCode)
  36. $('.group').text(result.data.user.F_SeartGroup);
  37. if (result.data.role) {
  38. // console.log(result.data);
  39. $(".rolename").text(result.data.role.F_RoleName);
  40. }
  41. $(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) + result.data
  42. .user.F_See);
  43. obj.AgentGroup = result.data.user.F_SeartGroupID;
  44. obj.AgentID = result.data.user.F_UserCode;
  45. //obj.AgentExten = result.data.user.F_WorkNumber;
  46. if (result.data.user.F_SeatFlag) {
  47. Connect();
  48. $("#top-search").show();
  49. $(".phoneBZ").show();
  50. $(".zts").show();
  51. }
  52. }
  53. })
  54. //分机号
  55. //话务相关
  56. $("#top-search li").click(function() {
  57. if ($(this).find("i").hasClass("active")) {
  58. if (obj.AgentID) {
  59. var fun = $(this).attr("datafun");
  60. obj.Type = fun;
  61. switch (fun) {
  62. case "Login":
  63. // obj.AgentGroup = "364";
  64. obj.AgentType = "0";
  65. Send();
  66. break; //签入
  67. case "MakeCall":
  68. obj.Type = "SayFree";
  69. Send(); //备注:用户要求外呼立刻置闲
  70. $(".hidCallID").val("");
  71. $("#hidwhtype").val(fun);
  72. whtp();
  73. //obj.DestinationNumber = "1012";
  74. break; //外呼
  75. case "Meeting":
  76. $("#hidwhtype").val(fun);
  77. whtp();
  78. //obj.DestinationNumber = "1012";
  79. break; //多方通话
  80. case "Transfer":
  81. $("#hidwhtype").val(fun);
  82. whtp();
  83. //obj.DestinationNumber = "1012";
  84. break; //转移
  85. default:
  86. Send();
  87. break;
  88. }
  89. }
  90. }
  91. });
  92. //关闭外呼弹屏
  93. $(".closes").click(function() {
  94. $(".WH").removeClass("fadeInDown").addClass("fadeOutUp");
  95. $(".WH").addClass("hidens");
  96. })
  97. $(".J_menuTabs").on("click" ,'.fa',function(){
  98. $(".SayBusy").addClass("active");
  99. $(".SayFree").removeClass("active");
  100. $(".zxzt").removeClass("br").removeClass("by").addClass("bl");
  101. $(".hwzt").text('空闲');
  102. obj.Type = "SayFree";
  103. Send();
  104. });
  105. //键盘事件外呼
  106. document.onkeydown = function(e) {
  107. var theEvent = window.event || e;
  108. var code = theEvent.keyCode || theEvent.which;
  109. if (code == 13) {
  110. $(".CallOut").click();
  111. }
  112. }
  113. //外呼呼出
  114. $(".CallOut").click(function(event) {
  115. event.stopPropagation();
  116. if ($("#Result").val()) {
  117. $.ajax({
  118. type: "get",
  119. url: huayi.config.callcenter_url + "CallOutOpt/GetCallOutprefix",
  120. async: true,
  121. dataType: 'json',
  122. data: {
  123. token: $.cookie("token"),
  124. phone: $("#Result").val()
  125. },
  126. success: function(result) {
  127. // result = $.parseJSON(result);
  128. if (result.state.toLowerCase() == "success") {
  129. var guid = uuid();
  130. obj.Type = $("#hidwhtype").val();
  131. obj.DestinationNumber = result.data.phone;
  132. obj.Header = result.data.fix;
  133. top.obj.TaskType = "0"; //0:拨号外呼;1:95005回访外呼;2:电销回访外呼
  134. top.obj.TaskPhoneID = ""; //回访的电话ID
  135. top.obj.TaskID = guid; //回访记录编号
  136. Send();
  137. $('#Result').val('');
  138. $(".WH").addClass("hidens");
  139. }
  140. }
  141. });
  142. // obj.Type = $("#hidwhtype").val();
  143. // obj.DestinationNumber = $("#Result").val();
  144. // Send();
  145. }
  146. })
  147. //外呼弹屏数字键盘样式
  148. $(".Num_ul div").mousedown(function() {
  149. $(this).addClass("actives");
  150. $(".img").removeClass("hidens");
  151. }).mouseup(function() {
  152. $(this).removeClass("actives");
  153. })
  154. //外呼弹屏数字键盘号码输入
  155. $(".Num_ul li div").click(function() {
  156. var rt = $("#Result").val() + "";
  157. if (rt.length < 18) {
  158. rt = rt + $(this).find("a").text();
  159. $("#Result").val(rt);
  160. }
  161. });
  162. //外呼弹屏数字键盘号码截取
  163. $(".img").click(function() {
  164. var Result = $("#Result").val() + "";
  165. Result = Result.substr(0, Result.length - 1);
  166. $("#Result").val(Result);
  167. if (Result.length == 0) {
  168. $(".img").addClass("hidens");
  169. }
  170. })
  171. //外呼电话列表
  172. $(".bg_title li").click(function() {
  173. $(this).addClass("lactive").siblings().removeClass("lactive");
  174. loadWH();
  175. })
  176. $(".ty").click(function() {
  177. loadWH();
  178. });
  179. //加载左侧导航菜单
  180. loadMenu();
  181. workcount();
  182. setInterval(function() {
  183. workcount();
  184. $.cookie("token", $.cookie("token"), {expires: 7});
  185. }, huayi.config.menuworktime);
  186. //修改密码开始
  187. $('.shezhi').click(function() {
  188. Dialog('dialogDrag', 'dialogMove');
  189. showDialog();
  190. //侦听浏览器窗口大小变化
  191. window.onresize = function() {
  192. if ($('#dialogMove').is(':visible')) {
  193. showDialog();
  194. }
  195. }
  196. $.ajax({
  197. type: "get",
  198. url: huayi.config.callcenter_url + "UserAccount/GetNowUser",
  199. async: true,
  200. dataType: 'json',
  201. data: {
  202. token: $.cookie("token")
  203. },
  204. success: function(result) {
  205. if (result.state.toLowerCase() == "success") {
  206. var con = result.data.user;
  207. // console.log(con)
  208. $('.mgh').val(con.F_UserId);
  209. $('.mn').val(con.F_UserName);
  210. $('.mobile').val(con.F_Mobile);
  211. $('.fenji').val($.cookie("extno"));
  212. //$('.wxno').val(con.F_WXNo);
  213. // $('.spwd').val(con.F_Password);
  214. }
  215. }
  216. });
  217. })
  218. //tab切换
  219. $('.perTab li').click(function() {
  220. $(this).addClass('sel').siblings().removeClass('sel');
  221. var index = $(this).index();
  222. $('.perTab_con').children('div').eq(index).show().siblings().hide();
  223. })
  224. //编辑个人资料
  225. $('.grzl tbody>tr>td input.zhidu').attr('readonly', true);
  226. $('.grbj').click(function() {
  227. $('.grzl tbody>tr>td input.zhidu').attr('readonly', false);
  228. $('.grzl tbody>tr>td input.zhidu').css('border-bottom', "1px solid #b3b3b3");
  229. $('.grbtn').attr('disabled', false);
  230. })
  231. //取消编辑
  232. $('.grqx').click(function() {
  233. $('.grzl tbody>tr>td input.zhidu').attr('readonly', true);
  234. $('.grzl tbody>tr>td input.zhidu').css('border-bottom', "none");
  235. $('.grbtn').attr('disabled', true);
  236. })
  237. //关闭按钮
  238. $('.ptr').click(function() {
  239. hideDialog();
  240. })
  241. $('.grbtn').click(function() {
  242. var gh = $('.mgh').val();
  243. var xm = $('.mn').val();
  244. var ymm = $('.spwd').val();
  245. var xmm = $('.npwd').val();
  246. var qmm = $('.epwd').val();
  247. if (xmm !== qmm) {
  248. $('.wrong').show();
  249. $('.npwd').val('')
  250. $('.epwd').val('')
  251. } else if (xmm == '') {
  252. layer.msg("密码不允许为空!");
  253. } else {
  254. $('.wrong').hide();
  255. $('.grzl tbody>tr>td input').attr('readonly', true);
  256. $('.grzl tbody>tr>td input').css('border-bottom', "none");
  257. $.ajax({
  258. type: "post",
  259. url: huayi.config.callcenter_url + "UserAccount/UpdatePwd",
  260. async: true,
  261. dataType: 'json',
  262. data: {
  263. token: $.cookie("token"),
  264. usercode: gh,
  265. pwd: xmm,
  266. oldpwd: ymm,
  267. mobile: $('.mobile').val()
  268. },
  269. success: function(result) {
  270. // result = $.parseJSON(result);
  271. if (result.state.toLowerCase() == "success") {
  272. layer.msg("修改成功!");
  273. }
  274. }
  275. });
  276. }
  277. })
  278. //图片裁剪
  279. var o = $(".image-crop > img");
  280. $(o).cropper({
  281. aspectRatio: 1 / 1,
  282. resizable: false,
  283. dragCrop: false,
  284. preview: ".img-preview",
  285. done: function() {}
  286. });
  287. var r = $("#inputImage");
  288. if (window.FileReader) {
  289. r.change(function() {
  290. var e, i = new FileReader,
  291. t = this.files;
  292. if (t.length && (e = t[0], /^image\/\w+$/.test(e.type))) {
  293. i.readAsDataURL(e);
  294. i.onload = function() {
  295. r.val("");
  296. o.cropper("reset", !0).cropper("replace", this.result);
  297. }
  298. } else {
  299. alert("请选择图片文件");
  300. }
  301. });
  302. $("#setDrag").click(function() {
  303. o.cropper("setDragMode", "crop");
  304. var img = o.cropper("getDataURL");
  305. $.post(huayi.config.callcenter_url + "Index/UploadTX64", {
  306. dataurl: encodeURIComponent(img),
  307. "token": $.cookie("token")
  308. }, function(result) {
  309. result = $.parseJSON(result);
  310. if (result.state.toLowerCase() == "success") {
  311. $(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) +
  312. result.data);
  313. layer.msg("上传成功");
  314. hideDialog();
  315. }
  316. })
  317. });
  318. $("#zoomIn").click(function() {
  319. o.cropper("zoom", .1)
  320. });
  321. $("#zoomOut").click(function() {
  322. o.cropper("zoom", -.1)
  323. });
  324. $("#rotateLeft").click(function() {
  325. o.cropper("rotate", 45)
  326. });
  327. $("#rotateRight").click(function() {
  328. o.cropper("rotate", -45)
  329. });
  330. } else {
  331. r.addClass("hide");
  332. }
  333. //新工单提示开始
  334. $('.add_blank').click(function(){
  335. $('.add_blank').css('display','none')
  336. });
  337. function timeout() {
  338. var res;
  339. $.ajax({
  340. url:huayi.config.callcenter_url +'WorkOrder/GetList',
  341. type:'get',
  342. async:false,
  343. data:{
  344. token: $.cookie("token")
  345. },
  346. success:function (data) {
  347. var data=JSON.parse(data);
  348. res = data.total;
  349. window.localStorage.setItem('order_total',res)
  350. }
  351. });
  352. return res;
  353. }
  354. var i=timeout();
  355. console.log(i);
  356. function newOrderList() {
  357. $.ajax({
  358. url:huayi.config.callcenter_url +'WorkOrder/GetList',
  359. type:'get',
  360. async:false,
  361. data:{
  362. token: $.cookie("token")
  363. },
  364. success:function (result) {
  365. var result=JSON.parse(result).total;
  366. var a=window.localStorage.getItem('order_total')
  367. if (result > a){
  368. a = result;
  369. $(".add_blank").show();
  370. window.localStorage.setItem('order_total',a);
  371. playSaveHandler();
  372. }
  373. }
  374. });
  375. }
  376. setInterval(newOrderList,10000);
  377. setInterval(function(){
  378. $(".add_blank").hide();
  379. },9000);
  380. //新工单弹屏提示结束
  381. //新工单声音提示
  382. function playSaveHandler() {
  383. //播放语音
  384. var promise = $('#btn_audio')[0].play();
  385. if (promise !== undefined) {
  386. promise.then(function() {
  387. $('#btn_audio')[0].play();
  388. }).catch(function(error) {
  389. var context = new(window.AudioContext || window.webkitAudioContext)();
  390. playAudio(context, 'audio/orderTips.wav');
  391. });
  392. }
  393. }
  394. })
  395. //菜单数字
  396. function workcount() {
  397. $.getJSON(huayi.config.callcenter_url + 'Index/GetWorkOrderCount', {
  398. "token": $.cookie("token")
  399. }, function(result) {
  400. if (result.state.toLowerCase() == "success") {
  401. $(".dpd").text(result.data.dpd); //待指派
  402. $(".yzp").text(result.data.yzp); //已指派
  403. $(".djd").text(result.data.djd); //待接单
  404. $(".dcl").text(result.data.dcl); //待处理
  405. $(".ycl").text(result.data.ycl); //已处理
  406. $(".wyc").text(result.data.wyc); //已参与
  407. $(".cq").text(result.data.cq); //超期工单
  408. $(".wx").text(result.data.wx); //微信工单
  409. $(".dhf").text(result.data.dhf); //待回访
  410. $(".yhf").text(result.data.yhf); //已回访
  411. //"dpd":2,"djd":0,"dcl":0,"ycl":2,"wyc":6,"cq":0
  412. }
  413. })
  414. }
  415. //上传头像
  416. function uploadtx() {
  417. if (document.getElementById("upFile").files.length > 0) {
  418. var formData = new FormData();
  419. formData.append("upFile", document.getElementById("upFile").files[0]);
  420. formData.append("token", $.cookie("token"));
  421. $.ajax({
  422. url: huayi.config.callcenter_url + "Index/UploadTX",
  423. type: "POST",
  424. data: formData,
  425. /**
  426. *必须false才会自动加上正确的Content-Type
  427. */
  428. contentType: false,
  429. /**
  430. * 必须false才会避开jQuery对 formdata 的默认处理
  431. * XMLHttpRequest会对 formdata 进行正确的处理
  432. */
  433. processData: false,
  434. success: function(result) {
  435. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  436. $("#upFile").change(function() {
  437. uploadtx();
  438. });
  439. var r = $.parseJSON(result);
  440. if (r.state.toLowerCase() == "success") {
  441. $(".yhtx").attr("src", huayi.config.callcenter_url.substr(0, huayi.config.callcenter_url.length - 1) + r.data);
  442. layer.msg("上传成功");
  443. }
  444. }
  445. });
  446. } else {
  447. layer.confirm('请上传文件!', {
  448. btn: ['确定']
  449. });
  450. }
  451. }
  452. //格式化呼叫状态
  453. function GetCallState(val) {
  454. if (val == '1') {
  455. return '已接通';
  456. } else {
  457. return '未接通';
  458. }
  459. }
  460. //外呼弹屏
  461. function whtp() {
  462. $("#Result").val("");
  463. if ($(".WH").hasClass("fadeOutUp")) {
  464. $(".WH").removeClass("fadeOutUp").addClass("fadeInDown");
  465. }
  466. $(".WH").removeClass("hidens");
  467. $('.first').removeClass('first');
  468. $('.WH').addClass('first');
  469. loadWH();
  470. }
  471. //加载外呼电话列表
  472. function loadWH() {
  473. $(".phonediv").hide();
  474. var n = $(".bg_title .lactive").attr("itemid");
  475. switch (n) {
  476. case '0':
  477. var obj = $(".phonediv").eq(0);
  478. obj.show();
  479. //先销毁表格
  480. var table = obj.find(".phonelist");
  481. table.bootstrapTable('destroy');
  482. //初始化表格,动态从服务器加载数据
  483. table.bootstrapTable({
  484. method: "get", //使用get请求到服务器获取数据
  485. url: huayi.config.callcenter_url + "CallOutScreen/GetPhoneList", //获取数据的Servlet地址
  486. contentType: 'application/x-www-form-urlencoded',
  487. striped: true, //表格显示条纹
  488. pagination: true, //启动分页
  489. pageSize: 10, //每页显示的记录数
  490. pageNumber: 1, //当前第几页
  491. pageList: [10, 20, 50, 100], //记录数可选列表
  492. search: false, //是否启用查询
  493. showColumns: false, //显示下拉框勾选要显示的列
  494. showRefresh: false, //显示刷新按钮
  495. sidePagination: "server", //表示服务端请求
  496. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  497. //设置为limit可以获取limit, offset, search, sort, order
  498. queryParamsType: "undefined",
  499. queryParams: function queryParams(params) { //设置查询参数
  500. var param = {
  501. page: params.pageNumber,
  502. pagesize: params.pageSize,
  503. tel: $("#lastphone").val(),
  504. token: $.cookie("token")
  505. };
  506. return param;
  507. },
  508. onLoadSuccess: function() { //加载成功时执行
  509. //layer.msg("加载成功");
  510. },
  511. onLoadError: function() { //加载失败时执行
  512. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  513. }
  514. });
  515. break;
  516. case '1':
  517. var obj = $(".phonediv").eq(1);
  518. obj.show();
  519. getDepts(); //获取部门下拉
  520. var table = obj.find(".phonelist");
  521. table.bootstrapTable('destroy');
  522. //初始化表格,动态从服务器加载数据
  523. table.bootstrapTable({
  524. method: "get", //使用get请求到服务器获取数据
  525. url: huayi.config.callcenter_url + "CallOutScreen/GetUserList", //获取数据的Servlet地址
  526. contentType: 'application/x-www-form-urlencoded',
  527. striped: true, //表格显示条纹
  528. pagination: true, //启动分页
  529. pageSize: 10, //每页显示的记录数
  530. pageNumber: 1, //当前第几页
  531. pageList: [10, 20, 50, 100], //记录数可选列表
  532. search: false, //是否启用查询
  533. showColumns: false, //显示下拉框勾选要显示的列
  534. showRefresh: false, //显示刷新按钮
  535. sidePagination: "server", //表示服务端请求
  536. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  537. //设置为limit可以获取limit, offset, search, sort, order
  538. queryParamsType: "undefined",
  539. queryParams: function queryParams(params) { //设置查询参数
  540. var param = {
  541. page: params.pageNumber,
  542. pagesize: params.pageSize,
  543. zxzid: $('#s_department').val(),
  544. tel: $("#gsphone").val(),
  545. name: $("#gsname").val(),
  546. token: $.cookie("token")
  547. };
  548. return param;
  549. },
  550. onLoadSuccess: function() { //加载成功时执行
  551. //layer.msg("加载成功");
  552. },
  553. onLoadError: function() { //加载失败时执行
  554. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  555. }
  556. });
  557. break;
  558. case '2':
  559. var obj = $(".phonediv").eq(2);
  560. obj.show();
  561. var table = obj.find(".phonelist");
  562. table.bootstrapTable('destroy');
  563. //初始化表格,动态从服务器加载数据
  564. table.bootstrapTable({
  565. method: "get", //使用get请求到服务器获取数据
  566. url: huayi.config.callcenter_url + "CallOutScreen/GetCustomerList", //获取数据的Servlet地址
  567. contentType: 'application/x-www-form-urlencoded',
  568. striped: true, //表格显示条纹
  569. pagination: true, //启动分页
  570. pageSize: 10, //每页显示的记录数
  571. pageNumber: 1, //当前第几页
  572. pageList: [10, 20, 50, 100], //记录数可选列表
  573. search: false, //是否启用查询
  574. showColumns: false, //显示下拉框勾选要显示的列
  575. showRefresh: false, //显示刷新按钮
  576. sidePagination: "server", //表示服务端请求
  577. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  578. //设置为limit可以获取limit, offset, search, sort, order
  579. queryParamsType: "undefined",
  580. queryParams: function queryParams(params) { //设置查询参数
  581. var param = {
  582. page: params.pageNumber,
  583. pagesize: params.pageSize,
  584. tel: $("#khphone").val(),
  585. name: $("#khname").val(),
  586. token: $.cookie("token")
  587. };
  588. return param;
  589. },
  590. onLoadSuccess: function() { //加载成功时执行
  591. //layer.msg("加载成功");
  592. },
  593. onLoadError: function() { //加载失败时执行
  594. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  595. }
  596. });
  597. break;
  598. }
  599. }
  600. //格式化最近电话处理方式
  601. function formatterDealType(val, row) {
  602. //处理方式0:IVR处理1骚扰电话2自助服务3转值班电话4留言5呼损6人工处理
  603. var str = '-';
  604. switch (val) {
  605. case 0:
  606. str = 'IVR处理';
  607. break;
  608. case 1:
  609. str = '骚扰电话';
  610. break;
  611. case 2:
  612. str = '自助服务';
  613. break;
  614. case 3:
  615. str = '转值班电话';
  616. break;
  617. case 4:
  618. str = '留言';
  619. break;
  620. case 5:
  621. str = '呼损';
  622. break;
  623. case 6:
  624. str = '人工处理';
  625. break;
  626. }
  627. return str;
  628. }
  629. //获取外呼公司电话下 部门下拉
  630. function getDepts() {
  631. $.getJSON(huayi.config.callcenter_url + "SeatGroup/GetList", {
  632. token: $.cookie("token"),
  633. }, function(data) {
  634. if (data.rows && data.rows.length > 0) {
  635. $('#s_department').html('');
  636. $('#s_department').append('<option value="">请选择</option>');
  637. $.each(data.rows, function(i, v) {
  638. $('<option value="' + v.F_ZXZID + '">' + v.F_ZXZName + '</option>').appendTo($('#s_department'));
  639. });
  640. }
  641. });
  642. }
  643. //格式化 电话号码 分机号
  644. function view(val) {
  645. var str = '';
  646. if (val) {
  647. str = '<a onclick="call(\'' + val + '\')">' + val + '</a>';
  648. }
  649. return str;
  650. }
  651. function call(val) {
  652. $("#Result").val(val);
  653. $(".img").removeClass("hidens");
  654. }
  655. function logout() {
  656. if (!$('.Logout').hasClass('active')) {
  657. $.ajax({
  658. url: huayi.config.callcenter_url + "Login/Logout",
  659. data: {
  660. token: $.cookie("token")
  661. },
  662. dataType: "json",
  663. success: function(res) {
  664. if (res.state) {
  665. location.href = "./login.html";
  666. }
  667. }
  668. });
  669. } else {
  670. layer.msg("退出失败!");
  671. }
  672. }
  673. //加载左侧导航菜单
  674. function loadMenu() {
  675. $.ajaxSettings.async = false;
  676. $.getJSON(huayi.config.callcenter_url + 'Index/GetMenu', {
  677. "token": $.cookie("token")
  678. }, function(result) {
  679. $.ajaxSettings.async = true;
  680. if (result.state.toLowerCase() == "success") {
  681. var data = result.data;
  682. var _html = "";
  683. $.each(data, function(i) {
  684. var row = data[i];
  685. if (row.F_ParentID == "0") {
  686. _html += '<li>';
  687. _html += '<a class="Click"data-id="Menu_' + row.F_ModuleId + '" href="' + row.F_OptUrl +
  688. '"><i class="fa iconfont">' + row.F_ImgUrl + '</i><span class="nav-label">' + row.F_ModuleName +
  689. '</span><span class="fa arrow"></span></a>';
  690. var childNodes = row.ChildNodes; //二级
  691. if (childNodes.length > 0) {
  692. _html += '<ul class="nav nav-second-level">';
  693. $.each(childNodes, function(i) {
  694. var subrow = childNodes[i];
  695. var childNodsThird = subrow.ChildNodes; //三级
  696. if (childNodsThird.length > 0) {
  697. _html += '<li>';
  698. _html += '<a href="' + subrow.F_OptUrl + '">';
  699. _html += '<span class="nav-label">' + subrow.F_ModuleName + '</span>';
  700. _html += '<span class="fa arrow"></span>';
  701. _html += '</a>';
  702. _html += '<ul class="nav nav-third-level">';
  703. $.each(childNodsThird, function(i) {
  704. var subrowThird = childNodsThird[i];
  705. _html += '<li>';
  706. _html += '<a class="J_menuItem" data-id="Menu_' + subrowThird.F_ModuleId + '" href="' + subrowThird.F_OptUrl +
  707. '" >' + subrowThird.F_ModuleName + '</a>';
  708. _html += '</li>';
  709. });
  710. _html += '</ul>';
  711. } else {
  712. _html += '<li>';
  713. _html += '<a class="J_menuItem" data-id="Menu_' + subrow.F_ModuleId + '" href="' + subrow.F_OptUrl +
  714. '" >' + subrow.F_ModuleName + '</a>';
  715. if (subrow.F_Button != '') {
  716. _html += '<span class="' + subrow.F_Button + '"></span>';
  717. }
  718. _html += '</li>';
  719. }
  720. });
  721. _html += '</ul>';
  722. }
  723. _html += '</li>';
  724. }
  725. });
  726. // $("#sidebar-nav ul").prepend(_html);
  727. $(_html).appendTo("#side-menu");
  728. //绑定点击事件 添加点击的样式
  729. $('#side-menu').find('.J_menuItem').on('click', function() {
  730. $(this).parent().addClass('sub_active').siblings().removeClass('sub_active');
  731. });
  732. } else {
  733. window.location.href = "/login.html";
  734. }
  735. })
  736. }
  737. //跳转
  738. function Jumps() {
  739. //window.parent.frames[ "iframe0"].location.reload();
  740. $("iframe:visible")[0].src = "widgets.html"
  741. $(".J_menuTab").eq(0).addClass("active").text('首页');
  742. $(".J_menuTab").eq(0).attr("data-id", 'widgets.html');
  743. $(".J_mainContent .J_iframe0").attr("data-id", "widgets.html");
  744. }
  745. // 顶部消息
  746. function showTopMsgs() {
  747. $('#top_notices_lists').toggle();
  748. // if ($('#top_notices_lists').is(':visible')) {
  749. // $('#top_notices_lists').hide();
  750. // } else {
  751. // $('#top_notices_lists').show();
  752. // }
  753. }
  754. // 获取顶部消息(只展示未读消息 0未读 1已读)
  755. function getTopMsgs() {
  756. $.getJSON(huayi.config.callcenter_url + 'Msg/GetServerMsg', {
  757. token: $.cookie("token")
  758. }, function(result) {
  759. if(result.state.toLowerCase() === 'success'){
  760. $('#top_notices_lists').empty();
  761. result = result.data;
  762. var str = '';
  763. if (result && result.length) {
  764. if(isFirstShowTopMsg){
  765. $('#top_notices_lists').show();
  766. isFirstShowTopMsg = false;
  767. }
  768. $('#top_notices_num').text(result.length);
  769. for (var i = 0; i < result.length; i++) {
  770. str += '<li class="top_notices_item">' +
  771. '<span class="top_notices_con">'+ result[i].Detail +'</span>' +
  772. '<button type="button" class="btn btn-primary btn-sm" onclick="signRead('+ result[i].ID +', event)">未读</button>' +
  773. '</li>' +
  774. '<li class="divider"></li>';
  775. }
  776. } else {
  777. str = '<li class="top_notices_item">' +
  778. '<span class="top_notices_con">暂无消息!</span>' +
  779. '</li>';
  780. $('#top_notices_num').text(0);
  781. }
  782. $('#top_notices_lists').append(str);
  783. $('#top_notices_lists').find('.divider:last').remove();
  784. }
  785. });
  786. }
  787. // 标记消息状态
  788. function signRead(signid, e) {
  789. e.stopPropagation();
  790. layer.confirm('确认已读后该条消息将不再提示,请慎重', {
  791. icon: 7,
  792. btn: ['确认', '取消'] //按钮
  793. }, function(index) {
  794. $.ajax({
  795. type: "get",
  796. url: huayi.config.callcenter_url + "Msg/UpdateState",
  797. dataType: 'json',
  798. async: true,
  799. data: {
  800. ids: signid,
  801. state: 1, //状态,0未读 1已读
  802. token: $.cookie("token")
  803. },
  804. success: function(data) {
  805. if (data.state.toLowerCase() === "success") {
  806. // 更新顶部消息内容和数量
  807. getTopMsgs();
  808. $('#top_notices_lists').hide();
  809. layer.close(index);
  810. }
  811. }
  812. });
  813. });
  814. }
  815. $(document).click(function(e) {
  816. if($(e.target).is($('.top_notices_lists')) || $(e.target).is($('.top_notices_item')) || $(e.target).is($('.top_notices_con')) || $(e.target).is($('.divider'))) {
  817. $('#top_notices_lists').show();
  818. }
  819. })