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.
 
 
 
 
 
 

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