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.
 
 
 
 
 
 

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