You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
380 lines
11 KiB
JavaScript
380 lines
11 KiB
JavaScript
var user_tree;
|
|
var module_tree;
|
|
var user_module_tree;
|
|
|
|
function $(id){
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
function createUserTree(){
|
|
user_tree = new dhtmlXTreeObject("dvUserTree","100%","100%",0);
|
|
user_tree.setSkin('dhx_skyblue');
|
|
user_tree.setImagePath("../images/csh_dhx_skyblue/");
|
|
|
|
var url = "../WorkFlow/WorkFlowGridSource.aspx?handle=usertree&uid="+newGuid();
|
|
user_tree.loadJSON(url,function(){
|
|
|
|
});
|
|
user_tree.enableCheckBoxes(true);
|
|
|
|
user_tree.attachEvent("onClick", function(id){
|
|
initLoading();
|
|
user_tree.setCheck(id,true);
|
|
createUserModuleTree();
|
|
});
|
|
}
|
|
|
|
function createModuleTree(){
|
|
module_tree = new dhtmlXTreeObject("dvModuleTree","100%","100%",0);
|
|
module_tree.setSkin('dhx_skyblue');
|
|
module_tree.setImagePath("../images/csh_dhx_skyblue/");
|
|
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=modtree&uid="+newGuid();
|
|
module_tree.loadJSON(url,function(){
|
|
finishLoading();
|
|
});
|
|
|
|
module_tree.enableCheckBoxes(true);
|
|
|
|
module_tree.attachEvent("onClick", function(id){
|
|
|
|
});
|
|
|
|
module_tree.attachEvent("onCheck", function(id,state){
|
|
var selectedVal = module_tree.getAllSubItems(id);
|
|
var selectedArg = new Array();
|
|
if(selectedVal.indexOf(",") >= 0){
|
|
selectedArg = selectedVal.split(",");
|
|
}else{
|
|
selectedArg.push(selectedVal);
|
|
}
|
|
|
|
if(module_tree.isItemChecked(id)){
|
|
for(var i=0;i<selectedArg.length;i++){
|
|
module_tree.setCheck(selectedArg[i],true);
|
|
}
|
|
}else{
|
|
for(var i=0;i<selectedArg.length;i++){
|
|
module_tree.setCheck(selectedArg[i],false);
|
|
}
|
|
}
|
|
if(module_tree.getParentId(id) != "0"){
|
|
module_tree.setCheck(module_tree.getParentId(id),true)
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
function createUserModuleTree(){
|
|
user_module_tree = null;
|
|
$("dvUserModuleTree").innerHTML = "";
|
|
user_module_tree = new dhtmlXTreeObject("dvUserModuleTree","100%","100%",0);
|
|
user_module_tree.setSkin('dhx_skyblue');
|
|
user_module_tree.setImagePath("../images/csh_dhx_skyblue/");
|
|
|
|
var selectedUserID = getID(user_tree.getSelectedItemId());
|
|
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=modusertree&seluser="+selectedUserID+"&uid="+newGuid();
|
|
|
|
user_module_tree.enableCheckBoxes(true);
|
|
|
|
user_module_tree.loadJSON(url,function(){
|
|
finishLoading();
|
|
});
|
|
|
|
user_module_tree.attachEvent("onClick", function(id){
|
|
});
|
|
|
|
user_module_tree.attachEvent("onCheck", function(id,state){
|
|
var selectedVal = user_module_tree.getAllSubItems(id);
|
|
var selectedArg = new Array();
|
|
if(selectedVal.indexOf(",") >= 0){
|
|
selectedArg = selectedVal.split(",");
|
|
}else{
|
|
selectedArg.push(selectedVal);
|
|
}
|
|
|
|
if(user_module_tree.isItemChecked(id)){
|
|
for(var i=0;i<selectedArg.length;i++){
|
|
user_module_tree.setCheck(selectedArg[i],true);
|
|
}
|
|
}else{
|
|
for(var i=0;i<selectedArg.length;i++){
|
|
user_module_tree.setCheck(selectedArg[i],false);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function createTree(){
|
|
createUserTree();
|
|
createModuleTree();
|
|
//createUserModuleTree();
|
|
// setTimeout(function(){
|
|
// var id = $("h_moduleid").value;
|
|
//
|
|
// tree.selectItem(id,false);
|
|
// tree.openItem(id);
|
|
// },100);
|
|
|
|
|
|
|
|
// setTimeout(function(){
|
|
// var id = $("h_moduleid").value;
|
|
//
|
|
// module_tree.selectItem(id,false);
|
|
// module_tree.openItem(id);
|
|
// },100);
|
|
}
|
|
|
|
function newGuid(){
|
|
var guid = "";
|
|
for (var i = 1; i <= 32; i++){
|
|
var n = Math.floor(Math.random()*16.0).toString(16);
|
|
guid += n;
|
|
if((i==8)||(i==12)||(i==16)||(i==20))
|
|
guid += "-";
|
|
}
|
|
return guid.toUpperCase();
|
|
}
|
|
|
|
function focusOnTree(){;
|
|
// if(tree != null){
|
|
// if($("h_moduleid").value != ""){
|
|
// var id = $("h_moduleid").value;
|
|
// }
|
|
// }
|
|
}
|
|
|
|
function addUser(){
|
|
var selectedUserID = null;
|
|
var selectedModID = null;
|
|
|
|
var userArg = new Array();
|
|
var modArg = new Array();
|
|
|
|
if(user_tree.getSelectedItemId() != ""){
|
|
selectedUserID = getID(user_tree.getSelectedItemId());
|
|
}
|
|
if(module_tree.getSelectedItemId() != ""){
|
|
selectedModID = module_tree.getSelectedItemId();
|
|
}
|
|
|
|
if(user_tree.getAllChecked().indexOf(",") >= 0){
|
|
userArg = user_tree.getAllChecked().split(",");
|
|
alert("每次只能操作一个用户,请重新选择");
|
|
return;
|
|
}else{
|
|
userArg.push(user_tree.getAllChecked());
|
|
}
|
|
|
|
if(module_tree.getAllChecked().indexOf(",") >= 0){
|
|
modArg = module_tree.getAllChecked().split(",");
|
|
}else{
|
|
modArg.push(module_tree.getAllChecked());
|
|
}
|
|
|
|
if(userArg.length > 0 && modArg.length > 0){
|
|
for(var i=0;i<modArg.length;i++){
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=addmod&selmod="+modArg[i]+"&seluser="+userArg[0]+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
}
|
|
createUserModuleTree();
|
|
}
|
|
}
|
|
|
|
function removeUser(){
|
|
var selectedUserID = null;
|
|
var selectedModID = null;
|
|
|
|
var userArg = new Array();
|
|
var modArg = new Array();
|
|
|
|
if(user_tree.getSelectedItemId() != ""){
|
|
selectedUserID = getID(user_tree.getSelectedItemId());
|
|
}
|
|
if(user_module_tree.getSelectedItemId() != ""){
|
|
selectedModID = user_module_tree.getSelectedItemId();
|
|
}
|
|
|
|
if(user_tree.getAllChecked().indexOf(",") >= 0){
|
|
userArg = user_tree.getAllChecked().split(",");
|
|
alert("每次只能操作一个用户,请重新选择");
|
|
return;
|
|
}else{
|
|
userArg.push(user_tree.getAllChecked());
|
|
}
|
|
|
|
if(user_module_tree.getAllChecked().indexOf(",") >= 0){
|
|
modArg = user_module_tree.getAllChecked().split(",");
|
|
}else{
|
|
modArg.push(getID(user_module_tree.getAllChecked()));
|
|
}
|
|
|
|
if(userArg.length > 0 && modArg.length > 0){
|
|
for(var i=0;i<modArg.length;i++){
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=removemod&selmod="+modArg[i]+"&seluser="+userArg[0]+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
}
|
|
createUserModuleTree();
|
|
}
|
|
}
|
|
|
|
function mouseMoveImg(obj,type){
|
|
var imgUrl = obj.src;
|
|
var urlArg = imgUrl.split("/");
|
|
|
|
if(type == 1){
|
|
if(urlArg[urlArg.length-1] == "edit_left.gif"){
|
|
var newUrl = "";
|
|
for(var i=0;i<urlArg.length;i++){
|
|
if(i == urlArg.length - 1){
|
|
newUrl += "edit_lefthover.gif";
|
|
}else{
|
|
newUrl += urlArg[i]+"/";
|
|
}
|
|
}
|
|
|
|
obj.src = newUrl;
|
|
}else{
|
|
var newUrl = "";
|
|
for(var i=0;i<urlArg.length;i++){
|
|
if(i == urlArg.length - 1){
|
|
newUrl += "edit_left.gif";
|
|
}else{
|
|
newUrl += urlArg[i]+"/";
|
|
}
|
|
}
|
|
|
|
obj.src = newUrl;
|
|
}
|
|
}else{
|
|
if(urlArg[urlArg.length-1] == "edit_right.gif"){
|
|
var newUrl = "";
|
|
for(var i=0;i<urlArg.length;i++){
|
|
if(i == urlArg.length - 1){
|
|
newUrl += "edit_righthover.gif";
|
|
}else{
|
|
newUrl += urlArg[i]+"/";
|
|
}
|
|
}
|
|
|
|
obj.src = newUrl;
|
|
}else{
|
|
var newUrl = "";
|
|
for(var i=0;i<urlArg.length;i++){
|
|
if(i == urlArg.length - 1){
|
|
newUrl += "edit_right.gif";
|
|
}else{
|
|
newUrl += urlArg[i]+"/";
|
|
}
|
|
}
|
|
|
|
obj.src = newUrl;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function validateType(strObj){
|
|
var type = 0;
|
|
var result = strObj.substring(0,strObj.indexOf("#"));
|
|
var typeName = strObj.substring(strObj.indexOf("#")+1,strObj.length);
|
|
|
|
switch(typeName){
|
|
case "user":
|
|
type = 1;
|
|
break;
|
|
case "comp":
|
|
type = 2;
|
|
break;
|
|
case "dept":
|
|
type = 3;
|
|
break;
|
|
}
|
|
|
|
return type;
|
|
}
|
|
|
|
function getID(strObj){
|
|
var uid = strObj.substring(0,strObj.indexOf("#"));
|
|
return uid;
|
|
}
|
|
|
|
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
|
|
|
|
function finishLoading(){
|
|
$("progressBar").style.display = "none";
|
|
}
|
|
|
|
function initLoading(){
|
|
$("progressBar").style.display = "";
|
|
}
|
|
|
|
function searchUser(txtObjName){
|
|
var searchVal = $(txtObjName).value;
|
|
var searchType = $("sel_type").value;
|
|
|
|
var searchUserObj = null;
|
|
var searchDeptObj = null;
|
|
|
|
if(searchType == 1){
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=checkuser&searchuser="+escape(searchVal)+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
|
|
if(postStatus != ""){
|
|
searchUserObj = JSON.parse(postStatus,function(key,value){
|
|
return value;
|
|
});
|
|
}
|
|
|
|
if(user_tree != null){
|
|
for(var i=0;i<searchUserObj.users.length;i++){
|
|
user_tree.selectItem(searchUserObj.users[i].gid+"#user");
|
|
user_tree.setCheck(searchUserObj.users[i].gid+"#user",true);
|
|
}
|
|
}
|
|
}else if(searchType == 2){
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=checkdept&searchdept="+escape(searchVal)+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
alert(postStatus);
|
|
if(postStatus != ""){
|
|
searchDeptObj = JSON.parse(postStatus,function(key,value){
|
|
return value;
|
|
});
|
|
}
|
|
if(user_tree != null){
|
|
for(var i=0;i<searchDeptObj.depts.length;i++){
|
|
user_tree.selectItem(searchDeptObj.depts[i].gid+"#dept");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function searchModule(txtObjName){
|
|
var searchVal = $(txtObjName).value;
|
|
|
|
var searchModuleObj = null;
|
|
|
|
var url = "../Modules/ModuleGridSource.aspx?handle=checkmod&searchmod="+escape(searchVal)+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
|
|
if(postStatus != ""){
|
|
searchModuleObj = JSON.parse(postStatus,function(key,value){
|
|
return value;
|
|
});
|
|
}
|
|
if(module_tree != null){
|
|
for(var i=0;i<searchModuleObj.mods.length;i++){
|
|
module_tree.selectItem(searchModuleObj.mods[i].gid);
|
|
}
|
|
}
|
|
}
|