var tracywindyCommonUserSelection = function(config){ this.objectType='commonSelection'; //#######可配置项 //选择器种类:user(用户选择)/ dept(部门选择) / deptRole(角色选择)/ group(群组选择) this.type = config.type||'user'; //是否多选 this.isMultiSelect = config.isMultiSelect||false; //是否允许选择空值 this.isAllownChoseEmpty = config.isAllownChoseEmpty||false; //将要赋值id的隐藏域(用逗号(,)隔开) var hiddenInput = config.hiddenInput; //将要赋值显示文本的显示域(用逗号(,)隔开) var displayInput = config.displayInput; //提示性信息 this.displayPromit = config.displayPromit||"人员"; //选择成功后回调 this.choseCallBack = config.choseCallBack; //############# this.draggable = (false == config.draggable)?false:true; this.windowTop = config.windowTop||20; this.params = config.params||{}; this.filterDeptid=config.filterDeptid||"";//根据ID选择主部门下全部子部门 this.queryDeptText=config.queryDeptText||"";//根据部门编号或名称选择指定部门 //########################### var perfixUrl = getRootPath(); this.leftUrl = ""; this.rightUrl = ""; switch(this.type){ case "user":{ this.leftUrl=(perfixUrl+'/table/getDeptWithUserTreeData.action'); this.rightUrl=(perfixUrl+'/table/getUserTreeData.action'); this.displayPromit="人员";break; } case "dept":{ this.leftUrl=(perfixUrl+'/table/getDeptTreeData.action'); this.rightUrl=(perfixUrl+'/table/getDeptSelectedTreeData.action'); this.displayPromit="部门";break;} case "deptRole":{ this.leftUrl=(perfixUrl+'/table/getDeptWithRoleTreeData.action'); this.rightUrl=(perfixUrl+'/table/getRoleTreeData.action'); this.displayPromit="角色";break;} case "group":{ this.leftUrl=(perfixUrl+'/table/getGroupTreeData.action'); this.rightUrl=(perfixUrl+'/table/getGroupSelectedTreeData.action'); this.displayPromit="群组";break;} case "relation":{ this.leftUrl=(perfixUrl+'/table/getRelationTreeData.action'); this.rightUrl=(perfixUrl+'/table/getRelationSelectedTreeData.action'); this.displayPromit="关系";break;} case "definedRelation":{ this.leftUrl=(perfixUrl + '/table/getDefinedRelationTreeData.action'); this.rightUrl = (perfixUrl + '/table/getDefinedRelationSelectedTreeData.action'); this.displayPromit="预定义关系"; break;} case "step":{ if(!this.params["deployId"]){ alert("部署参数deployId不能为空"); return; } this.leftUrl=(perfixUrl+'/table/getStepTreeData.action'); this.rightUrl=(perfixUrl+'/table/getStepSelectedTreeData.action'); this.displayPromit="历史步骤";break; } case "synchronizedWorkflowDesigners":{ this.leftUrl=(perfixUrl+'/jbpm/getSynchronizedWorkflowDesignersTreeData.action'); this.rightUrl=(perfixUrl+'/jbpm/getSynchronizedWorkflowDesignersSelectedTreeData.action'); this.displayPromit="同步流程"; break; } default:{ this.leftUrl=(perfixUrl+'/table/getDeptWithUserTreeData.action'); this.rightUrl=(perfixUrl+'/table/getUserTreeData.action'); this.displayPromit="人员";break;} } if(config.displayPromit){ this.displayPromit = config.displayPromit; } var selectedUserHiddenIdsDom = null; //创建主div if(!(typeof(hiddenInput)=='object')) { selectedUserHiddenIdsDom = document.getElementById(hiddenInput); } else{ selectedUserHiddenIdsDom = hiddenInput; } if(!selectedUserHiddenIdsDom){ //alert("tracywindyTable[CommonUserSelection],没有对应的html元素<"+hiddenInput+">"); return; } this.selectedUserHiddenIdsDom = selectedUserHiddenIdsDom; var selectedUserDisplayRealnameDom = null; //创建主div if(!(typeof(displayInput)=='object')) { selectedUserDisplayRealnameDom = document.getElementById(displayInput); } else{ selectedUserDisplayRealnameDom = displayInput; } if(!selectedUserDisplayRealnameDom){ alert("tracywindyTable[CommonUserSelection],没有对应的html元素<"+displayInput+">"); return; } this.selectedUserDisplayRealnameDom = selectedUserDisplayRealnameDom; //创建window this.id = config.id||GenerateGuid(); var $id = this.id; tracywindyObject[this.id]= this; //创建window结束 this.loadMask = null; this.loadCommonWindow = function(){ if(null == this.loadMask){ this.loadMask = new tracywindyLoadMask(document.body/*"id_detailInfo"+this.id+"WindowContianer"*/,'数据加载中 请稍后...'); } this.loadMask.show(); //判断隐藏值是不是mini渲染的 if($(this.selectedUserHiddenIdsDom).attr("class") && $(this.selectedUserHiddenIdsDom).attr("class").indexOf("mini-queryinput") > -1){ this.initComonUserSelectionDeptTree(mini.get(hiddenInput) ? mini.get(hiddenInput).getValue() : ""); this.initComonUserSelectionUserTree(mini.get(hiddenInput) ? mini.get(hiddenInput).getValue() : ""); }else{ this.initComonUserSelectionDeptTree(this.selectedUserHiddenIdsDom.value); this.initComonUserSelectionUserTree(this.selectedUserHiddenIdsDom.value); } //加载初始化树形 }; this.setParams = function(params){ for(var p in params){ this.params[p] = params[p]; } }; this.reload = function(){ this.loadCommonWindow(); }; this.show = function(){ jQuery(this.selectedUserDisplayRealnameDom).blur(); /*********/ this.loadCommonWindow(); //############# jQuery("#id_detailInfo"+this.id+"WindowContianer").show(); jQuery("#id_detailInfo"+this.id+"WindowContianer").dialog({top:this.windowTop,zIndex:9999999,draggable:this.draggable}); jQuery("#id_detailInfo"+this.id+"WindowContianer").dialog('open'); }; var isDeptTreeLoaded = false; var isUserTreeLoaded = false; this.initComonUserSelectionDeptTree = function(selectedUserIds){ isDeptTreeLoaded = false; this.loadMask.show(); var $loadMask = this.loadMask; var $me = this; jQuery('#id_'+this.id+'_menu_tabs_menu').tree({ url:this.leftUrl, checkbox:true, cascadeCheck:false, onlyLeafCheck:("dept" == this.type) ? false : true, onLoadSuccess:function(){ isDeptTreeLoaded = true; if(isUserTreeLoaded){ $loadMask.hide(); } }, /* onLoadError:function(){ alert('请核实参数后,重新加载!!!'); $loadMask.hide(); },*/ onBeforeLoad:function(node,params){ $loadMask.show(); params['pid'] = node ? node.id : "0"; if($me.filterDeptid !=""){ params['pid'] = node ? node.id : $me.filterDeptid; } if($me.queryDeptText!=""){ params['queryDeptText']=$me.queryDeptText; } if(selectedUserIds){ params['selectedUserIds'] = selectedUserIds; } var queryText = jQuery("#id_"+$id+"_queryWorkflowsTableInput").val(); if(queryText){ params['queryText'] = queryText; } if(!node){ params['init'] = true; } for(var p in $me.params){ params[p] = $me.params[p]; } } }); }; this.initComonUserSelectionUserTree = function(selectedUserIds){ var $me = this; isUserTreeLoaded = false; this.loadMask.show(); var $loadMask = this.loadMask; jQuery('#id_'+this.id+'_menu_main_content_div').tree({ checkbox:true, cascadeCheck:false, onlyLeafCheck:true, onLoadSuccess:function(){ isUserTreeLoaded = true; if(isDeptTreeLoaded){ $loadMask.hide(); } }, url:this.rightUrl, onBeforeLoad:function(node,params){ $loadMask.show(); params['pid'] = node ? node.id : "0"; if(selectedUserIds){ params['selectedUserIds'] = selectedUserIds; } if(!node){ params['init'] = true; } for(var p in $me.params){ params[p] = $me.params[p]; } } }); }; this.addComonUserSelectionUserTree = function (){ var checkedNodes = jQuery('#id_'+this.id+'_menu_tabs_menu').tree('getChecked'); var checkedNodesLen = checkedNodes.length; if(0 == checkedNodesLen){ alert("请从左侧勾选需要添加的"+this.displayPromit+"!"); return; } var selectedNodes = jQuery('#id_'+this.id+'_menu_tabs_menu').tree('options').data; var selectedUserArray = this.getSelectedUserIdsArray(); for(var i=0;i'; windowHTML+='
'; windowHTML+=' '; windowHTML+= ''; windowHTML+= ''; windowHTML+= '
'; windowHTML+='
'+this.displayPromit+'列表 '; windowHTML+= '搜索:'; windowHTML+='
'; windowHTML+= '
'; windowHTML+= '
'; windowHTML+= '
>  >
'; windowHTML+= '
<  <
'; windowHTML+= '
'; windowHTML+= '
  已选择'+this.displayPromit+'
'; windowHTML+= '
'; windowHTML+= '
'; windowHTML+=''; windowHTML+= ''; jQuery(document.body).append(windowHTML); var pageHeight = Math.max(document.documentElement.clientHeight,document.body.clientHeight)-150; var pageWidth = 672; var heightAdd = -2; var widthAdd = -357; jQuery("#id_"+this.id+"_menu_main_content").css("height",(pageHeight+heightAdd)+"px"); jQuery("#id_"+this.id+"_menu_tabs_menu").css("height",(pageHeight+heightAdd-40)+"px"); jQuery("#id_"+this.id+"_menu_main_content_div").css("height",(pageHeight+heightAdd-40)+"px"); jQuery("#id_"+this.id+"_middle_btnContainer").css("width",98+"px"); jQuery("#id_"+this.id+"_middle_btnContainer").css("height",(pageHeight-1)+"px"); jQuery("#id_"+this.id+"_menu_main_oper").css("height",(pageHeight+heightAdd)+"px"); jQuery("#id_"+this.id+"_menu_main_oper").css("width",((pageWidth + widthAdd) )+"px"); jQuery("#id_"+this.id+"_queryWorkflowsTableInput").keypress(function(e){ var code = e.keyCode||e.charCode; if(13 == code){ var currentUserSelectionObj = getTracywindyObject($id); var selectedUserArray = currentUserSelectionObj.getSelectedUserIdsArray(); currentUserSelectionObj.initComonUserSelectionDeptTree(selectedUserArray.join(",")); } }); this.loadCommonWindow(); } };