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.

index.js 52 KiB

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