/** * @class 系统组织机构管理类 * 功能:管理组织机构,该菜单内容只有“系统管理员”才有访问权限 * * @author Jiamd * @since v1.0 2014-08-01 * */ com.sinosoft.lz.system.department.depart = function(){ var _this = this; _this.zTree = null; _this.tab = null; _this.nodes = []; _this.Setting = null; _this.Settinga = null; //示例2相关 var setting = { async: { enable: true, dataType: 'JSON', //返回的JSON数据的名字 dataName: 'treeNodes', contentType: "application/json", url:$.pathname() + '/ws/dept/DeptService/getDepartTree', autoParam: ["id", "name", "name=reName"] }, callback: { onClick:zTreeSelect, onRightClick: OnRightClick } }; /** * 加载数据 */ _this.initTree = function () { _this.zTree = $.fn.zTree.init($("#tree"),setting); _this.tab = new TabView( { containerId :'tab_menu', pageid :'page', cid :'tab1', position :"top" }); }; //鼠标点击右键处理 function OnRightClick(event, treeId, treeNode) { //在节点之外显示一种菜单 if (!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) { _this.zTree.cancelSelectedNode(); showRMenu("root", event.clientX, event.clientY); //在节点里面显示另一种菜单 } else if(treeNode && !treeNode.noR) { _this.zTree.selectNode(treeNode); showRMenu(treeNode.menuType, event.clientX, event.clientY); } } //根据设置弹出不同的右键菜单 function showRMenu(type, x, y) { $("#rMenu ul").show(); if(type == "root") {//树节点外只保留添加和恢复 $("#addUnit").show(); $("#addDept").show(); $("#addPerson").show(); $("#DeleteDept").hide(); $("#DeletePerson").hide(); }else if(type == "nonLeafMenu") {//父节点保留添加和删除 $("#addDept").show(); $("#addPerson").show(); $("#DeleteDept").show(); $("#addUnit").hide(); $("#DeletePerson").hide(); }else if(type == "leafMenu") {//子节点保留选择和删除 $("#DeletePerson").show(); $("#addUnit").hide(); $("#addDept").hide(); $("#addPerson").hide(); $("#DeleteDept").hide(); } $("#rMenu").css({"top":y+"px", "left":x+"px", "visibility":"visible"}); //点击菜单外时隐藏菜单 $("body").bind("mousedown", onBodyMouseDown); } //点击菜单项时隐藏菜单 function hideRMenu() { if ($("#rMenu")) $("#rMenu").css({"visibility": "hidden"}); $("body").unbind("mousedown", onBodyMouseDown); } //点击菜单外时隐藏菜单 function onBodyMouseDown(event){ if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length > 0)) { $("#rMenu").css({"visibility" : "hidden"}); } } //点击树节点 function zTreeSelect(event,treeId,treeNode) { var type = treeNode.type; var url = "DeptEdit.jsp?id="+treeNode.id+"&objectId="+treeNode.objectId; if(type=='person'){ url = "PersonEdit.jsp?id="+treeNode.id+"&objectId="+treeNode.objectId; } tabAddHandler(treeNode.id,treeNode.name,url); } function addDept(){ hideRMenu(); var node = _this.zTree.getSelectedNodes()[0]; tabAddHandler(node.objectId,"新增部门","DeptEdit.jsp?id="+node.id+"&objectId="+node.objectId); } function addPerson(){ hideRMenu(); var node = _this.zTree.getSelectedNodes()[0]; tabAddHandler(node.objectId,"新增用户","PersonEdit.jsp?id="+node.id+"&objectId="+node.objectId); } function deleteDept(){ } function deletePerson(){ } /** * 切换tab */ _this.tabAddHandler = function (mid,mtitle,murl){ _this.tab.close(mid); _this.tab.add( { id :mid, title :mtitle, url :murl, isClosed :true }); _this.tab.activate(mid); }; return { /** * 功能:初始化 */ init : function(){ _this.initTree(); }, addDept : function (){ // alert(12313); hideRMenu(); var node = _this.zTree.getSelectedNodes()[0]; _this.tabAddHandler(node.objectId,"新增部门","DeptEdit.jsp?id="+node.id+"&objectId="+node.objectId); } }; }(); $(function(){ com.sinosoft.lz.system.department.depart.init(); }); $.depart = com.sinosoft.lz.system.department.depart;