Açıklama Yok

index.js 22KB

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