
var WF={};var cst=2062;var oxe="DefaultF_";WF.LineList=new Array();WF.NodeList=new Array();WF.Draw=null;WF.FlowNodeList=new Array();var IsDesigning=true;var flowId=-1;var maxNodeId=0;var maxStepId=0;var $menuNode=null;var holder={Id:"holder",left:20,top:40,width:2000,height:800,margin_top:50,margin_left:50};var rectMsg={left:180,top:230,width:100,height:50,radius:4};$(document).ready(function(){try{if(!ymr(EntId))cst=EntId;if(!ymr(CtrlPrex))oxe=CtrlPrex}catch(err){}
document.onmouseup=bwe;document.oncontextmenu=function(){return false}});$(window).load(function(){flowId=tzm("flowId");if(!ymr(flowId)&&!isNaN(flowId))flowId=parseInt(flowId,10);else flowId=-1;WF.FlowId=flowId;IsDesigning=tzm("IsDesigning");if(!ymr(IsDesigning)&&!isNaN(IsDesigning))IsDesigning=parseInt(IsDesigning,10);else IsDesigning=-1;if(IsDesigning>0)IsDesigning=true;else{IsDesigning=false;$("#ul_Operate").hide()}
elw(flowId,IsDesigning)});function elw(b,c){var d=$("#"+holder.Id);var e=$("#divNode");d.css({"margin-top":holder.margin_top,"margin-left":holder.margin_left});d.html("");e.html("");WF.$holderObj=d;WF.$nodeHold=e;WF.LineList=new Array();WF.NodeList=new Array();nut(b);if(WF.FlowNodeList==null){art.VLdialog.alert("获取流程节点失败！",function(){},2,"提示");return}
WF.Draw=Raphael(holder.Id,holder.width,holder.height);Raphael.fn.qqh=function(a){return WF.oui(a,this)};WF.NodeList=new Array();var f=new nzy();var g=holder.left;WF.CurLeft=g;WF.$nodeHold.css("position","absolute");WF.NodeColor={StartColor:"#569CD2",EndColor:"#F4A8BD",TaskColor:"#84B939",BorderColor:"#ffffff"};for(var i=0;i<WF.FlowNodeList.length;i++){var h=WF.FlowNodeList[i];WF.MaxIndex=i;h.Index=i;WF.NodeList.push(WF.qjl(h))}
WF.LineList=new Array();for(var i=0;i<WF.FlowNodeList.length;i++){var j=WF.NodeList[i];var h=WF.FlowNodeList[i];WF.bda(j,h)}}
DcxCom.ShowWfDlg=elw;WF.cwh=function(a){for(var i=WF.FlowNodeList.length-1;i>=0;i--){var b=WF.FlowNodeList[i];if(b.NodeId==a){var c=b.Index;if(ymr(c)||isNaN(c)||c<0){WF.MaxIndex++;c=WF.MaxIndex;b.Index=c}
return c}}
return-1};WF.rct=function(a){for(var i=WF.LineList.length-1;i>=0;i--){var b=WF.LineList[i];if(b.obj1.nodeId==a||b.obj2.nodeId){b.arrPath.remove();WF.LineList.splice(i,1)}}
for(var i=WF.NodeList.length-1;i>=0;i--){var b=WF.NodeList[i];if(b.nodeId==a){b.rectObj.remove();b.$txt.remove();WF.NodeList.splice(i,1)}}
var c=','+a+',';for(var i=WF.FlowNodeList.length-1;i>=0;i--){var b=WF.FlowNodeList[i];if(b.NodeId==a){WF.FlowNodeList.splice(i,1)}else{var d=b.PrcsTo;if(!ymr(d)&&d.length>2){if(d[0]!=',')d=','+d;if(d[d.length-1]!=',')d=d+',';d=d.replaceAll(c,',');if(d.length<=2)d='';else d=d.substr(1,d.length-2);b.PrcsTo=d}}}};WF.dhe=function(a){var b=WF.cwh(a.NodeId);WF.rct(a.NodeId);a.Index=b;WF.pyp(a)};WF.pyp=function(a){var b=a.NodeId;for(var i=WF.FlowNodeList.length-1;i>=0;i--){var c=WF.FlowNodeList[i];if(c.NodeId==b){WF.rct(b);break}}
var d=a.Index;if(ymr(d)||isNaN(d)||d<0){a.Index=WF.MaxIndex}
WF.FlowNodeList.push(a);var e=WF.qjl(a);WF.bda(e,a)};WF.bda=function(a,b){var c=null;if(!ymr(b.PrcsTo))c=b.PrcsTo.split(',');if(c!=null&&c.length>0){var d=true;for(var e=0;e<c.length;e++){var f=c[e];if(f!=""&&f!="-1"&&!isNaN(f)&&parseInt(f,10)>0){f=parseInt(f,10);var g=null;for(var h=0;h<WF.NodeList.length;h++){if(WF.NodeList[h].nodeId==f){g=WF.NodeList[h];break}}
if(!ymr(g)){d=false;WF.LineList.push(WF.Draw.qqh({obj1:a.rectObj,obj2:g.rectObj}))}}}
if(d){a.rectObj.attr({fill:WF.NodeColor.EndColor});b.NodeType==3}}};WF.qjl=function(g){strNode=new nzy();if(maxNodeId<g.NodeId)maxNodeId=g.NodeId;if(maxStepId<g.Step)maxStepId=g.Step;if(ymr(g.NodeName))g.NodeName="未命名";strNode.append("<span id=\"fn"+g.NodeId+"\" nodeId=\""+g.NodeId+"\" index=\""+WF.MaxIndex+"\" style=\"cursor:move;padding:0px;position: absolute;white-space: nowrap;font-size:12px;\">"+g.Step+"."+g.NodeName+"</span>\n");var h=WF.NodeColor.TaskColor;if(isNaN(g.NodeType))g.NodeType=-1;if((g.NodeType<1&&WF.MaxIndex==0)||g.NodeType==1)h=WF.NodeColor.StartColor;else if((g.NodeType<1&&WF.MaxIndex==WF.FlowNodeList.length-1)||g.NodeType==3)h=WF.NodeColor.EndColor;var i=holder.top;if(WF.MaxIndex>0)WF.CurLeft+=rectMsg.left;if(WF.MaxIndex%2==1){i=holder.top+230}
if(isNaN(g.Pointx)||g.Pointx<1)g.Pointx=WF.CurLeft;if(isNaN(g.Pointy)||g.Pointy<1)g.Pointy=i;if(isNaN(g.Width)||g.Width<1)g.Width=rectMsg.width;if(isNaN(g.Height)||g.Height<1)g.Height=rectMsg.height;var j=$(strNode.toString());WF.$nodeHold.append(j);if(j.width()+10>g.Width)g.Width=j.width()+20;var k={nodeId:g.NodeId,index:WF.MaxIndex,$txt:j,rectObj:WF.Draw.rect(g.Pointx,g.Pointy,g.Width,g.Height,rectMsg.radius)};k.rectObj.attr({fill:h,stroke:WF.NodeColor.BorderColor,"stroke-width":"1px","fill-opacity":1,cursor:"move",nodeId:g.NodeId});k.rectObj.id=k.nodeId;k.rectObj.drag(WF.Move,WF.Dragger,WF.Up);k.rectObj.dblclick(function(){alert(this.id)});k.rectObj.mousedown(function(){var a=$(event.srcElement);if(ymr($menuNode))$menuNode=$("#div_SetNode");if(event.button==2||event.button==3){var b=a.attr("tagName").toLowerCase();if(b=="rect"||b=="shape"){var c=this.id;var d=this;var e=a.position().left+holder.margin_left;var f=a.position().top+holder.margin_top+40;if(IsDesigning){$menuNode.css({"left":e+"px","top":f+"px"}).attr("nodeId",c).show();WF.CurNodeId=parseInt(c,10)}}}});j.offset({left:g.Pointx+holder.margin_left+(g.Width-j.width())/2,top:g.Pointy+holder.margin_top+(g.Height-j.height())/2});return k};WF.Dragger=function(){this.ox=this.attr("x");this.oy=this.attr("y");this.animate({"fill-opacity":.2},500)};WF.Move=function(a,b){var c={x:this.ox+a,y:this.oy+b};this.attr(c);var d=WF.$nodeHold.children("#fn"+this.id);d.offset({left:this.ox+holder.margin_left+a+(this.attr("width")-d.width())/2,top:this.oy+holder.margin_top+b+(this.attr("height")-d.height())/2});for(var i=WF.LineList.length;i--;){WF.Draw.qqh(WF.LineList[i])}};WF.Up=function(){this.animate({"fill-opacity":1},500)};WF.oui=function(a,b){var c=WF.aai(a.obj1,a.obj2);var d=WF.pqt(c.start.x,c.start.y,c.end.x,c.end.y,4);if(a.arrPath){a.arrPath.attr({path:d})}else{a.arrPath=b.path(d);a.arrPath.attr({stroke:"#666","stroke-width":1,"stroke-linecap":"round"})}
return a}
WF.aai=function(a,b){var c=a.getBBox(),bb2=b.getBBox();var p=[{x:c.x+c.width/2,y:c.y-1},{x:c.x+c.width/2,y:c.y+c.height+1},{x:c.x-1,y:c.y+c.height/2},{x:c.x+c.width+1,y:c.y+c.height/2},{x:bb2.x+bb2.width/2,y:bb2.y-1},{x:bb2.x+bb2.width/2,y:bb2.y+bb2.height+1},{x:bb2.x-1,y:bb2.y+bb2.height/2},{x:bb2.x+bb2.width+1,y:bb2.y+bb2.height/2}];var d={},dis=[];for(var i=0;i<4;i++){for(var j=4;j<8;j++){var e=Math.abs(p[i].x-p[j].x),dy=Math.abs(p[i].y-p[j].y);if((i==j-4)||(((i!=3&&j!=6)||p[i].x<p[j].x)&&((i!=2&&j!=7)||p[i].x>p[j].x)&&((i!=0&&j!=5)||p[i].y>p[j].y)&&((i!=1&&j!=4)||p[i].y<p[j].y))){dis.push(e+dy);d[dis[dis.length-1]]=[i,j]}}}
if(dis.length==0){var f=[0,4]}else{f=d[Math.min.apply(Math,dis)]}
var g={};g.start={};g.end={};g.start.x=p[f[0]].x;g.start.y=p[f[0]].y;g.end.x=p[f[1]].x;g.end.y=p[f[1]].y;return g}
WF.pqt=function(a,b,c,d,e){var f=Raphael.angle(a,b,c,d);var g=Raphael.rad(f-45);var h=Raphael.rad(f+45);var i=c+Math.cos(g)*e;var j=d+Math.sin(g)*e;var k=c+Math.cos(h)*e;var l=d+Math.sin(h)*e;var m=["M",a,b,"L",c,d,"L",i,j,"M",c,d,"L",k,l];return m}
function bwe(){if(ymr($menuNode))$menuNode=$("#div_SetNode");if(event.button!=2&&event.button!=3){$menuNode.hide()}
var a=$(event.srcElement);if(event.button==2||event.button==3){if(a.attr("tagName").toLowerCase()=="span"&&!isNaN(a.attr("nodeId"))){var b=parseInt(a.attr("nodeId"),10);var c=null;for(var i=0;i<WF.NodeList.length;i++){if(b==WF.NodeList[i].nodeId){c=WF.NodeList[i].rectObj;break}}
var d=a.position().left;var e=a.position().top+30;WF.CurNodeId=b;if(IsDesigning)$menuNode.css({"left":(holder.margin_left+d)+"px","top":(e+holder.margin_top)+"px"}).attr("nodeId",b).show()}}
if(event.button!=1){return}}
WF.tum=function(a,b,c){var d=c.iframe.contentWindow;var e=d.mxx(a,b);var f=d.yci(a,b);var g=d.col(a,b);var h=g.$form;var i=d.sme(h,false,a,b,true,a,f);if(ymr(i)||i==false){art.VLdialog.alert("获取表单数据失败。您输入的数据有误。",function(){},4,"提示");return null}
return null};function pyp(){nbp(1)}
function nbp(f){if(ymr(f))f=2;if(ymr(WF.FlowId)||parseInt(flowId,10)<1){art.VLdialog.alert("请指定流程！",function(){},20,"提示");return}
var g="/WorkFlow/EditAttribute.aspx?menuId=3309&flowId="+WF.FlowId+"&nodeId="+WF.CurNodeId+"&mkfv="+WF.CurNodeId+"&entid=2064&optype="+f;if(!ymr($menuNode)&&$menuNode.length>0)$menuNode.hide();art.VLdialog.open(g,{"title":(f==2?"编辑节点":"新建节点"),width:850,height:500,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.3,button:[{name:'保  存',title:"保  存",width:'250px',height:'20px',callback:function(){var c=WF.tum(cst,oxe,this);if(!ymr(c)){var d={"obj":c};var e="/WebServices/WorkFlow/FlowNode.asmx/"+(f==2?"SetNodeAttribute":"pyp");$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:JSON2.stringify(d),dataType:'json',success:function(a){a=hmy(a);if(a.IsOK)art.VLdialog.tips("保存成功！",1);else art.VLdialog.tips("保存失败。原因："+a.ErrorMsg+"",1);if(f==1)WF.pyp(c);else{for(var i=0;i<WF.FlowNodeList.length;i++){var a=WF.FlowNodeList[i];if(a.NodeId==nodeId){a.NodeName=c.NodeName;a.Step=c.Step;a.PrcsTo=c.PrcsTo;WF.dhe(a)}}}
Dcx.RemoveCache(WF.FlowId,1)},error:function(a){var b=JSON2.stringify(a);alert("保存流程节点失败。详情："+b);return false}})}
return false},focus:true},{name:'关闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;return true},focus:false}]},true)}
function zha(){var f="/WorkFlow/EditField.aspx?menuId=3309&flowId="+WF.FlowId+"&nodeId="+WF.CurNodeId+"&mkfv="+WF.CurNodeId+"&entid=2065&optype=2";$menuNode.hide();art.VLdialog.open(f,{"title":"设置可写字段",width:850,height:500,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.3,button:[{name:'保  存',title:"保  存",width:'250px',height:'20px',callback:function(){var c=WF.tum(cst,oxe,this);if(!ymr(c)){var d={"obj":c};var e="/WebServices/WorkFlow/FlowNode.asmx/zha";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:JSON2.stringify(d),dataType:'json',success:function(a){a=hmy(a);if(a.IsOK)art.VLdialog.tips("保存成功！",1);else art.VLdialog.tips("保存失败。原因："+a.ErrorMsg+"",1);for(var i=0;i<WF.FlowNodeList.length;i++){var a=WF.FlowNodeList[i];if(a.NodeId==nodeId){a.PrcsItem=c.PrcsItem;a.PrcsItem2=c.PrcsItem2;break}}
Dcx.RemoveCache(WF.FlowId,1)},error:function(a){var b=JSON2.stringify(a);alert("设置可写字段失败。详情："+b);return false}})}
return false},focus:true},{name:'关闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;return true},focus:false}]},true)}
function omm(){var f="/WorkFlow/EditPower.aspx?menuId=3309&flowId="+WF.FlowId+"&nodeId="+WF.CurNodeId+"&mkfv="+WF.CurNodeId+"&entid=2067&optype=2";$menuNode.hide();art.VLdialog.open(f,{"title":"设置经办人",width:850,height:500,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.3,button:[{name:'保  存',title:"保  存",width:'250px',height:'20px',callback:function(){var c=WF.tum(cst,oxe,this);if(!ymr(c)){var d={"obj":c};var e="/WebServices/WorkFlow/FlowNode.asmx/SetNodePower";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:JSON2.stringify(d),dataType:'json',success:function(a){a=hmy(a);if(a.IsOK)art.VLdialog.tips("保存成功！",1);else art.VLdialog.tips("保存失败。原因："+a.ErrorMsg+"",1);for(var i=0;i<WF.FlowNodeList.length;i++){var a=WF.FlowNodeList[i];if(a.NodeId==nodeId){a.NodeName=c.NodeName;a.PrcsUsers=c.PrcsUsers;a.PrcsDepts=c.PrcsDepts;a.PrcsPositions=c.PrcsPositions;a.PrcsRoles=c.PrcsRoles;a.AllowLastNodeBoss=c.AllowLastNodeBoss;a.AllowWorkCreator=c.AllowWorkCreator;a.PrcsUserNames=c.PrcsUserNames;a.PrcsDeptNames=c.PrcsDeptNames;a.PrcsRoleNames=c.PrcsRoleNames;a.PrcsPositionNames=c.PrcsPositionNames;a.PrcsItem2=c.PrcsItem2;break}}
Dcx.RemoveCache(WF.FlowId,1)},error:function(a){var b=JSON2.stringify(a);alert("设置经办人失败。详情："+b);return false}})}
return false},focus:true},{name:'关闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;return true},focus:false}]},true)}
function adx(f){var g="/WorkFlow/EditTrigger.aspx?menuId=3309&flowId="+WF.FlowId+"&nodeId="+WF.CurNodeId+"&mkfv="+WF.CurNodeId+"&entid=2068&optype=2";$menuNode.hide();art.VLdialog.open(g,{"title":"设置归档与触发器",width:850,height:500,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.3,button:[{name:'保  存',title:"保  存",width:'250px',height:'20px',callback:function(){var c=WF.tum(cst,oxe,this);if(!ymr(c)){var d={"obj":c};var e="/WebServices/WorkFlow/FlowNode.asmx/SetNodePower";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:JSON2.stringify(d),dataType:'json',success:function(a){a=hmy(a);if(a.IsOK)art.VLdialog.tips("保存成功！",1);else art.VLdialog.tips("保存失败。原因："+a.ErrorMsg+"",1);for(var i=0;i<WF.FlowNodeList.length;i++){var a=WF.FlowNodeList[i];if(a.NodeId==nodeId){a.CanPigeonhole=c.CanPigeonhole;a.CanPigeonhole=c.CanPigeonhole;a.TriggerAfter=c.TriggerAfter;a.TriggerBefore=c.TriggerBefore;a.PigeonholedSQL=c.PigeonholedSQL;break}}
Dcx.RemoveCache(WF.FlowId,1)},error:function(a){var b=JSON2.stringify(a);alert("设置归档与触发器失败。详情："+b);return false}})}
return false},focus:true},{name:'关闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;return true},focus:false}]},true)}
function mji(){if(ymr(WF.FlowId)||parseInt(WF.FlowId,10)<1){art.VLdialog.alert("请指定流程！",function(){},20,"提示");return}
var b="/WorkFlow/FormValidator.html?menuId=3132&flowId="+WF.FlowId+"&isFlowNode=1&nodeId="+WF.CurNodeId+"&mkfv="+WF.CurNodeId+"&entid=1848&optype=1";$menuNode.hide();art.VLdialog.open(b,{title:"工作流设计",width:850,height:500,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.3,button:[{name:'保  存',title:"保  存",width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;a.owq(flowId,curNodeId);return false},focus:true},{name:'关闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;return true},focus:false}]},true)}
function yoi(){if(d<1)return;var d=WF.FlowId;var e=WF.CurNodeId;art.VLdialog.confirm('确定要删除本节点吗？',function(){var c="/WebServices/WorkFlow/FlowNode.asmx/yoi";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:c,data:"{flowId:"+d+",nodeId:"+e+"}",dataType:'json',success:function(a){a=hmy(a);if(a){art.VLdialog.tips("删除成功！",1)}
WF.rct(WF.CurNodeId);Dcx.RemoveCache(WF.FlowId,1)},beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("删除流程节点失败失败。详情："+b);return false}})},function(){art.VLdialog.tips('你取消了删除')})}
function nut(c){if(c<1)return;var d="/WebServices/WorkFlow/FlowNode.asmx/nut_noCache";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:d,async:false,data:"{FlowId:"+c+"}",dataType:'json',success:function(a){a=hmy(a);WF.FlowNodeList=a},beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("获取流程节点失败失败。详情："+b);return false}})}
function zze(c){if(ymr(c)){c=tzm("flowId");if(!ymr(c)&&!isNaN(c))c=parseInt(c,10);else c=-1}
if(c<1)return;var d=new Array();for(var i=0;i<WF.NodeList.length;i++){var e=WF.NodeList[i];var f=e.nodeId;var g=e.rectObj;var b=g.getBBox();var h={"NodeId":f,"Pointx":b.x,"Pointy":b.y};d.push(h)}
var j="/WebServices/WorkFlow/FlowRun.asmx/zze";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:j,async:false,data:"{FlowId:"+c+",NodeList:"+JSON2.stringify(d)+"}",dataType:'json',success:function(a){a=hmy(a);art.VLdialog({content:'保存成功',time:0.6});Dcx.RemoveCache(c,1)},beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("获取流程节点失败失败。详情："+b);return false}})}