|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019 |
- /*
- * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn)
- * Copyright (c) 2013-2018 北京泉江科技有限公司
- * 创建人:陈彬彬
- * 日 期:2017.03.16
- * 描 述:经典风格皮肤
- */
- var autoopenid = request('autoopen');
- var pwd = request("pwd");
- var bootstrap = function ($, learun) {
- "use strict";
- // 菜单操作
- var meuns = {
- init: function () {
- this.load();
- this.bind();
- },
- load: function () {
- var modulesTree = learun.clientdata.get(['modulesTree']);
- // 第一级菜单
- var parentId = '0';
- var modules = modulesTree[parentId] || [];
- var $firstmenus = $('<ul class="lr-first-menu-list"></ul>');
-
- for (var i = 0, l = modules.length; i < l; i++) {
- var item = modules[i];
- if (item.F_IsMenu == 1) {
- var $firstMenuItem = $('<li></li>');
- if (!!item.F_Description) {
- $firstMenuItem.attr('title', item.F_Description);
- }
- var menuItemHtml = '<a id="' + item.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item">';
- menuItemHtml += '<i class="' + item.F_Icon + ' lr-menu-item-icon"></i>';
- menuItemHtml += '<span class="lr-menu-item-text">' + item.F_FullName + '</span>';
- menuItemHtml += '</a>';
- $firstMenuItem.append(menuItemHtml);
- // 第二级菜单
- // var secondModules = modulesTree[item.F_ModuleId] || [];
- // var $secondMenus = $('<ul class="lr-second-menu-list"></ul>');
- // var secondMenuHad = false;
- // for (var j = 0, sl = secondModules.length; j < sl; j++) {
- // var secondItem = secondModules[j];
- // if (secondItem.F_IsMenu == 1) {
- // secondMenuHad = true;
- // var $secondMenuItem = $('<li></li>');
- // if (!!secondItem.F_Description) {
- // $secondMenuItem.attr('title', secondItem.F_Description);
- // }
- // var secondItemHtml = '<a id="' + secondItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
- // secondItemHtml += '<i class="' + secondItem.F_Icon + ' lr-menu-item-icon"></i>';
- // secondItemHtml += '<span class="lr-menu-item-text">' + secondItem.F_FullName + '</span>';
- // secondItemHtml += '</a>';
- //
- // $secondMenuItem.append(secondItemHtml);
- // // 第三级菜单
- // var threeModules = modulesTree[secondItem.F_ModuleId] || [];
- // var $threeMenus = $('<ul class="lr-three-menu-list"></ul>');
- // var threeMenuHad = false;
- // for (var m = 0, tl = threeModules.length; m < tl; m++) {
- // var threeItem = threeModules[m];
- // if (threeItem.F_IsMenu == 1) {
- // threeMenuHad = true;
- // var $threeMenuItem = $('<li></li>');
- // $threeMenuItem.attr('title', threeItem.F_FullName);
- // var threeItemHtml = '<a id="' + threeItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
- // threeItemHtml += '<i class="' + threeItem.F_Icon + ' lr-menu-item-icon"></i>';
- // threeItemHtml += '<span class="lr-menu-item-text">' + threeItem.F_FullName + '</span>';
- // threeItemHtml += '</a>';
- // $threeMenuItem.append(threeItemHtml);
- // //第四级菜单
- // var fourModules = modulesTree[threeItem.F_ModuleId] || [];
- // var $fourMenus = $('<ul class="lr-four-menu-list"></ul>');
- // var fourMenuHad = false;
- // for (var n = 0, fl = fourModules.length; n < fl; n++) {
- // var fourItem = fourModules[n];
- // if (fourItem.F_IsMenu == 1) {
- // fourMenuHad = true;
- // var $fourMenuItem = $('<li></li>');
- // $fourMenuItem.attr('title', fourItem.F_FullName);
- // var fourItemHtml = '<a id="' + fourItem.F_ModuleId + '" href="javascript:void(0);" class="lr-menu-item" >';
- // fourItemHtml += '<i class="' + fourItem.F_Icon + ' lr-menu-item-icon"></i>';
- // fourItemHtml += '<span class="lr-menu-item-text">' + fourItem.F_FullName + '</span>';
- // fourItemHtml += '</a>';
- // $fourMenuItem.append(fourItemHtml);
- // $fourMenus.append($fourMenuItem);
- // }
- // }
- // if (fourMenuHad) {
- // $threeMenuItem.addClass('lr-meun-had');
- // $threeMenuItem.append($fourMenus);
- // }
- // $threeMenus.append($threeMenuItem);
- // }
- // }
- // if (threeMenuHad) {
- // $secondMenuItem.addClass('lr-meun-had');
- // $secondMenuItem.append($threeMenus);
- // }
- // $secondMenus.append($secondMenuItem);
- // }
- // }
- // if (secondMenuHad) {
- // $firstMenuItem.append($secondMenus);
- // }
- $firstmenus.append($firstMenuItem);
- }
- }
- $('#lr_frame_menu').html($firstmenus);
-
-
- // 语言包翻译
- $('.lr-menu-item-text').each(function () {
- var $this = $(this);
- var text = $this.text();
- learun.language.get(text, function (text) {
- $this.text(text);
- $this.parent().parent().attr('title', text);
- });
- });
- },
- bind: function () {
- $("#lr_frame_menu").lrscroll();
- $("#lr_frame_menu .lr-first-menu-list > li").hover(function (e) {// 一级菜单选中的时候判断二级菜单的位置
- //$('#lr_frame_menu').width(4000);
- var $secondMenu = $(this).find('.lr-second-menu-list');
- var length = $secondMenu.find('li').length;
- if (length > 0) {
- $secondMenu.css('top', '0px');
- var secondMenuTop = $(this).offset().top + $secondMenu.height() + 23;
- var bodyHeight = $(window).height();
- if (secondMenuTop > bodyHeight) {
- $secondMenu.css('top', '-' + (secondMenuTop - bodyHeight) + 'px');
- }
- }
- }, function (e) {
- $('#lr_frame_menu').width(80);
- });
-
- $("#lr_frame_menu .lr-second-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置
- var $ul = $(this).find('.lr-three-menu-list');
- $ul.css('top', '-9px');
- var ulTop = $(this).offset().top + $ul.height() + 23;
- var bodyHeight = $(window).height();
- if (ulTop > bodyHeight) {
- $ul.css('top', '-' + (ulTop - bodyHeight) + 'px');
- }
- });
- $("#lr_frame_menu .lr-three-menu-list > li.lr-meun-had").hover(function (e) {// 二级菜单选中的时候判断三级菜单的位置
- var $ul = $(this).find('.lr-four-menu-list');
- $ul.css('top', '-9px');
- var ulTop = $(this).offset().top + $ul.height() + 23;
- var bodyHeight = $(window).height();
- if (ulTop > bodyHeight) {
- $ul.css('top', '-' + (ulTop - bodyHeight) + 'px');
- }
- });
-
- var desktopnavigation = learun.clientdata.get(['modulesMap', "be81bdde-8bbc-4080-b976-84faefc414d2"]);
- // 添加点击事件
- $('#lr_frame_menu .lr-menu-item').on('click', function () {
- var $obj = $(this);
- var id = $obj.attr('id');
- if ($('#lr_tab_be81bdde-8bbc-4080-b976-84faefc414d2').length != 0) {
- learun.frameTab.close('be81bdde-8bbc-4080-b976-84faefc414d2');
- }
-
- var _module = learun.clientdata.get(['modulesMap', id]);
- learun.frameTab.open({ F_ModuleId: desktopnavigation.F_ModuleId, F_Icon: desktopnavigation.F_Icon, F_FullName: desktopnavigation.F_FullName, F_UrlAddress: desktopnavigation.F_UrlAddress + '?id=' + id }, false);
- });
-
- //使用引导页
- var guide = learun.clientdata.get(['modulesMap', "44e91494-942d-482d-949e-ae8af5333956"]);
- if (guide) {
- //learun.frameTab.open(guide);
- learun.frameTab.open({ F_ModuleId: guide.F_ModuleId, F_Icon: guide.F_Icon, F_FullName: guide.F_FullName, F_UrlAddress: guide.F_UrlAddress }, true);
- }
- //上网认证
- if (ACIp != null && ACIp != "") {
- //Ip上网
- sendToAc(ACIp, 'logon', Ip, learun.clientdata.get(['userinfo']).account, '');
- }
- if (ACIp2 != null && ACIp2 != "") {
- //Ip上网
- sendToAc(ACIp2, 'logon', Ip, learun.clientdata.get(['userinfo']).account, '');
- }
- //桌面导航
- // var desktopnavigation = learun.clientdata.get(['modulesMap', "be81bdde-8bbc-4080-b976-84faefc414d2"]);
- // if (desktopnavigation) {
- // learun.frameTab.open({ F_ModuleId: desktopnavigation.F_ModuleId, F_Icon: desktopnavigation.F_Icon, F_FullName: desktopnavigation.F_FullName, F_UrlAddress: desktopnavigation.F_UrlAddress }, true);
- // }
- //var needtodo = learun.clientdata.get(['modulesMap', "021a59b0-2589-4f9e-8140-6052177a967c"]);
- //if (needtodo) {
- // //自动弹出待办事项
- // top.layer.open({
- // id: 'ntdform',
- // title: '我的待办事项',
- // type: 2,
- // skin: 'lr-layer',
- // btn: ['关闭'],
- // content: top.$.rootUrl + '/Home/NeedToDoForm',
- // area: ['500px', '300px']
- // });
- //}
- if (pwd == "true") {
- top.layer.open({
- id: 'pwdform',
- title: '密码修改',
- closeBtn: 0,
- resize: false,
- type: 2,
- skin: 'lr-layer',
- btn: ['确定'],
- content: top.$.rootUrl + '/Home/ChangePwd',
- area: ['500px', '300px'],
- success: function (layero, index) {
- top['layer_pwdform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- layero[0].learun_layerid = 'layer_pwdform';
- },
- yes: function (index, layero) {
- var flag = top['layer_pwdform'].acceptClick(function () {
- top.location.href = "/Login/Index";
- });
- if (!!flag) {
- learun.layerClose('', index);
- }
- },
- end: function () {
- top['layer_pwdform'] = null;
- }
- });
- }
- if (!!autoopenid) {
- var _module = learun.clientdata.get(['modulesMap', autoopenid]);
- switch (_module.F_Target) {
- case 'iframe':// 窗口
- if (learun.validator.isNotNull(_module.F_UrlAddress).code) {
- learun.frameTab.open(_module);
- var keyValue = request('keyValue');
- //内部邮件
- if (autoopenid == '252878d7-d807-497f-b01e-839bb1b869c6' && !!keyValue) {
- var iframe = document.getElementById('lr_iframe_' + autoopenid);
- top.layer.open({
- id: 'viewform',
- title: '查看',
- type: 2,
- skin: 'lr-layer',
- btn: ['回复', '转发', '关闭'],
- content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormView?keyValue=' + keyValue,
- area: ['800px', '700px'],
- success: function (layero, index) {
- top['viewform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- //自动已读
- learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Read', { keyValue: keyValue }, function () {
- iframe.contentWindow.refreshreceivetableGirdData();
- });
- },
- yes: function (index, layero) {
- top.layer.open({
- id: 'resendform',
- title: '回复邮件',
- type: 2,
- skin: 'lr-layer',
- btn: ['发送', '保存草稿', '关闭'],
- content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/Form?keyValue=' + keyValue,
- area: ['800px', '700px'],
- success: function (layero, index) {
- top['resendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- },
- yes: function (index, layero) {
- top['resendform'].acceptClick(iframe.contentWindow.sendthismessage);
- top['resendform'] = null;
- top.layer.close(index);
- }
- , btn2: function (index, layero) {
- top['resendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData);
- top['resendform'] = null;
- top.layer.close(index);
- }
- , btn3: function (index, layero) {
- top['resendform'] = null;
- top.layer.close(index);
- }
- });
- top['viewform'] = null;
- top.layer.close(index);
- },
- btn2: function (index, layero) {
- top.layer.open({
- id: 'chsendform',
- title: '转发邮件',
- type: 2,
- skin: 'lr-layer',
- btn: ['发送', '保存草稿', '关闭'],
- content: top.$.rootUrl + '/EducationalAdministration/SYS_ReceiveMessage/FormCh?keyValue=' + keyValue,
- area: ['800px', '700px'],
- success: function (layero, index) {
- top['chsendform'] = learun.iframe($(layero).find('iframe').attr('id'), top.frames);
- },
- yes: function (index, layero) {
- top['chsendform'].acceptClick(iframe.contentWindow.sendthismessage);
- top['chsendform'] = null;
- top.layer.close(index);
- }
- , btn2: function (index, layero) {
- top['chsendform'].acceptClick(iframe.contentWindow.refreshsendtableGirdData);
- top['chsendform'] = null;
- top.layer.close(index);
- }
- , btn3: function (index, layero) {
- top['chsendform'] = null;
- top.layer.close(index);
- }
- });
- top['viewform'] = null;
- top.layer.close(index);
- },
- btn3: function (index, layero) {
- top['viewform'] = null;
- top.layer.close(index);
- }
- });
- }
- //我的任务
- if (autoopenid == '021a59b0-2589-4f9e-8140-6052177a967c' && !!request('F_Id')) {
- var processId = request('F_Id');
- var taskId = request('F_TaskId');
- var taskType = request('F_TaskType');
- if (taskType == 4) {
- if (learun.checkrow(taskId)) {
- 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 });
- }
- }
- else if (taskType == 1) {
- if (learun.checkrow(taskId)) {
- 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 });
- }
- }
- else if (taskType == 2) {
- learun.alert.warning('请点击重新发起');
- }
- else {
- if (learun.checkrow(taskId)) {
- 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 });
- }
- }
- }
- //办事大厅
- if (autoopenid == '56ce34c2-882e-47d1-b12d-5036e3b79fcf' && !!request('shcemeCode')) {
- var id = request('id');
- var shcemeCode = request('shcemeCode');
- //learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_WorkFlowModule/WfMyTask/CustmerWorkFlowForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=0' });
-
- learun.frameTab.open({ F_ModuleId: id, F_Icon: 'fa magic', F_FullName: '发起流程【快捷发起】', F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/NWFContainerForm?shcemeCode=' + shcemeCode + '&tabIframeId=' + id + '&type=create' });
- }
- //公告
- if (autoopenid == '6252983c-52f5-402c-991b-ad19a9cb1f94' && !!keyValue) {
- learun.frameTab.open({
- F_ModuleId: "dtlist" + keyValue,
- F_FullName: '通知公告',
- F_UrlAddress: "/Utility/ListContentIndex?id=" + keyValue
- });
- }
- }
- break;
- case 'open':// 窗口
- var newWin = window.open(_module.F_UrlAddress);
- newWin.location.replace(_module.F_UrlAddress);
- break;
- }
- }
- }
- };
- meuns.init();
-
-
- var companyMap = {};
- var departmentMap = {};
- var userMap = {};
- var sysUserMap = {};
-
- var imUserId = '';
-
- //获取头像
- var getHeadImg = function (user) {
- var url = top.$.rootUrl;
- switch (user.img) {
- case '0':
- url += '/Content/images/head/on-girl.jpg';
- break;
- case '1':
- url += '/Content/images/head/on-boy.jpg';
- break;
- default:
- url += '/LR_OrganizationModule/User/GetImg?userId=' + user.id;
- break;
- }
- return url;
- };
- // 发送聊天信息
- var sendMsg = function (msg, time) {
- var loginInfo = learun.clientdata.get(['userinfo']);
- learun.clientdata.getAsync('user', {
- key: loginInfo.userId,
- callback: function (data, op) {
- data.id = op.key;
- var _html = '\
- <div class="im-me">\
- <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
- <div class="arrow"></div>\
- <span class="content">'+ msg + '</span>\
- </div>';
-
- if (time && time != '') {
- $('.lr-im-msgcontent .lr-scroll-box').append('<div class="im-time">' + time + '</div>');
- }
-
- $('.lr-im-msgcontent .lr-scroll-box').append(_html);
- $('.lr-im-msgcontent').lrscrollSet('moveBottom');
- }
- });
- };
- // 接收聊天消息
- var revMsg = function (userId, msg, time) {
- learun.clientdata.getAsync('user', {
- key: userId,
- callback: function (data, op) {
- data.id = op.key;
- var _html = '\
- <div class="im-other">\
- <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
- <div class="arrow"></div>\
- <span class="content">'+ msg + '</span>\
- </div>';
-
- if (time && time != '') {
- $('.lr-im-msgcontent .lr-scroll-box').append('<div class="im-time">' + time + '</div>');
- }
-
- $('.lr-im-msgcontent .lr-scroll-box').append(_html);
- $('.lr-im-msgcontent').lrscrollSet('moveBottom');
- }
- });
- };
-
-
- // 即时通讯
- var im = {
- init: function () {
- this.bind();
- this.load();
- },
- load: function () {
- // 获取下公司列表
- learun.clientdata.getAllAsync('company', {
- callback: function (data) {
- $.each(data, function (_id, _item) {
- companyMap[_item.parentId] = companyMap[_item.parentId] || [];
- _item.id = _id;
- companyMap[_item.parentId].push(_item);
- });
- var $list = $('#lr_im_content_userlist .lr-scroll-box');
- $list.html("");
- $.each(companyMap["0"], function (_index, _item) {
-
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="0" >\
- <i class="fa fa-angle-right"></i>'+ _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
-
- });
- // 获取部门列表
- learun.clientdata.getAllAsync('department', {
- callback: function (data) {
- $.each(data, function (_id, _item) {
- _item.id = _id;
- if (_item.parentId == "0") {
- departmentMap[_item.companyId] = departmentMap[_item.companyId] || [];
- departmentMap[_item.companyId].push(_item);
- }
- else {
- departmentMap[_item.parentId] = departmentMap[_item.parentId] || [];
- departmentMap[_item.parentId].push(_item);
- }
- });
- // 获取人员数据
- learun.clientdata.getAllAsync('user', {
- callback: function (data) {
- $.each(data, function (_id, _item) {
- _item.id = _id;
- if (_item.departmentId) {
- userMap[_item.departmentId] = userMap[_item.departmentId] || [];
- userMap[_item.departmentId].push(_item);
- }
- else if (_item.companyId) {
- userMap[_item.companyId] = userMap[_item.companyId] || [];
- userMap[_item.companyId].push(_item);
- }
- });
- // 获取最近联系人列表
- learun.im.getContacts(function (data, sysUserList) {
- $.each(sysUserList, function (_index, _item) {
- sysUserMap[_item.F_Code] = _item;
- });
- var $userList = $('#lr_immsg_userlist .lr-scroll-box');
- $userList.html("");
- $.each(data, function (_index, _item) {
- var html = ' <div class="userlist-item ' + (_item.F_IsRead == '1' ? 'imHasMsg' : '') + '" data-value="' + _item.F_OtherUserId + '" >';
- if (sysUserMap[_item.F_OtherUserId]) {
- html += '<div class="photo"><i class="' + sysUserMap[_item.F_OtherUserId].F_Icon + '" ></i>';
- }
- else {
- html += '<div class="photo"><img src="' + top.$.rootUrl + '/Content/images/head/on-boy.jpg" >';
- }
- html += '<div class="point"></div></div>';
- html += '</div>';
- $userList.append(html);
- if (sysUserMap[_item.F_OtherUserId]) {
- var _$item = $userList.find('[data-value="' + _item.F_OtherUserId + '"]');
- _$item.attr('title', sysUserMap[_item.F_OtherUserId].F_Name);
-
- if (_index == 0) {
- _$item.trigger('click');
- }
- _$item = null;
- }
- else {
- learun.clientdata.getAsync('user', {
- key: _item.F_OtherUserId,
- index: _index,
- callback: function (data, op) {
- var $item = $userList.find('[data-value="' + op.key + '"]');
- $item.attr('title', data.name);
- data.id = op.key;
- $item.find('img').attr('src', getHeadImg(data));
- if (op.index == 0) {
- $item.trigger('click');
- }
- $item = null;
- }
- });
- }
- });
- });
- }
- });
- }
- });
-
- }
- });
- },
- bind: function () {
- // 最近消息 与 联系人之间的切换
- $('.lr-im-title .title-item').on('click', function () {
- var $this = $(this);
- if (!$this.hasClass('active')) {
- $('.lr-im-body>.active').removeClass('active');
- $('.lr-im-title>.active').removeClass('active');
- $this.addClass('active');
- var v = $this.attr('data-value');
- $('#' + v).addClass('active');
- }
- });
-
- $(".lr-lzca-user").on('click',
- function () {
- learun.httpPost(top.$.rootUrl + '/Home/GetOnlineUserInfo',
- {},
- function (op) {
- if (op.data) {
- var content = '';
- $.each(op.data, function (i, item) {
-
- content += '<li>' + item.F_RealName + '(' + item.Source + ')' + '</li>';
- console.log(item.F_RealName + "(" + item.Source + ")")
- })
-
- $(".lr-lzca-user-ul").html(content);
-
-
- }
- });
- });
-
- $("#btn_daiban").on('click',
- function () {
- learun.frameTab.open({
- F_ModuleId: '101',
- F_Icon: 'fa fa-user',
- F_FullName: '流程任务',
- F_UrlAddress: '/LR_NewWorkFlow/NWFProcess/Index'
- });
- });
- $("#btn_youjian").on('click',
- function () {
- learun.frameTab.open({
- F_ModuleId: '102',
- F_Icon: 'fa fa-user',
- F_FullName: '内部邮件',
- F_UrlAddress: '/EducationalAdministration/LanMail/Index'
- });
- });
-
- $("#btn_tonggao").on('click',
- function () {
- learun.frameTab.open({
- F_ModuleId: '103',
- F_Icon: 'fa fa-user',
- F_FullName: '下发通知公告',
- F_UrlAddress: '/LR_OAModule/Notice/Index'
- });
- });
-
- $("#btn_gongwen").on('click',
- function () {
- learun.frameTab.open({
- F_ModuleId: '104',
- F_Icon: 'fa fa-user',
- F_FullName: '公文查阅',
- F_UrlAddress: '/EducationalAdministration/Sys_ReceiveFile/Index'
- });
- });
-
- // 打开关闭聊天窗
- $('.lr-im-bell').off('click').on('click', function () {
- var $this = $(this);
- if ($this.hasClass('open')) {
- $this.removeClass('open');
- $('.lr-im-body').removeClass('open');
- }
- else {
- $this.addClass('open');
- $('.lr-im-bell .point').hide();
- $('.lr-im-body').addClass('open');
- }
- return false;
- });
- // 联系人
- $('#lr_im_content_userlist').lrscroll();
- $('#lr_immsg_userlist').lrscroll();
- $('.lr-im-msgcontent').lrscroll();
-
- // 联系人列表点击
- $('#lr_im_content_userlist .lr-scroll-box').on('click', function (e) {
- e = e || window.event;
- var et = e.target || e.srcElement;
- var $et = $(et);
-
- if (et.tagName == 'IMG' || et.tagName == 'I') {
- $et = $et.parent();
- }
-
- if ($et.hasClass('lr-im-company')) {// 点击公司项
- // 判断是否是打开的状态
- if ($et.hasClass('open')) {
- $et.removeClass('open');
- $et.parent().find('.lr-im-user-list').remove();
-
- } else {
- var id = $et.attr('data-value');
- var deep = parseInt($et.attr('data-deep'));
- var $list = $('<div class="lr-im-user-list" ></div>');
- $list.css({ 'padding-left': '10px' });
- var flag = false;
- // 加载员工
- var loginInfo = learun.clientdata.get(['userinfo']);
- $.each(userMap[id] || [], function (_index, _item) {
- if (_item.id != loginInfo.userId) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
- <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- flag = true;
- }
- });
- // 加载部门
- $.each(departmentMap[id] || [], function (_index, _item) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
- <i class="fa fa-angle-right"></i>'+ _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- flag = true;
- });
- // 加载下属公司
- $.each(companyMap[id] || [], function (_index, _item) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
- <i class="fa fa-angle-right"></i>'+ _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- flag = true;
- });
-
-
-
- if (flag) {
- $et.parent().append($list);
- }
- $et.addClass('open');
- }
- return false;
- }
- else if ($et.hasClass('lr-im-department')) {
- // 判断是否是打开的状态
- if ($et.hasClass('open')) {
- $et.removeClass('open');
- $et.parent().find('.lr-im-user-list').remove();
-
- } else {
- var id = $et.attr('data-value');
- var deep = parseInt($et.attr('data-deep'));
- var $list = $('<div class="lr-im-user-list" ></div>');
- $list.css({ 'padding-left': '10px' });
- var flag = false;
- // 加载员工
- var loginInfo = learun.clientdata.get(['userinfo']);
- $.each(userMap[id] || [], function (_index, _item) {
- if (_item.id != loginInfo.userId) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
- <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- flag = true;
- }
- });
- // 加载部门
- $.each(departmentMap[id] || [], function (_index, _item) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-department" data-value="'+ _item.id + '" data-deep="' + (deep + 1) + '" >\
- <i class="fa fa-angle-right"></i>'+ _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- flag = true;
- });
-
- if (flag) {
- $et.parent().append($list);
- }
- $et.addClass('open');
-
- }
-
- }
- else if ($et.hasClass('lr-im-user')) {
- // 如果是用户列表
- // 1.打开聊天窗口
- // 2.添加一条最近联系人数据(如果没有添加的话)
- // 3.获取最近的20条聊天数据或者最近的聊天信息
-
- var id = $et.attr('data-value');
- var $userList = $('#lr_immsg_userlist .lr-scroll-box');
- var $userItem = $userList.find('[data-value="' + id + '"]');
-
- // 更新下最近的联系人列表数据
-
- $('.lr-im-title .title-item').eq(0).trigger('click');
-
- $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
-
- imUserId = id;
- if ($userItem.length > 0) {
- $userList.prepend($userItem);
- $userItem.trigger('click');
- }
- else {
- $userList.find('.active').removeClass('active');
- var imgurl = $et.find('img').attr('src');
-
- var _html = '\
- <div class="userlist-item" data-value="'+ id + '" >\
- <div class="photo"><img src="'+ imgurl + '" >\
- <div class="point"></div></div>\
- </div>';
-
- $userList.prepend(_html);
-
- // 获取人员数据
- learun.clientdata.getAsync('user', {
- key: id,
- callback: function (data, op) {
- $userList.find('[data-value="' + op.key + '"]').attr('title', data.name).addClass('active');
- $('#lr_im_msglist .lr-im-right .lr-im-touser').text(data.name);
- }
- });
- learun.im.addContacts(id);
- $('.lr-im-msgcontent .lr-scroll-box').html('');
- }
- $('#lr_im_input').val('');
- $('#lr_im_input').select();
- }
- });
- // 最近联系人列表点击
- $('#lr_immsg_userlist .lr-scroll-box').on('click', function (e) {
- e = e || window.event;
- var et = e.target || e.srcElement;
- var $et = $(et);
-
- if (!$et.hasClass('userlist-item')) {
- $et = $et.parents('.userlist-item');
- }
- if ($et.length > 0) {
- if (!$et.hasClass('active')) {
- var name = $et.attr('title');
- if (name == undefined) {
- name = "";
- }
- imUserId = $et.attr('data-value');
-
- $('#lr_immsg_userlist .lr-scroll-box .active').removeClass('active');
- $et.addClass('active');
- $('#lr_im_msglist .lr-im-right .lr-im-touser').text(name);
- $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
-
- $('#lr_im_input').val('');
- $('#lr_im_input').select();
-
- $('.lr-im-msgcontent .lr-scroll-box').html('');
- // 获取聊天信息
- learun.im.getMsgList(imUserId, function (data) {
- var len = data.length;
- if (len > 0) {
- for (var i = len - 1; i >= 0; i--) {
- var _item = data[i];
- learun.clientdata.getAsync('user', {
- key: _item.userId,
- msg: _item.content,
- time: _item.time,
- callback: function (data, op) {
- data.id = op.key;
- var loginInfo = learun.clientdata.get(['userinfo']);
- var _html = '\
- <div class="'+ (loginInfo.userId == op.key ? 'im-me' : 'im-other') + '">\
- <div class="headimg"><img src="'+ getHeadImg(data) + '"></div>\
- <div class="arrow"></div>\
- <span class="content">'+ op.msg + '</span>\
- </div>';
- $('.lr-im-msgcontent .lr-scroll-box').prepend(_html);
- $('.lr-im-msgcontent .lr-scroll-box').prepend('<div class="im-time">' + op.time + '</div>');
- }
- });
- }
- $('.lr-im-msgcontent').lrscrollSet('moveBottom');
- }
- }, $et.hasClass('imHasMsg'));
- $et.removeClass('imHasMsg');
- learun.im.updateContacts(imUserId);
- }
- }
- });
- // 联系人搜索
- $('.lr-im-search input').on("keypress", function (e) {
- e = e || window.event;
- if (e.keyCode == "13") {
- var $this = $(this);
- var keyword = $this.val();
- var $list = $('#lr_im_content_userlist .lr-scroll-box');
- $list.html("");
- if (keyword) {
- learun.clientdata.getAllAsync('user', {
- callback: function (data) {
- var loginInfo = learun.clientdata.get(['userinfo']);
- $.each(data, function (_index, _item) {
- if (_index != loginInfo.userId) {
- if (_item.name.indexOf(keyword) != -1) {
- _item.id = _index;
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-user" data-value="'+ _item.id + '" >\
- <img src="'+ getHeadImg(_item) + '" >' + _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- }
- }
- });
- }
- });
- }
- else {
- $.each(companyMap["0"], function (_index, _item) {
- var _html = '\
- <div class="lr-im-company-item">\
- <div class="lr-im-item-name lr-im-company" data-value="'+ _item.id + '" data-deep="0" >\
- <i class="fa fa-angle-right"></i>'+ _item.name + '\
- </div>\
- </div>';
- $list.append(_html);
- });
- }
-
- }
- });
- // 发送消息
- $('#lr_im_input').on("keypress", function (e) {
- e = e || window.event;
- if (e.keyCode == "13") {
- var text = $(this).val();
- $(this).val('');
- if (text.replace(/(^\s*)|(\s*$)/g, "") != '') {
- //var time = learun.im.sendMsg(imUserId, text);
-
- var checked = $('#lr_immsg_userlist .userlist-item.active');
- if (!checked) {
- learun.alert.warning("请选择聊天人员!");
- return false;
- }
- var checkedVal = checked.attr('data-value');
-
- var time = learun.im.sendMsg(checkedVal, text);
- sendMsg(text, time);
- }
-
- return false;
- }
- });
-
- // 注册消息接收
- learun.im.registerRevMsg(function (userId, msg, dateTime) {
- // 判断当前账号是否打开聊天窗口
- if (userId == imUserId) {
- revMsg(userId, msg, dateTime);
- learun.im.updateContacts(userId);
- }
- else {
- var $userList = $('#lr_immsg_userlist .lr-scroll-box');
- var $userItem = $userList.find('[data-value="' + userId + '"]');
- $('#lr_im_msglist .lr-im-right').removeClass('lr-im-nouser');
-
- if ($userItem.length > 0) {
- $userList.prepend($userItem);
- if (!$userItem.hasClass('imHasMsg')) {
- $userItem.addClass('imHasMsg');
- }
- }
- else {
- var html = '<div class="userlist-item imHasMsg" data-value="' + userId + '" >';
- if (sysUserMap[userId]) {
- html += '<div class="photo"><i class="' + sysUserMap[userId].F_Icon + '" ></i>';
- }
- else {
- html += '<div class="photo"><img src="' + top.$.rootUrl + '/Content/images/head/on-boy.jpg" >';
- }
-
- html += '<div class="point"></div></div>';
- html += '</div>';
- $userList.prepend(html);
- if (sysUserMap[userId]) {
- var _$item = $userList.find('[data-value="' + userId + '"]');
- _$item.attr('title', sysUserMap[userId].F_Name);
- _$item = null;
- }
- else {
- learun.clientdata.getAsync('user', {
- key: userId,
- callback: function (data, op) {
- var $item = $userList.find('[data-value="' + op.key + '"]');
- $item.attr('title', data.name);
- data.id = op.key;
- $item.find('img').attr('src', getHeadImg(data));
- $item = null;
- }
- });
- }
-
- var _$userItem = $userList.find('.userlist-item');
- if (_$userItem.length == 1) {
- _$userItem.trigger('click');
- }
-
- }
- $('#lr_im_input').val('');
- $('#lr_im_input').select();
- }
- if (!$('.lr-im-bell').hasClass('open')) {
- $('.lr-im-bell .point').show();
- }
- });
-
- // 查看聊天记录
- $('#lr_im_look_msg_btn').on('click', function () {
- //获取聊天用户编号
- var checked = $('#lr_immsg_userlist .userlist-item.active');
- if (!checked) {
- learun.alert.warning("请选择聊天人员!");
- return false;
- }
- var checkedVal = checked.attr('data-value');
- learun.layerForm({
- id: 'LookMsgIndex',
- title: '查看聊天记录-' + $('#lr_im_msglist .lr-im-right .lr-im-touser').text(),
- //url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + imUserId,
- url: top.$.rootUrl + '/LR_IM/IMMsg/Index?userId=' + checkedVal,
- width: 800,
- height: 500,
- maxmin: true,
- btn: null
- });
- });
- }
- };
-
- im.init();
- };
|