| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- var menu;
- var groupMenu;
- var currentMenu;
- var actionNode;
- var olineObj, orgObj, groupObj;
- $(function() {
- initTab();
- loadMenu();
- loadGroupMenu();
- initTabTree();
- });
- function initTab(){
- try{
- var h = $(".portlet_content", window.parent.document).height();
- $("#tab1").height(h - 10);
- $("#tab2").height(h - 10);
- $("#tab1 .org_tree").height(h - 40);
- $(".org_tree").scroll(function(){
- menu.hide();
- groupMenu.hide();
- });
- }catch(e){}
- }
- function initTabTree(){
- try{
- olineObj = onlineTree();
- $("#tab1").ligerTab({
- contextmenu : false,
- onAfterSelectTabItem : function(tabid) {
- if (tabid == "tabitem1" && !olineObj) {
- olineObj = onlineTree();
- }
- if (tabid == "tabitem2" && !orgObj) {
- orgObj = orgTree();
- }
- if (tabid == "tabitem3" && !groupObj) {
- groupObj = groupTree();
- }
- }
- });
- }catch(e){}
- }
- function loadMenu() {
- try{
- var param = {'type':"menu"};
- sendAsyncAjax(param, "loadOrgIndex.do", "json", processMenu);
- }catch(e){}
- }
- function processMenu(data) {
- var userMenu = [];
- try{
- if(data==null||!data)return;
- for(var i = 0; i < data.length; i++) {
- userMenu.push({
- id:data[i].clickName,
- text : data[i].menuText,
- action : data[i].menuAction,
- click : eval(data[i].clickName)
- });
- }
- menu = $.ligerMenu({
- top : 100,
- left : 100,
- width : 120,
- items : userMenu
- });
- currentMenu = $.ligerMenu({
- top : 100,
- left : 100,
- width : 120,
- items : userMenu
- });
- currentMenu.removeItem('sendIMEvent');
- }catch(e){
-
- }
- }
- function loadGroupMenu() {
- try{
- var param = {'type':"all"};
- sendAsyncAjax(param, "loadOrgIndex.do", "json", processAllMenu);
- }catch(e){}
- }
- function processAllMenu(data) {
- var userMenu = [];
- for ( var i = 0; i < data.length; i++) {
- userMenu.push({
- text : data[i].menuText,
- action : data[i].menuAction,
- click : eval(data[i].clickName)
- });
- }
- groupMenu = $.ligerMenu({
- top : 100,
- left : 100,
- width : 120,
- items : userMenu
- });
- }
- function onlineTree() {
- try{
- $("#onlineList").empty();
- var m = "";
- m = $("#onlineList").ligerTree({
- url : "loadOnlineTree.do?type=user&t=" + new Date().getTime(),
- checkbox : false,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- slide : false,
- nodeWidth : 120,
- attribute : [ 'id', 'url', 'level' ],
- onContextmenu : function(node, e) {
- if(m){
- $("#onlineList").find(".l-selected").removeClass("l-selected");
- m.selectNode(node.target);
- }
- loadContextMenu(node, e);
- return false;
- },
- onBeforeAppend:function(parentNode, newdata){
- $("#onlineList").empty();
- },
- onSuccess : function() {
- filterFolder(5);
- }
- });
- return m;
- }catch(e){}
- }
- function orgTree() {
- $("#orgList").empty();
- var m = "";
- m = $("#orgList").ligerTree({
- url : "orgTree.do?type=user&t=" + new Date().getTime(),
- checkbox : false,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- slide : false,
- nodeWidth : 120,
- attribute : [ 'id', 'url', 'level', 'isexpand' ],
- onContextmenu : function(node, e) {
- if(m){
- $("#orgList").find(".l-selected").removeClass("l-selected");
- m.selectNode(node.target);
- }
- loadContextMenu(node,e);
- return false;
- }
- });
- return m;
- }
- function groupTree() {
- $("#groupList").empty();
- var m = "";
- m = $("#groupList").ligerTree({
- url : "loadGroupTree.do?type=user&t=" + new Date().getTime(),
- checkbox : false,
- childIcon : 'folder',
- idFieldName : 'id',
- parentIDFieldName : 'pid',
- slide : false,
- nodeWidth : 120,
- attribute : [ 'id', 'url', 'level' ],
- onContextmenu : function(node, e) {
- if(m){
- $("#groupList").find(".l-selected").removeClass("l-selected");
- m.selectNode(node.target);
- }
- loadContextMenu(node, e);
- return false;
- }
- });
- return m;
- }
- function loadContextMenu(node,e){
- var childNode = node.data.children;
- var treeH = $(".org_tree").height();
- var top = e.pageY;
- actionNode = node;
- var tempMenu;
- if (!childNode) {
- var currentUserId = $("#currentUserId").val();
- if("-"+currentUserId == node.data.id){
- tempMenu = currentMenu;
- menu.hide();
- }else{
- tempMenu = menu;
- currentMenu.hide();
- }
- var mh = tempMenu.getItemCount()*23;
- if(top>treeH-mh){
- top = e.pageY-mh;
- }
- tempMenu.show({
- top : top,
- left : e.pageX
- });
- groupMenu.hide();
- } else {
- var gmh = groupMenu.getItemCount()*23;
- if(top>treeH-gmh){
- top = e.pageY-gmh;
- }
- groupMenu.show({
- top : top,
- left : e.pageX
- });
- currentMenu.hide();
- menu.hide();
- }
- }
- function filterFolder(n) {
- while (n > 1) {
- $("li[outlinelevel=" + n + "]").each(function() {
- var itemid = $(this).attr("id");
- if (itemid.indexOf("-") == -1) {
- var children = $(".l-children li", this);
- if (children.length == 0) {
- $(this).remove();
- }
- }
- });
- n--;
- }
- $("ul#onlineList").find(".l-expandable-close").click();
- }
- var imDialog;
- function viewInfoEvent(item, i) {
- var nodeId = actionNode.data.id;
- if (nodeId>0) {
- openTopDialog({
- title : "部门信息",
- url : "viewUser.do?type=group&nodeId=" + nodeId,
- width : 500,
- height : 200
- });
- } else {
- openTopDialog({
- title : "用户信息",
- url : "viewUser.do?type=user&nodeId=" + nodeId,
- width : 500,
- height : 500
- });
- }
- }
- function sendEvent(item, type) {
- var url = "";
- var nodeId = actionNode.data.id;
- if (nodeId>0) {
- url = "sendEvent.do?type=" + type + "&sendType=group&nodeId=" + nodeId;
- } else {
- url = "sendEvent.do?type=" + type + "&sendType=user&nodeId=" + nodeId;
- }
- addTab(item.action, item.text, url, true, false);
- }
- function sendMsgEvent(item, i) {
- sendEvent(item, "sendMsg");
- }
- function sendEmailEvent(item, i) {
- sendEvent(item, "sendEmail");
- }
- function sendSmsEvent(item, i) {
- sendEvent(item, "sendSms");
- }
- function sendIMEvent(item, i) {
- var nodeId = actionNode.data.id;
- var t = actionNode.data.text;
- var currentUserId = $("#currentUserId").val();
- if("-"+currentUserId == nodeId){
- addError("不能和自己对话");
- return;
- }
- var task = getTask(nodeId);
- if(task.length>0){
- $(task).click();
- nodeId = 1;
- }
- if (nodeId<0) {
- imDialog = openTopDialog({onClose:closeTopDialog,id:nodeId,height: 500, url: 'openMI.do?type=open&sendUserName='+t+'&toUser='+nodeId, width: 550, showMax: true, showMin: true, isResize: true,title:t,isHidden:false});
- }
- }
- function openIMList(e,userId,t){
- $(e).parent().remove();
- var l = $("#msgBoxDialog").find("li");
- if(l.length==0){
- imMsgBoxDialog.close();
- window.top.document.title=$("#topTitle").val();
- clearTimeout(titleTipTime);
- clearTimeout(blinkTime);
- $("#imCount").html(0);
- im_imgCount.style.visibility = "visible";
- }
- openTopDialog({onClose:closeTopDialog,id:"-"+userId,height: 500, url: 'openMI.do?type=open&toUser='+userId, width: 550, showMax: true, showMin: true, isResize: true,title:t,isHidden:false});
- }
- function getTask(nodeId){
- return $("#task_"+nodeId,window.top.document);
- }
- function closeTopDialog(dialog,options){
- var iframeId = $(dialog.jiframe).attr("id");
- parent.parent.document.getElementById(iframeId).contentWindow.stopTime();
- return true;
- }
- function openTab(i){
- if(i=='1'){
- loadUnlineMsg();
- }
- if(i=='2'){
- addTab("toRecieveMsgList.do","我的消息","toRecieveMsgList.do", true, false);
- }
- if(i=='3'){
- addTab("receiveMailAction.do?task=list","我的邮件","receiveMailAction.do?task=list", true, false);
- }
- }
- function loadUnlineMsg(){
- var imCount = parseInt($("#imCount").html(),10);
- if(imCount>0){
- var param = {'type':'unlineMsg'};
- sendAsyncAjax(param,"openMI.do","json",loadUnlineMsgProcess);
- }
- }
- var imMsgBoxDialog;
- function loadUnlineMsgProcess(data){
- var html = "";
- if(data==null||!data)return;
- for(var i=0;i<data.length;i++){
- var im = data[i];
- var isExist = $("#"+im.sendUser);
- if(isExist.length==0){
- html += "<li style='height:15px;padding-top:3px;' id='"+im.sendUser+"'><a href='#' onclick=openIMList(this,'"+im.sendUser+"','"+im.sendUserName+"')>"+im.sendUserName+"</a></li>";
- }
- }
- var ct = "<ul id='msgBoxDialog'>"+html+"</ul>";
- imMsgBoxDialog = $.ligerDialog.open({ height: 200, content:ct, width: 150,isHidden:false});
- }
|