188 lines
5.2 KiB
JavaScript
188 lines
5.2 KiB
JavaScript
var tree;
|
|
|
|
function $(id){
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
function createTree(){
|
|
tree = new dhtmlXTreeObject("treeBox","100%","100%",0);
|
|
tree.setSkin('dhx_skyblue');
|
|
tree.setImagePath("../images/csh_dhx_skyblue/");
|
|
|
|
var url = "WorkFlowGridSource.aspx?handle=usertree&uid="+newGuid();
|
|
tree.loadJSON(url);
|
|
|
|
tree.attachEvent("onSelect", function(id){
|
|
});
|
|
|
|
// 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 addUser(){
|
|
var userList = $("sel_auditor");
|
|
|
|
|
|
if(userList.options.length > 0){
|
|
alert("不能添加,请将原审核人移除后,再指定新的审核人");
|
|
}else{
|
|
if(tree.getSelectedItemId().trim() == ""){
|
|
alert("没有选择要添加的审核人,请选择");
|
|
}else{
|
|
if(validateType(tree.getSelectedItemId()) > 1){
|
|
alert("只能选择用户添加,请重新选择要添加的审核人");
|
|
}else{
|
|
var auditiorId = getID(tree.getSelectedItemId());
|
|
var auditiorName = tree.getSelectedItemText();
|
|
|
|
var workFlowID = $("h_workflow").value;
|
|
var workFlowStepID = $("h_step").value;
|
|
|
|
var url = "WorkFlowGridSource.aspx?handle=updateauditor&flowid="+workFlowID+"&stepid="+workFlowStepID+"&auditor="+auditiorId+"&uid="+newGuid();
|
|
var loader = dhtmlxAjax.getSync(url);
|
|
var postStatus = loader.xmlDoc.responseText;
|
|
|
|
var status = parseInt(postStatus);
|
|
|
|
if(status == 1){
|
|
var varItem = new Option(auditiorName, auditiorId);
|
|
userList.options.add(varItem);
|
|
}else if(status == -1 || status == -2){
|
|
alert("更新异常");
|
|
}else if(status == -3){
|
|
alert("工作流内存在未完成的审核记录,不能修改工作流审核人信息");
|
|
}
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
function removeUser(){
|
|
var userList = $("sel_auditor");
|
|
|
|
if(userList.options.length > 0){
|
|
if(userList.value.trim() == ""){
|
|
alert("没有要操作的审核人信息");
|
|
}else{
|
|
for(var i=0;i<userList.options.length;i++){
|
|
if(userList.options[i].value == userList.value){
|
|
userList.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,""); }
|
|
|