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.
 
 
 
 
 
 

1053 lines
54 KiB

  1. /*
  2. * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
  3. * Copyright (c) 2013-2018 北京泉江科技有限公司
  4. * 创建人:陈彬彬
  5. * 日 期:2017.03.16
  6. * 描 述:经典风格皮肤
  7. */
  8. var autoopenid = request('autoopen');
  9. var pwd = request("pwd");//弱密码修改弹框
  10. var pwdtip = request("pwdtip");//初始密码提示弹框
  11. var 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/ViewIndex'
  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_ReceiveDocument/Index'
  606. });
  607. });
  608. //教师请假归档
  609. $("#btn_studentleave").on('click',
  610. function () {
  611. learun.frameTab.open({
  612. F_ModuleId: '105',
  613. F_Icon: 'fa fa-user',
  614. F_FullName: '普通教师请假归档',
  615. F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/LeaveFiling'
  616. });
  617. });
  618. //中层请假归档
  619. $("#btn_studentleavezc").on('click',
  620. function () {
  621. learun.frameTab.open({
  622. F_ModuleId: '106',
  623. F_Icon: 'fa fa-user',
  624. F_FullName: '中层领导请假归档',
  625. F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/LeaderLeaveFiling'
  626. });
  627. });
  628. // 打开关闭聊天窗
  629. $('.lr-im-bell').off('click').on('click', function () {
  630. var $this = $(this);
  631. if ($this.hasClass('open')) {
  632. $this.removeClass('open');
  633. $('.lr-im-body').removeClass('open');
  634. }
  635. else {
  636. $this.addClass('open');
  637. $('.lr-im-bell .point').hide();
  638. $('.lr-im-body').addClass('open');
  639. }
  640. return false;
  641. });
  642. // 联系人
  643. $('#lr_im_content_userlist').lrscroll();
  644. $('#lr_immsg_userlist').lrscroll();
  645. $('.lr-im-msgcontent').lrscroll();
  646. // 联系人列表点击
  647. $('#lr_im_content_userlist .lr-scroll-box').on('click', function (e) {
  648. e = e || window.event;
  649. var et = e.target || e.srcElement;
  650. var $et = $(et);
  651. if (et.tagName == 'IMG' || et.tagName == 'I') {
  652. $et = $et.parent();
  653. }
  654. if ($et.hasClass('lr-im-company')) {// 点击公司项
  655. // 判断是否是打开的状态
  656. if ($et.hasClass('open')) {
  657. $et.removeClass('open');
  658. $et.parent().find('.lr-im-user-list').remove();
  659. } else {
  660. var id = $et.attr('data-value');
  661. var deep = parseInt($et.attr('data-deep'));
  662. var $list = $('<div class="lr-im-user-list" ></div>');
  663. $list.css({ 'padding-left': '10px' });
  664. var flag = false;
  665. // 加载员工
  666. var loginInfo = learun.clientdata.get(['userinfo']);
  667. $.each(userMap[id] || [], function (_index, _item) {
  668. if (_item.id != loginInfo.userId) {
  669. var _html = '\
  670. <div class="lr-im-company-item">\
  671. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  672. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  673. </div>\
  674. </div>';
  675. $list.append(_html);
  676. flag = true;
  677. }
  678. });
  679. // 加载部门
  680. $.each(departmentMap[id] || [], function (_index, _item) {
  681. var _html = '\
  682. <div class="lr-im-company-item">\
  683. <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  684. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  685. </div>\
  686. </div>';
  687. $list.append(_html);
  688. flag = true;
  689. });
  690. // 加载下属公司
  691. $.each(companyMap[id] || [], function (_index, _item) {
  692. var _html = '\
  693. <div class="lr-im-company-item">\
  694. <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  695. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  696. </div>\
  697. </div>';
  698. $list.append(_html);
  699. flag = true;
  700. });
  701. if (flag) {
  702. $et.parent().append($list);
  703. }
  704. $et.addClass('open');
  705. }
  706. return false;
  707. }
  708. else if ($et.hasClass('lr-im-department')) {
  709. // 判断是否是打开的状态
  710. if ($et.hasClass('open')) {
  711. $et.removeClass('open');
  712. $et.parent().find('.lr-im-user-list').remove();
  713. } else {
  714. var id = $et.attr('data-value');
  715. var deep = parseInt($et.attr('data-deep'));
  716. var $list = $('<div class="lr-im-user-list" ></div>');
  717. $list.css({ 'padding-left': '10px' });
  718. var flag = false;
  719. // 加载员工
  720. var loginInfo = learun.clientdata.get(['userinfo']);
  721. $.each(userMap[id] || [], function (_index, _item) {
  722. if (_item.id != loginInfo.userId) {
  723. var _html = '\
  724. <div class="lr-im-company-item">\
  725. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  726. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  727. </div>\
  728. </div>';
  729. $list.append(_html);
  730. flag = true;
  731. }
  732. });
  733. // 加载部门
  734. $.each(departmentMap[id] || [], function (_index, _item) {
  735. var _html = '\
  736. <div class="lr-im-company-item">\
  737. <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
  738. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  739. </div>\
  740. </div>';
  741. $list.append(_html);
  742. flag = true;
  743. });
  744. if (flag) {
  745. $et.parent().append($list);
  746. }
  747. $et.addClass('open');
  748. }
  749. }
  750. else if ($et.hasClass('lr-im-user')) {
  751. // 如果是用户列表
  752. // 1.打开聊天窗口
  753. // 2.添加一条最近联系人数据(如果没有添加的话)
  754. // 3.获取最近的20条聊天数据或者最近的聊天信息
  755. var id = $et.attr('data-value');
  756. var $userList = $('#lr_immsg_userlist .lr-scroll-box');
  757. var $userItem = $userList.find('[data-value="' + id + '"]');
  758. // 更新下最近的联系人列表数据
  759. $('.lr-im-title .title-item').eq(0).trigger('click');
  760. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  761. imUserId = id;
  762. if ($userItem.length > 0) {
  763. $userList.prepend($userItem);
  764. $userItem.trigger('click');
  765. }
  766. else {
  767. $userList.find('.active').removeClass('active');
  768. var imgurl = $et.find('img').attr('src');
  769. var _html = '\
  770. <div class="userlist-item" data-value="'+ id + '" >\
  771. <div class="photo"><img src="'+ imgurl + '" >\
  772. <div class="point"></div></div>\
  773. </div>';
  774. $userList.prepend(_html);
  775. // 获取人员数据
  776. learun.clientdata.getAsync('user', {
  777. key: id,
  778. callback: function (data, op) {
  779. $userList.find('[data-value="' + op.key + '"]').attr('title', data.name).addClass('active');
  780. $('#lr_im_msglist .lr-im-right .lr-im-touser').text(data.name);
  781. }
  782. });
  783. learun.im.addContacts(id);
  784. $('.lr-im-msgcontent .lr-scroll-box').html('');
  785. }
  786. $('#lr_im_input').val('');
  787. $('#lr_im_input').select();
  788. }
  789. });
  790. // 最近联系人列表点击
  791. $('#lr_immsg_userlist .lr-scroll-box').on('click', function (e) {
  792. e = e || window.event;
  793. var et = e.target || e.srcElement;
  794. var $et = $(et);
  795. if (!$et.hasClass('userlist-item')) {
  796. $et = $et.parents('.userlist-item');
  797. }
  798. if ($et.length > 0) {
  799. if (!$et.hasClass('active')) {
  800. var name = $et.attr('title');
  801. if (name == undefined) {
  802. name = "";
  803. }
  804. imUserId = $et.attr('data-value');
  805. $('#lr_immsg_userlist .lr-scroll-box .active').removeClass('active');
  806. $et.addClass('active');
  807. $('#lr_im_msglist .lr-im-right .lr-im-touser').text(name);
  808. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  809. $('#lr_im_input').val('');
  810. $('#lr_im_input').select();
  811. $('.lr-im-msgcontent .lr-scroll-box').html('');
  812. // 获取聊天信息
  813. learun.im.getMsgList(imUserId, function (data) {
  814. var len = data.length;
  815. if (len > 0) {
  816. for (var i = len - 1; i >= 0; i--) {
  817. var _item = data[i];
  818. learun.clientdata.getAsync('user', {
  819. key: _item.userId,
  820. msg: _item.content,
  821. time: _item.time,
  822. callback: function (data, op) {
  823. data.id = op.key;
  824. var loginInfo = learun.clientdata.get(['userinfo']);
  825. var _html = '\
  826. <div class="'+ (loginInfo.userId == op.key ? 'im-me' : 'im-other') + '">\
  827. <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
  828. <div class="arrow"></div>\
  829. <span class="content">'+ op.msg + '</span>\
  830. </div>';
  831. $('.lr-im-msgcontent .lr-scroll-box').prepend(_html);
  832. $('.lr-im-msgcontent .lr-scroll-box').prepend('<div class="im-time">' + op.time + '</div>');
  833. }
  834. });
  835. }
  836. $('.lr-im-msgcontent').lrscrollSet('moveBottom');
  837. }
  838. }, $et.hasClass('imHasMsg'));
  839. $et.removeClass('imHasMsg');
  840. learun.im.updateContacts(imUserId);
  841. }
  842. }
  843. });
  844. // 联系人搜索
  845. $('.lr-im-search input').on("keypress", function (e) {
  846. e = e || window.event;
  847. if (e.keyCode == "13") {
  848. var $this = $(this);
  849. var keyword = $this.val();
  850. var $list = $('#lr_im_content_userlist .lr-scroll-box');
  851. $list.html("");
  852. if (keyword) {
  853. learun.clientdata.getAllAsync('user', {
  854. callback: function (data) {
  855. var loginInfo = learun.clientdata.get(['userinfo']);
  856. $.each(data, function (_index, _item) {
  857. if (_index != loginInfo.userId) {
  858. if (_item.name.indexOf(keyword) != -1) {
  859. _item.id = _index;
  860. var _html = '\
  861. <div class="lr-im-company-item">\
  862. <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
  863. <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
  864. </div>\
  865. </div>';
  866. $list.append(_html);
  867. }
  868. }
  869. });
  870. }
  871. });
  872. }
  873. else {
  874. $.each(companyMap["0"], function (_index, _item) {
  875. var _html = '\
  876. <div class="lr-im-company-item">\
  877. <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="0" >\
  878. <i class="fa fa-angle-right"></i>'+ _item.name + '\
  879. </div>\
  880. </div>';
  881. $list.append(_html);
  882. });
  883. }
  884. }
  885. });
  886. // 发送消息
  887. $('#lr_im_input').on("keypress", function (e) {
  888. e = e || window.event;
  889. if (e.keyCode == "13") {
  890. var text = $(this).val();
  891. $(this).val('');
  892. if (text.replace(/(^\s*)|(\s*$)/g, "") != '') {
  893. //var time = learun.im.sendMsg(imUserId, text);
  894. var checked = $('#lr_immsg_userlist .userlist-item.active');
  895. if (!checked) {
  896. learun.alert.warning("请选择聊天人员!");
  897. return false;
  898. }
  899. var checkedVal = checked.attr('data-value');
  900. var time = learun.im.sendMsg(checkedVal, text);
  901. sendMsg(text, time);
  902. }
  903. return false;
  904. }
  905. });
  906. // 注册消息接收
  907. learun.im.registerRevMsg(function (userId, msg, dateTime) {
  908. // 判断当前账号是否打开聊天窗口
  909. if (userId == imUserId) {
  910. revMsg(userId, msg, dateTime);
  911. learun.im.updateContacts(userId);
  912. }
  913. else {
  914. var $userList = $('#lr_immsg_userlist .lr-scroll-box');
  915. var $userItem = $userList.find('[data-value="' + userId + '"]');
  916. $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
  917. if ($userItem.length > 0) {
  918. $userList.prepend($userItem);
  919. if (!$userItem.hasClass('imHasMsg')) {
  920. $userItem.addClass('imHasMsg');
  921. }
  922. }
  923. else {
  924. var html = '<div class="userlist-item imHasMsg" data-value="' + userId + '" >';
  925. if (sysUserMap[userId]) {
  926. html += '<div class="photo"><i class="' + sysUserMap[userId].F_Icon + '" ></i>';
  927. }
  928. else {
  929. html += '<div class="photo"><img src="' + top.$.rootUrl + '/Content/images/head/on-boy.jpg" >';
  930. }
  931. html += '<div class="point"></div></div>';
  932. html += '</div>';
  933. $userList.prepend(html);
  934. if (sysUserMap[userId]) {
  935. var _$item = $userList.find('[data-value="' + userId + '"]');
  936. _$item.attr('title', sysUserMap[userId].F_Name);
  937. _$item = null;
  938. }
  939. else {
  940. learun.clientdata.getAsync('user', {
  941. key: userId,
  942. callback: function (data, op) {
  943. var $item = $userList.find('[data-value="' + op.key + '"]');
  944. $item.attr('title', data.name);
  945. data.id = op.key;
  946. $item.find('img').attr('src', getHeadImg(data));
  947. $item = null;
  948. }
  949. });
  950. }
  951. var _$userItem = $userList.find('.userlist-item');
  952. if (_$userItem.length == 1) {
  953. _$userItem.trigger('click');
  954. }
  955. }
  956. $('#lr_im_input').val('');
  957. $('#lr_im_input').select();
  958. }
  959. if (!$('.lr-im-bell').hasClass('open')) {
  960. $('.lr-im-bell .point').show();
  961. }
  962. });
  963. // 查看聊天记录
  964. $('#lr_im_look_msg_btn').on('click', function () {
  965. //获取聊天用户编号
  966. var checked = $('#lr_immsg_userlist .userlist-item.active');
  967. if (!checked) {
  968. learun.alert.warning("请选择聊天人员!");
  969. return false;
  970. }
  971. var checkedVal = checked.attr('data-value');
  972. learun.layerForm({
  973. id: 'LookMsgIndex',
  974. title: '查看聊天记录-' + $('#lr_im_msglist .lr-im-right .lr-im-touser').text(),
  975. //url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + imUserId,
  976. url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + checkedVal,
  977. width: 800,
  978. height: 500,
  979. maxmin: true,
  980. btn: null
  981. });
  982. });
  983. }
  984. };
  985. //im.init();
  986. };