You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1057 lines
54 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 北京泉江科技有限公司
  4. * 创建人:陈彬彬
  5. * 日 期:2017.03.16
  6. * 描 述:经典风格皮肤
  7. */
  8. var autoopenid = request('autoopen');
  9. var pwd = request("pwd");
  10. var pwdtip = request("pwdtip");
  11. var bootstrap = function ($, learun) {
  12. "use strict";
  13. // 菜单操作
  14. var meuns = {
  15. init: function () {
  16. this.load();
  17. this.bind();
  18. },
  19. load: function () {
  20. var modulesTree = learun.clientdata.get(['modulesTree']);
  21. // 第一级菜单
  22. var parentId = '0';
  23. var modules = modulesTree[parentId] || [];
  24. var $firstmenus = $('<ul class="lr-first-menu-list"></ul>');
  25. for (var i = 0, l = modules.length; i < l; i++) {
  26. var item = modules[i];
  27. if (item.F_IsMenu == 1) {
  28. var $firstMenuItem = $('<li></li>');
  29. if (!!item.F_Description) {
  30. $firstMenuItem.attr('title', item.F_Description);
  31. }
  32. var menuItemHtml = '<a id="' + item.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item">';
  33. menuItemHtml += '<i class="' + item.F_Icon + ' lr-menu-item-icon"></i>';
  34. menuItemHtml += '<span class="lr-menu-item-text">' + item.F_FullName + '</span>';
  35. menuItemHtml += '<span class="lr-menu-item-arrow"></span></a>';
  36. $firstMenuItem.append(menuItemHtml);
  37. // 第二级菜单
  38. var secondModules = modulesTree[item.F_ModuleId] || [];
  39. var $secondMenus = $('<ul class="lr-second-menu-list"></ul>');
  40. var secondMenuHad = false;
  41. for (var j = 0, sl = secondModules.length; j < sl; j++) {
  42. var secondItem = secondModules[j];
  43. if (secondItem.F_IsMenu == 1) {
  44. secondMenuHad = true;
  45. var $secondMenuItem = $('<li></li>');
  46. if (!!secondItem.F_Description) {
  47. $secondMenuItem.attr('title', secondItem.F_Description);
  48. }
  49. var secondItemHtml = '<a id="' + secondItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
  50. secondItemHtml += '<i class="' + secondItem.F_Icon + ' lr-menu-item-icon"></i>';
  51. secondItemHtml += '<span class="lr-menu-item-text">' + secondItem.F_FullName + '</span>';
  52. secondItemHtml += '</a>';
  53. $secondMenuItem.append(secondItemHtml);
  54. // 第三级菜单
  55. var threeModules = modulesTree[secondItem.F_ModuleId] || [];
  56. var $threeMenus = $('<ul class="lr-three-menu-list"></ul>');
  57. var threeMenuHad = false;
  58. for (var m = 0, tl = threeModules.length; m < tl; m++) {
  59. var threeItem = threeModules[m];
  60. if (threeItem.F_IsMenu == 1) {
  61. threeMenuHad = true;
  62. var $threeMenuItem = $('<li></li>');
  63. $threeMenuItem.attr('title', threeItem.F_FullName);
  64. var threeItemHtml = '<a id="' + threeItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
  65. threeItemHtml += '<i class="' + threeItem.F_Icon + ' lr-menu-item-icon"></i>';
  66. threeItemHtml += '<span class="lr-menu-item-text">' + threeItem.F_FullName + '</span>';
  67. threeItemHtml += '</a>';
  68. $threeMenuItem.append(threeItemHtml);
  69. //第四级菜单
  70. var fourModules = modulesTree[threeItem.F_ModuleId] || [];
  71. var $fourMenus = $('<ul class="lr-four-menu-list"></ul>');
  72. var fourMenuHad = false;
  73. for (var n = 0, fl = fourModules.length; n < fl; n++) {
  74. var fourItem = fourModules[n];
  75. if (fourItem.F_IsMenu == 1) {
  76. fourMenuHad = true;
  77. var $fourMenuItem = $('<li></li>');
  78. $fourMenuItem.attr('title', fourItem.F_FullName);
  79. var fourItemHtml = '<a id="' + fourItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
  80. fourItemHtml += '<i class="' + fourItem.F_Icon + ' lr-menu-item-icon"></i>';
  81. fourItemHtml += '<span class="lr-menu-item-text">' + fourItem.F_FullName + '</span>';
  82. fourItemHtml += '</a>';
  83. $fourMenuItem.append(fourItemHtml);
  84. $fourMenus.append($fourMenuItem);
  85. }
  86. }
  87. if (fourMenuHad) {
  88. $threeMenuItem.addClass('lr-meun-had');
  89. $threeMenuItem.append($fourMenus);
  90. }
  91. $threeMenus.append($threeMenuItem);
  92. }
  93. }
  94. if (threeMenuHad) {
  95. $secondMenuItem.addClass('lr-meun-had');
  96. $secondMenuItem.append($threeMenus);
  97. }
  98. $secondMenus.append($secondMenuItem);
  99. }
  100. }
  101. if (secondMenuHad) {
  102. $firstMenuItem.append($secondMenus);
  103. }
  104. $firstmenus.append($firstMenuItem);
  105. }
  106. }
  107. $('#lr_frame_menu').html($firstmenus);
  108. // 语言包翻译
  109. $('.lr-menu-item-text').each(function () {
  110. var $this = $(this);
  111. var text = $this.text();
  112. learun.language.get(text, function (text) {
  113. $this.text(text);
  114. $this.parent().parent().attr('title', text);
  115. });
  116. });
  117. },
  118. bind: function () {
  119. $("#lr_frame_menu").lrscroll();
  120. $("#lr_frame_menu .lr-first-menu-list > li").hover(function (e) {// 一级菜单选中的时候判断二级菜单的位置
  121. //$('#lr_frame_menu').width(4000);
  122. var $secondMenu = $(this).find('.lr-second-menu-list');
  123. var length = $secondMenu.find('li').length;
  124. if (length > 0) {
  125. $secondMenu.css('top', '0px');
  126. var secondMenuTop = $(this).offset().top + $secondMenu.height() + 23;
  127. var bodyHeight = $(window).height();
  128. if (secondMenuTop > bodyHeight) {
  129. $secondMenu.css('top', '-' + (secondMenuTop - bodyHeight) + 'px');
  130. }
  131. }
  132. }, function (e) {
  133. $('#lr_frame_menu').width(80);
  134. });
  135. $("#lr_frame_menu .lr-second-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置
  136. var $ul = $(this).find('.lr-three-menu-list');
  137. $ul.css('top', '-9px');
  138. var ulTop = $(this).offset().top + $ul.height() + 23;
  139. var bodyHeight = $(window).height();
  140. if (ulTop > bodyHeight) {
  141. $ul.css('top', '-' + (ulTop - bodyHeight) + 'px');
  142. }
  143. });
  144. $("#lr_frame_menu .lr-three-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置
  145. var $ul = $(this).find('.lr-four-menu-list');
  146. $ul.css('top', '-9px');
  147. var ulTop = $(this).offset().top + $ul.height() + 23;
  148. var bodyHeight = $(window).height();
  149. if (ulTop > bodyHeight) {
  150. $ul.css('top', '-' + (ulTop - bodyHeight) + 'px');
  151. }
  152. });
  153. // 添加点击事件
  154. $('#lr_frame_menu .lr-menu-item').on('click', function () {
  155. var $obj = $(this);
  156. var id = $obj.attr('id');
  157. var _module = learun.clientdata.get(['modulesMap', id]);
  158. switch (_module.F_Target) {
  159. case 'iframe':// 窗口
  160. if (learun.validator.isNotNull(_module.F_UrlAddress).code) {
  161. learun.frameTab.open(_module);
  162. }
  163. break;
  164. case 'open':// 窗口
  165. var newWin = window.open(_module.F_UrlAddress);
  166. newWin.location.replace(_module.F_UrlAddress);
  167. break;
  168. }
  169. });
  170. //使用引导页
  171. var guide = learun.clientdata.get(['modulesMap', "44e91494-942d-482d-949e-ae8af5333956"]);
  172. if (guide) {
  173. //learun.frameTab.open(guide);
  174. learun.frameTab.open({ F_ModuleId: guide.F_ModuleId, F_Icon: guide.F_Icon, F_FullName: guide.F_FullName, F_UrlAddress: guide.F_UrlAddress }, true);
  175. }
  176. //桌面导航
  177. //var desktopnavigation = learun.clientdata.get(['modulesMap', "be81bdde-8bbc-4080-b976-84faefc414d2"]);
  178. //if (desktopnavigation) {
  179. // learun.frameTab.open({ F_ModuleId: desktopnavigation.F_ModuleId, F_Icon: desktopnavigation.F_Icon, F_FullName: desktopnavigation.F_FullName, F_UrlAddress: desktopnavigation.F_UrlAddress }, true);
  180. //}
  181. //var needtodo = learun.clientdata.get(['modulesMap', "021a59b0-2589-4f9e-8140-6052177a967c"]);
  182. //if (needtodo) {
  183. // //自动弹出待办事项
  184. // top.layer.open({
  185. // id: 'ntdform',
  186. // title: '我的待办事项',
  187. // type: 2,
  188. // skin: 'lr-layer',
  189. // btn: ['关闭'],
  190. // content: top.$.rootUrl + '/Home/NeedToDoForm',
  191. // area: ['500px', '300px']
  192. // });
  193. //}
  194. if (pwd == "true") {
  195. top.layer.open({
  196. id: 'pwdform',
  197. title: '密码修改',
  198. closeBtn: 0,
  199. resize: false,
  200. type: 2,
  201. skin: 'lr-layer',
  202. btn: ['确定'],
  203. content: top.$.rootUrl + '/Home/ChangePwd',
  204. area: ['500px', '300px'],
  205. success: function (layero, index) {
  206. top['layer_pwdform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  207. layero[0].learun_layerid = 'layer_pwdform';
  208. },
  209. yes: function (index, layero) {
  210. var flag = top['layer_pwdform'].acceptClick(function () {
  211. top.location.href = "/Login/Index";
  212. });
  213. if (!!flag) {
  214. learun.layerClose('', index);
  215. }
  216. },
  217. end: function () {
  218. top['layer_pwdform'] = null;
  219. }
  220. });
  221. }
  222. if (pwd == "first") {
  223. top.layer.open({
  224. id: 'pwdform',
  225. title: '密码修改',
  226. closeBtn: 0,
  227. resize: false,
  228. type: 2,
  229. skin: 'lr-layer',
  230. btn: ['确定'],
  231. content: top.$.rootUrl + '/Home/FirstChangePwd',
  232. area: ['500px', '300px'],
  233. success: function (layero, index) {
  234. top['layer_pwdform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  235. layero[0].learun_layerid = 'layer_pwdform';
  236. },
  237. yes: function (index, layero) {
  238. var flag = top['layer_pwdform'].acceptClick(function () {
  239. top.location.href = "/Login/Index";
  240. });
  241. if (!!flag) {
  242. learun.layerClose('', index);
  243. }
  244. },
  245. end: function () {
  246. top['layer_pwdform'] = null;
  247. }
  248. });
  249. }
  250. //30天未修改密码进行提示
  251. if (pwdtip == "true") {
  252. layer.alert("您已30天未修改密码,请先修改!", {icon:7, title: "提示", yes: function (index) { layer.close(index) } });
  253. }
  254. //上网认证
  255. if (ACIp != null && ACIp != "") {
  256. //Ip上网
  257. sendToAc(ACIp, 'logon', Ip, learun.clientdata.get(['userinfo']).account, '');
  258. }
  259. if (ACIp2 != null && ACIp2 != "") {
  260. //Ip上网
  261. sendToAc(ACIp2, 'logon', Ip, learun.clientdata.get(['userinfo']).account, '');
  262. }
  263. if (!!autoopenid) {
  264. var _module = learun.clientdata.get(['modulesMap', autoopenid]);
  265. switch (_module.F_Target) {
  266. case 'iframe':// 窗口
  267. if (learun.validator.isNotNull(_module.F_UrlAddress).code) {
  268. learun.frameTab.open(_module);
  269. var keyValue = request('keyValue');
  270. //内部邮件
  271. if (autoopenid == '252878d7-d807-497f-b01e-839bb1b869c6' && !!keyValue) {
  272. var iframe = document.getElementById('lr_iframe_' + autoopenid);
  273. top.layer.open({
  274. id: 'viewform',
  275. title: '查看',
  276. type: 2,
  277. skin: 'lr-layer',
  278. btn: ['回复', '转发', '关闭'],
  279. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue,
  280. area: ['800px', '700px'],
  281. success: function (layero, index) {
  282. top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  283. //自动已读
  284. learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () {
  285. iframe.contentWindow.refreshreceivetableGirdData();
  286. });
  287. },
  288. yes: function (index, layero) {
  289. top.layer.open({
  290. id: 'resendform',
  291. title: '回复邮件',
  292. type: 2,
  293. skin: 'lr-layer',
  294. btn: ['发送', '保存草稿', '关闭'],
  295. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Form?keyValue=' + keyValue,
  296. area: ['800px', '700px'],
  297. success: function (layero, index) {
  298. top['resendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  299. },
  300. yes: function (index, layero) {
  301. top['resendform'].acceptClick(iframe.contentWindow.sendthismessage);
  302. top['resendform'] = null;
  303. top.layer.close(index);
  304. }
  305. , btn2: function (index, layero) {
  306. top['resendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData);
  307. top['resendform'] = null;
  308. top.layer.close(index);
  309. }
  310. , btn3: function (index, layero) {
  311. top['resendform'] = null;
  312. top.layer.close(index);
  313. }
  314. });
  315. top['viewform'] = null;
  316. top.layer.close(index);
  317. },
  318. btn2: function (index, layero) {
  319. top.layer.open({
  320. id: 'chsendform',
  321. title: '转发邮件',
  322. type: 2,
  323. skin: 'lr-layer',
  324. btn: ['发送', '保存草稿', '关闭'],
  325. content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormCh?keyValue=' + keyValue,
  326. area: ['800px', '700px'],
  327. success: function (layero, index) {
  328. top['chsendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
  329. },
  330. yes: function (index, layero) {
  331. top['chsendform'].acceptClick(iframe.contentWindow.sendthismessage);
  332. top['chsendform'] = null;
  333. top.layer.close(index);
  334. }
  335. , btn2: function (index, layero) {
  336. top['chsendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData);
  337. top['chsendform'] = null;
  338. top.layer.close(index);
  339. }
  340. , btn3: function (index, layero) {
  341. top['chsendform'] = null;
  342. top.layer.close(index);
  343. }
  344. });
  345. top['viewform'] = null;
  346. top.layer.close(index);
  347. },
  348. btn3: function (index, layero) {
  349. top['viewform'] = null;
  350. top.layer.close(index);
  351. }
  352. });
  353. }
  354. //我的任务
  355. if (autoopenid == '021a59b0-2589-4f9e-8140-6052177a967c' && !!request('F_Id')) {
  356. var processId = request('F_Id');
  357. var taskId = request('F_TaskId');
  358. var taskType = request('F_TaskType');
  359. if (taskType == 4) {
  360. if (learun.checkrow(taskId)) {
  361. learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=4' + "&processId=" + processId + "&taskId=" + taskId });
  362. }
  363. }
  364. else if (taskType == 1) {
  365. if (learun.checkrow(taskId)) {
  366. learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=1' + "&processId=" + processId + "&taskId=" + taskId });
  367. }
  368. }
  369. else if (taskType == 2) {
  370. learun.alert.warning('请点击重新发起');
  371. }
  372. else {
  373. if (learun.checkrow(taskId)) {
  374. learun.frameTab.open({ F_ModuleId: taskId, F_Icon: 'fa magic', F_FullName: '审核流程', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?tabIframeId=' + taskId + '&type=3' + "&processId=" + processId + "&taskId=" + taskId });
  375. }
  376. }
  377. }
  378. //办事大厅
  379. if (autoopenid == '56ce34c2-882e-47d1-b12d-5036e3b79fcf' && !!request('shcemeCode')) {
  380. var id = request('id');
  381. var shcemeCode = request('shcemeCode');
  382. //learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=0' });
  383. learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/NWFContainerForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=create' });
  384. }
  385. //公告
  386. if (autoopenid == '6252983c-52f5-402c-991b-ad19a9cb1f94' && !!keyValue) {
  387. learun.frameTab.open({
  388. F_ModuleId: "dtlist" + keyValue,
  389. F_FullName: '通知公告',
  390. F_UrlAddress: "/Utility/ListContentIndex?id=" + keyValue
  391. });
  392. }
  393. }
  394. break;
  395. case 'open':// 窗口
  396. var newWin = window.open(_module.F_UrlAddress);
  397. newWin.location.replace(_module.F_UrlAddress);
  398. break;
  399. }
  400. }
  401. }
  402. };
  403. meuns.init();
  404. var companyMap = {};
  405. var departmentMap = {};
  406. var userMap = {};
  407. var sysUserMap = {};
  408. var imUserId = '';
  409. //获取头像
  410. var getHeadImg = function (user) {
  411. var url = top.$.rootUrl;
  412. switch (user.img) {
  413. case '0':
  414. url += '/Content/images/head/on-girl.jpg';
  415. break;
  416. case '1':
  417. url += '/Content/images/head/on-boy.jpg';
  418. break;
  419. default:
  420. url += '/LR_OrganizationModule/User/GetImg?userId=' + user.id;
  421. break;
  422. }
  423. return url;
  424. };
  425. // 发送聊天信息
  426. var sendMsg = function (msg, time) {
  427. var loginInfo = learun.clientdata.get(['userinfo']);
  428. learun.clientdata.getAsync('user', {
  429. key: loginInfo.userId,
  430. callback: function (data, op) {
  431. data.id = op.key;
  432. var _html = '\
  433. <div class="im-me">\
  434. <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
  435. <div class="arrow"></div>\
  436. <span class="content">'+ msg + '</span>\
  437. </div>';
  438. if (time && time != '') {
  439. $('.lr-im-msgcontent .lr-scroll-box').append('<div class="im-time">' + time + '</div>');
  440. }
  441. $('.lr-im-msgcontent .lr-scroll-box').append(_html);
  442. $('.lr-im-msgcontent').lrscrollSet('moveBottom');
  443. }
  444. });
  445. };
  446. // 接收聊天消息
  447. var revMsg = function (userId, msg, time) {
  448. learun.clientdata.getAsync('user', {
  449. key: userId,
  450. callback: function (data, op) {
  451. data.id = op.key;
  452. var _html = '\
  453. <div class="im-other">\
  454. <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
  455. <div class="arrow"></div>\
  456. <span class="content">'+ msg + '</span>\
  457. </div>';
  458. if (time && time != '') {
  459. $('.lr-im-msgcontent .lr-scroll-box').append('<div class="im-time">' + time + '</div>');
  460. }
  461. $('.lr-im-msgcontent .lr-scroll-box').append(_html);
  462. $('.lr-im-msgcontent').lrscrollSet('moveBottom');
  463. }
  464. });
  465. };
  466. // 即时通讯
  467. var im = {
  468. init: function () {
  469. this.bind();
  470. this.load();
  471. },
  472. load: function () {
  473. // 获取下公司列表
  474. learun.clientdata.getAllAsync('company', {
  475. callback: function (data) {
  476. $.each(data, function (_id, _item) {
  477. companyMap[_item.parentId] = companyMap[_item.parentId] || [];
  478. _item.id = _id;
  479. companyMap[_item.parentId].push(_item);
  480. });
  481. var $list = $('#lr_im_content_userlist .lr-scroll-box');
  482. $list.html("");
  483. $.each(companyMap["0"], function (_index, _item) {
  484. var _html = '\
  485. <div class="lr-im-company-item">\
  486. <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="0" >\
  487. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  488. </div>\
  489. </div>';
  490. $list.append(_html);
  491. });
  492. // 获取部门列表
  493. learun.clientdata.getAllAsync('department', {
  494. callback: function (data) {
  495. $.each(data, function (_id, _item) {
  496. _item.id = _id;
  497. if (_item.parentId == "0") {
  498. departmentMap[_item.companyId] = departmentMap[_item.companyId] || [];
  499. departmentMap[_item.companyId].push(_item);
  500. }
  501. else {
  502. departmentMap[_item.parentId] = departmentMap[_item.parentId] || [];
  503. departmentMap[_item.parentId].push(_item);
  504. }
  505. });
  506. // 获取人员数据
  507. learun.clientdata.getAllAsync('user', {
  508. callback: function (data) {
  509. $.each(data, function (_id, _item) {
  510. _item.id = _id;
  511. if (_item.departmentId) {
  512. userMap[_item.departmentId] = userMap[_item.departmentId] || [];
  513. userMap[_item.departmentId].push(_item);
  514. }
  515. else if (_item.companyId) {
  516. userMap[_item.companyId] = userMap[_item.companyId] || [];
  517. userMap[_item.companyId].push(_item);
  518. }
  519. });
  520. // 获取最近联系人列表
  521. learun.im.getContacts(function (data, sysUserList) {
  522. $.each(sysUserList, function (_index, _item) {
  523. sysUserMap[_item.F_Code] = _item;
  524. });
  525. var $userList = $('#lr_immsg_userlist .lr-scroll-box');
  526. $userList.html("");
  527. $.each(data, function (_index, _item) {
  528. var html = ' <div class="userlist-item ' + (_item.F_IsRead == '1' ? 'imHasMsg' : '') + '" data-value="' + _item.F_OtherUserId + '" >';
  529. if (sysUserMap[_item.F_OtherUserId]) {
  530. html += '<div class="photo"><i class="' + sysUserMap[_item.F_OtherUserId].F_Icon + '" ></i>';
  531. }
  532. else {
  533. html += '<div class="photo"><img src="' + top.$.rootUrl + '/Content/images/head/on-boy.jpg" >';
  534. }
  535. html += '<div class="point"></div></div>';
  536. html += '</div>';
  537. $userList.append(html);
  538. if (sysUserMap[_item.F_OtherUserId]) {
  539. var _$item = $userList.find('[data-value="' + _item.F_OtherUserId + '"]');
  540. _$item.attr('title', sysUserMap[_item.F_OtherUserId].F_Name);
  541. if (_index == 0) {
  542. _$item.trigger('click');
  543. }
  544. _$item = null;
  545. }
  546. else {
  547. learun.clientdata.getAsync('user', {
  548. key: _item.F_OtherUserId,
  549. index: _index,
  550. callback: function (data, op) {
  551. var $item = $userList.find('[data-value="' + op.key + '"]');
  552. $item.attr('title', data.name);
  553. data.id = op.key;
  554. $item.find('img').attr('src', getHeadImg(data));
  555. if (op.index == 0) {
  556. $item.trigger('click');
  557. }
  558. $item = null;
  559. }
  560. });
  561. }
  562. });
  563. });
  564. }
  565. });
  566. }
  567. });
  568. }
  569. });
  570. },
  571. bind: function () {
  572. // 最近消息 与 联系人之间的切换
  573. $('.lr-im-title .title-item').on('click', function () {
  574. var $this = $(this);
  575. if (!$this.hasClass('active')) {
  576. $('.lr-im-body>.active').removeClass('active');
  577. $('.lr-im-title>.active').removeClass('active');
  578. $this.addClass('active');
  579. var v = $this.attr('data-value');
  580. $('#' + v).addClass('active');
  581. }
  582. });
  583. $(".lr-lzca-user").on('click',
  584. function () {
  585. learun.httpPost(top.$.rootUrl + '/Home/GetOnlineUserInfo',
  586. {},
  587. function (op) {
  588. if (op.data) {
  589. var content = '';
  590. $.each(op.data, function (i, item) {
  591. content += '<li>' + item.F_RealName + '(' + item.Source + ')' + '</li>';
  592. console.log(item.F_RealName + "(" + item.Source + ")")
  593. })
  594. $(".lr-lzca-user-ul").html(content);
  595. }
  596. });
  597. });
  598. $("#btn_daiban").on('click',
  599. function () {
  600. learun.frameTab.open({
  601. F_ModuleId: '101',
  602. F_Icon: 'fa fa-user',
  603. F_FullName: '流程任务',
  604. F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/Index'
  605. });
  606. });
  607. $("#btn_youjian").on('click',
  608. function () {
  609. learun.frameTab.open({
  610. F_ModuleId: '102',
  611. F_Icon: 'fa fa-user',
  612. F_FullName: '内部邮件',
  613. F_UrlAddress: '/EducationalAdministration/LanMail/Index'
  614. });
  615. });
  616. $("#btn_tonggao").on('click',
  617. function () {
  618. learun.frameTab.open({
  619. F_ModuleId: '103',
  620. F_Icon: 'fa fa-user',
  621. F_FullName: '下发通知公告',
  622. F_UrlAddress: '/LR_OAModule/Notice/Index'
  623. });
  624. });
  625. $("#btn_gongwen").on('click',
  626. function () {
  627. learun.frameTab.open({
  628. F_ModuleId: '104',
  629. F_Icon: 'fa fa-user',
  630. F_FullName: '公文查阅',
  631. F_UrlAddress: '/EducationalAdministration/Sys_ReceiveFile/Index'
  632. });
  633. });
  634. // 打开关闭聊天窗
  635. $('.lr-im-bell').off('click').on('click', function () {
  636. var $this = $(this);
  637. if ($this.hasClass('open')) {
  638. $this.removeClass('open');
  639. $('.lr-im-body').removeClass('open');
  640. }
  641. else {
  642. $this.addClass('open');
  643. $('.lr-im-bell .point').hide();
  644. $('.lr-im-body').addClass('open');
  645. }
  646. return false;
  647. });
  648. // 联系人
  649. $('#lr_im_content_userlist').lrscroll();
  650. $('#lr_immsg_userlist').lrscroll();
  651. $('.lr-im-msgcontent').lrscroll();
  652. // 联系人列表点击
  653. $('#lr_im_content_userlist .lr-scroll-box').on('click', function (e) {
  654. e = e || window.event;
  655. var et = e.target || e.srcElement;
  656. var $et = $(et);
  657. if (et.tagName == 'IMG' || et.tagName == 'I') {
  658. $et = $et.parent();
  659. }
  660. if ($et.hasClass('lr-im-company')) {// 点击公司项
  661. // 判断是否是打开的状态
  662. if ($et.hasClass('open')) {
  663. $et.removeClass('open');
  664. $et.parent().find('.lr-im-user-list').remove();
  665. } else {
  666. var id = $et.attr('data-value');
  667. var deep = parseInt($et.attr('data-deep'));
  668. var $list = $('<div class="lr-im-user-list" ></div>');
  669. $list.css({ 'padding-left': '10px' });
  670. var flag = false;
  671. // 加载员工
  672. var loginInfo = learun.clientdata.get(['userinfo']);
  673. $.each(userMap[id] || [], function (_index, _item) {
  674. if (_item.id != loginInfo.userId) {
  675. var _html = '\
  676. <div class="lr-im-company-item">\
  677. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  678. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  679. </div>\
  680. </div>';
  681. $list.append(_html);
  682. flag = true;
  683. }
  684. });
  685. // 加载部门
  686. $.each(departmentMap[id] || [], function (_index, _item) {
  687. var _html = '\
  688. <div class="lr-im-company-item">\
  689. <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  690. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  691. </div>\
  692. </div>';
  693. $list.append(_html);
  694. flag = true;
  695. });
  696. // 加载下属公司
  697. $.each(companyMap[id] || [], function (_index, _item) {
  698. var _html = '\
  699. <div class="lr-im-company-item">\
  700. <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  701. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  702. </div>\
  703. </div>';
  704. $list.append(_html);
  705. flag = true;
  706. });
  707. if (flag) {
  708. $et.parent().append($list);
  709. }
  710. $et.addClass('open');
  711. }
  712. return false;
  713. }
  714. else if ($et.hasClass('lr-im-department')) {
  715. // 判断是否是打开的状态
  716. if ($et.hasClass('open')) {
  717. $et.removeClass('open');
  718. $et.parent().find('.lr-im-user-list').remove();
  719. } else {
  720. var id = $et.attr('data-value');
  721. var deep = parseInt($et.attr('data-deep'));
  722. var $list = $('<div class="lr-im-user-list" ></div>');
  723. $list.css({ 'padding-left': '10px' });
  724. var flag = false;
  725. // 加载员工
  726. var loginInfo = learun.clientdata.get(['userinfo']);
  727. $.each(userMap[id] || [], function (_index, _item) {
  728. if (_item.id != loginInfo.userId) {
  729. var _html = '\
  730. <div class="lr-im-company-item">\
  731. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  732. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  733. </div>\
  734. </div>';
  735. $list.append(_html);
  736. flag = true;
  737. }
  738. });
  739. // 加载部门
  740. $.each(departmentMap[id] || [], function (_index, _item) {
  741. var _html = '\
  742. <div class="lr-im-company-item">\
  743. <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  744. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  745. </div>\
  746. </div>';
  747. $list.append(_html);
  748. flag = true;
  749. });
  750. if (flag) {
  751. $et.parent().append($list);
  752. }
  753. $et.addClass('open');
  754. }
  755. }
  756. else if ($et.hasClass('lr-im-user')) {
  757. // 如果是用户列表
  758. // 1.打开聊天窗口
  759. // 2.添加一条最近联系人数据(如果没有添加的话)
  760. // 3.获取最近的20条聊天数据或者最近的聊天信息
  761. var id = $et.attr('data-value');
  762. var $userList = $('#lr_immsg_userlist .lr-scroll-box');
  763. var $userItem = $userList.find('[data-value="' + id + '"]');
  764. // 更新下最近的联系人列表数据
  765. $('.lr-im-title .title-item').eq(0).trigger('click');
  766. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  767. imUserId = id;
  768. if ($userItem.length > 0) {
  769. $userList.prepend($userItem);
  770. $userItem.trigger('click');
  771. }
  772. else {
  773. $userList.find('.active').removeClass('active');
  774. var imgurl = $et.find('img').attr('src');
  775. var _html = '\
  776. <div class="userlist-item" data-value="'+ id + '" >\
  777. <div class="photo"><img src="'+ imgurl + '" >\
  778. <div class="point"></div></div>\
  779. </div>';
  780. $userList.prepend(_html);
  781. // 获取人员数据
  782. learun.clientdata.getAsync('user', {
  783. key: id,
  784. callback: function (data, op) {
  785. $userList.find('[data-value="' + op.key + '"]').attr('title', data.name).addClass('active');
  786. $('#lr_im_msglist .lr-im-right .lr-im-touser').text(data.name);
  787. }
  788. });
  789. learun.im.addContacts(id);
  790. $('.lr-im-msgcontent .lr-scroll-box').html('');
  791. }
  792. $('#lr_im_input').val('');
  793. $('#lr_im_input').select();
  794. }
  795. });
  796. // 最近联系人列表点击
  797. $('#lr_immsg_userlist .lr-scroll-box').on('click', function (e) {
  798. e = e || window.event;
  799. var et = e.target || e.srcElement;
  800. var $et = $(et);
  801. if (!$et.hasClass('userlist-item')) {
  802. $et = $et.parents('.userlist-item');
  803. }
  804. if ($et.length > 0) {
  805. if (!$et.hasClass('active')) {
  806. var name = $et.attr('title');
  807. if (name == undefined) {
  808. name = "";
  809. }
  810. imUserId = $et.attr('data-value');
  811. $('#lr_immsg_userlist .lr-scroll-box .active').removeClass('active');
  812. $et.addClass('active');
  813. $('#lr_im_msglist .lr-im-right .lr-im-touser').text(name);
  814. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  815. $('#lr_im_input').val('');
  816. $('#lr_im_input').select();
  817. $('.lr-im-msgcontent .lr-scroll-box').html('');
  818. // 获取聊天信息
  819. learun.im.getMsgList(imUserId, function (data) {
  820. var len = data.length;
  821. if (len > 0) {
  822. for (var i = len - 1; i >= 0; i--) {
  823. var _item = data[i];
  824. learun.clientdata.getAsync('user', {
  825. key: _item.userId,
  826. msg: _item.content,
  827. time: _item.time,
  828. callback: function (data, op) {
  829. data.id = op.key;
  830. var loginInfo = learun.clientdata.get(['userinfo']);
  831. var _html = '\
  832. <div class="'+ (loginInfo.userId == op.key ? 'im-me' : 'im-other') + '">\
  833. <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
  834. <div class="arrow"></div>\
  835. <span class="content">'+ op.msg + '</span>\
  836. </div>';
  837. $('.lr-im-msgcontent .lr-scroll-box').prepend(_html);
  838. $('.lr-im-msgcontent .lr-scroll-box').prepend('<div class="im-time">' + op.time + '</div>');
  839. }
  840. });
  841. }
  842. $('.lr-im-msgcontent').lrscrollSet('moveBottom');
  843. }
  844. }, $et.hasClass('imHasMsg'));
  845. $et.removeClass('imHasMsg');
  846. learun.im.updateContacts(imUserId);
  847. }
  848. }
  849. });
  850. // 联系人搜索
  851. $('.lr-im-search input').on("keypress", function (e) {
  852. e = e || window.event;
  853. if (e.keyCode == "13") {
  854. var $this = $(this);
  855. var keyword = $this.val();
  856. var $list = $('#lr_im_content_userlist .lr-scroll-box');
  857. $list.html("");
  858. if (keyword) {
  859. learun.clientdata.getAllAsync('user', {
  860. callback: function (data) {
  861. var loginInfo = learun.clientdata.get(['userinfo']);
  862. $.each(data, function (_index, _item) {
  863. if (_index != loginInfo.userId) {
  864. if (_item.name.indexOf(keyword) != -1) {
  865. _item.id = _index;
  866. var _html = '\
  867. <div class="lr-im-company-item">\
  868. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  869. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  870. </div>\
  871. </div>';
  872. $list.append(_html);
  873. }
  874. }
  875. });
  876. }
  877. });
  878. }
  879. else {
  880. $.each(companyMap["0"], function (_index, _item) {
  881. var _html = '\
  882. <div class="lr-im-company-item">\
  883. <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="0" >\
  884. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  885. </div>\
  886. </div>';
  887. $list.append(_html);
  888. });
  889. }
  890. }
  891. });
  892. // 发送消息
  893. $('#lr_im_input').on("keypress", function (e) {
  894. e = e || window.event;
  895. if (e.keyCode == "13") {
  896. var text = $(this).val();
  897. $(this).val('');
  898. if (text.replace(/(^\s*)|(\s*$)/g, "") != '') {
  899. //var time = learun.im.sendMsg(imUserId, text);
  900. var checked = $('#lr_immsg_userlist .userlist-item.active');
  901. if (!checked) {
  902. learun.alert.warning("请选择聊天人员!");
  903. return false;
  904. }
  905. var checkedVal = checked.attr('data-value');
  906. var time = learun.im.sendMsg(checkedVal, text);
  907. sendMsg(text, time);
  908. }
  909. return false;
  910. }
  911. });
  912. // 注册消息接收
  913. learun.im.registerRevMsg(function (userId, msg, dateTime) {
  914. // 判断当前账号是否打开聊天窗口
  915. if (userId == imUserId) {
  916. revMsg(userId, msg, dateTime);
  917. learun.im.updateContacts(userId);
  918. }
  919. else {
  920. var $userList = $('#lr_immsg_userlist .lr-scroll-box');
  921. var $userItem = $userList.find('[data-value="' + userId + '"]');
  922. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  923. if ($userItem.length > 0) {
  924. $userList.prepend($userItem);
  925. if (!$userItem.hasClass('imHasMsg')) {
  926. $userItem.addClass('imHasMsg');
  927. }
  928. }
  929. else {
  930. var html = '<div class="userlist-item imHasMsg" data-value="' + userId + '" >';
  931. if (sysUserMap[userId]) {
  932. html += '<div class="photo"><i class="' + sysUserMap[userId].F_Icon + '" ></i>';
  933. }
  934. else {
  935. html += '<div class="photo"><img src="' + top.$.rootUrl + '/Content/images/head/on-boy.jpg" >';
  936. }
  937. html += '<div class="point"></div></div>';
  938. html += '</div>';
  939. $userList.prepend(html);
  940. if (sysUserMap[userId]) {
  941. var _$item = $userList.find('[data-value="' + userId + '"]');
  942. _$item.attr('title', sysUserMap[userId].F_Name);
  943. _$item = null;
  944. }
  945. else {
  946. learun.clientdata.getAsync('user', {
  947. key: userId,
  948. callback: function (data, op) {
  949. var $item = $userList.find('[data-value="' + op.key + '"]');
  950. $item.attr('title', data.name);
  951. data.id = op.key;
  952. $item.find('img').attr('src', getHeadImg(data));
  953. $item = null;
  954. }
  955. });
  956. }
  957. var _$userItem = $userList.find('.userlist-item');
  958. if (_$userItem.length == 1) {
  959. _$userItem.trigger('click');
  960. }
  961. }
  962. $('#lr_im_input').val('');
  963. $('#lr_im_input').select();
  964. }
  965. if (!$('.lr-im-bell').hasClass('open')) {
  966. $('.lr-im-bell .point').show();
  967. }
  968. });
  969. // 查看聊天记录
  970. $('#lr_im_look_msg_btn').on('click', function () {
  971. //获取聊天用户编号
  972. var checked = $('#lr_immsg_userlist .userlist-item.active');
  973. if (!checked) {
  974. learun.alert.warning("请选择聊天人员!");
  975. return false;
  976. }
  977. var checkedVal = checked.attr('data-value');
  978. learun.layerForm({
  979. id: 'LookMsgIndex',
  980. title: '查看聊天记录-' + $('#lr_im_msglist .lr-im-right .lr-im-touser').text(),
  981. //url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + imUserId,
  982. url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + checkedVal,
  983. width: 800,
  984. height: 500,
  985. maxmin: true,
  986. btn: null
  987. });
  988. });
  989. }
  990. };
  991. im.init();
  992. };