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.
DS7/DSWeb/js/CompanyTree.js

174 lines
4.7 KiB
JavaScript

2 years ago
var tree_company;
function $(id){
return document.getElementById(id);
}
function createTree(){
tree_company = new dhtmlXTreeObject("treeBox","100%","100%",0);
tree_company.setSkin('dhx_skyblue');
tree_company.setImagePath("../images/csh_dhx_skyblue/");
var url = "WorkFlowGridSource.aspx?handle=companytree&uid="+newGuid();
tree_company.loadJSON(url);
tree_company.attachEvent("onSelect", function(id){
});
tree_company.enableCheckBoxes(true);
// setTimeout(function(){
// var id = $("h_moduleid").value;
//
// tree.selectItem(id,false);
// 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 assignTo(){
var compArg = new Array();
var selCompanyObj = $("sel_company");
if(tree_company != null){
if(tree_company.getAllChecked().indexOf(",") >= 0){
//modArg = tree.getAllChecked().split(",");
alert("指定错误,只能指定一个模块作为父模块");
return;
}else{
compArg.push(tree_company.getAllChecked());
}
if(selCompanyObj.options.length < 1){
var varItem = new Option(tree_company.getItemText(compArg[0]), compArg[0]);
selCompanyObj.options.add(varItem);
window.opener.document.getElementById("txt_company").value = tree_company.getItemText(compArg[0]);
window.opener.document.getElementById("h_compid").value = compArg[0];
//var parentId = window.opener.document.getElementById("h_parentid").value;
}else{
alert("已指定父模块信息,不能重复添加,请先移除后再添加");
return;
}
}
}
function removeAssign(){
var compList = $("sel_company");
if(compList.options.length > 0){
if(compList.value.trim() == ""){
alert("没有要操作的审核人信息");
}else{
for(var i=0;i<compList.options.length;i++){
if(compList.options[i].value == compList.value){
compList.options.remove(i);
break;
}
}
}
}else{
alert("没有要操作的审核人信息");
return;
}
}
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,""); }