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.
 
 
 
 
 
 

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