123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- /**
- * @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;
|