
var xjr=null;var jpc=null;$(document).ready(function(){xjr=$("#div_FormHtml_DefaultF_1848").find("ul:first");$("#btnNew").linkbutton({plain:false});$vld_btnUpdate=$("#btnUpdate");$vld_btnUpdate.linkbutton({plain:false});$("#LinkButton2").linkbutton({plain:false});$("#but_delete").linkbutton({plain:false})});$(window).load(function(){vvc=$("#d1848_FldId");isFlowNode=tzm("isFlowNode");if(!ymr(isFlowNode)&&!isNaN(isFlowNode)){isFlowNode=parseInt(isFlowNode,10);if(isFlowNode==1)isFlowNode=true;else isFlowNode=false}else isFlowNode=false;if(isFlowNode){wF_FlowId=tzm("FlowId");if(!ymr(wF_FlowId)&&!isNaN(wF_FlowId))wF_FlowId=parseInt(wF_FlowId,10);else wF_FlowId=-1;$("#div_DefaultF_1848").css("margin-left","50px");wF_NodeId=tzm("NodeId");if(!ymr(wF_NodeId)&&!isNaN(wF_NodeId))wF_NodeId=parseInt(wF_NodeId,10);else wF_NodeId=-1;nlu(wF_FlowId,wF_NodeId);var a=vvc.parent();var b=0;while(!ymr(a)&&a.length>0&&b<20){if(!ymr(a.attr("areaid"))&&!isNaN(a.attr("areaid")))break;a=a.parent();b++}
a.show();var c=$vld_btnUpdate.html();c=c.replace("保","暂");$vld_btnUpdate.html(c);vvc.change(function(){wry=parseInt($(this).val(),10);bym()})}
jwj=zcn();bym()});function nlu(d,e){if(d<1)return;var f="/WebServices/WorkFlow/FlowRun.asmx/GetFlowFieldListAndEntId";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:f,async:false,data:"{FlowId:"+d+",NodeId:"+e+"}",dataType:'json',success:function(a){a=hmy(a);var b=new nzy();if(!ymr(a)){for(var i=0;i<a.length;i++){var c=a[i];if(i==0){han=parseInt(c.Value,10);vcv=c.Text;if(!ymr(vcv))vcv=JSON2.parse(vcv)}else{b.append("<option value=\""+c.Value+"\">"+c.Text+"</option>")}}}else art.VLdialog.alert("您还没为本流程绑定应用，无法设置节点条件。");vvc.empty().append(b.toString());wry=parseInt(vvc.val(),10)},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 crf(c,d){if(c<1)return;var e="/WebServices/WorkFlow/FlowRun.asmx/crf";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,async:false,data:"{FlowId:"+c+",NodeId:"+d+"}",dataType:'json',success:function(a){a=hmy(a);vcv=a;if(!ymr(vcv))vcv=JSON2.parse(vcv);else vcv=null},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 owq(c,d){if(c<1)return;var e="/WebServices/WorkFlow/FlowRun.asmx/owq";var f={"strVld":null,"FlowId":c,"NodeId":d};if(!ymr(jwj))f.strVld=JSON2.stringify(jwj);$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,async:false,data:JSON2.stringify(f),dataType:'json',success:function(a){a=hmy(a);if(a)art.VLdialog({content:'保存成功',time:0.6});else art.VLdialog({content:'保存失败',time:121.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}})}
function acb(b){var c=null;if(!ymr(b)){c=b;$("#d1848_VlType").find("input[value="+b+"]").attr("checked",true)}else{c=$("#d1848_VlType").find("input").filter(":checked").attr("value")}
if(!ymr(c))c=parseInt(c,10);else c=1;if(ymr(xjr))xjr=$("#div_FormHtml_DefaultF_1848").find("ul:first");xjr.children().each(function(){var a=$(this);if(a.attr("AreaId")=="16"||a.attr("AreaId")=="6"||a.attr("AreaId")=="7"||a.attr("AreaId")=="9"||a.attr("AreaId")=="11"||a.attr("AreaId")=="13"||a.attr("AreaId")=="22")a.hide()});if(c==2){xjr.children().each(function(){var a=$(this);if(a.attr("AreaId")=="7"||a.attr("AreaId")=="9")a.show()})}else if(c==3){xjr.children().each(function(){var a=$(this);if(a.attr("AreaId")=="11"||a.attr("AreaId")=="13")a.show()})}else if(c==4){xjr.children().each(function(){var a=$(this);if(a.attr("AreaId")=="6"||a.attr("AreaId")=="16")a.show()})}else if(c==5){xjr.children().each(function(){var a=$(this);if(a.attr("AreaId")=="22")a.show()})}}
function msb(a){var v=$(a).val();var b=v.split("{&*&}");if(b.length>0)$("#d1848_ErrorMsg").val(b[0]);if(b.length>1)$("#d1848_RExp").val(b[1])}
function bym(){var a=-1;var b=-1;var c=null;if(!isFlowNode){if(ymr(window.top.pec))return;c=window.top.bkj;if(ymr(c)||c.length<1){art.VLdialog({content:'请您先点击字段，再设置它的验证。',time:1.8});return}
if(ymr(xjr)||xjr.length<1){xjr=$("#div_FormHtml_DefaultF_1848").find("ul:first")}
a=parseInt(c.attr("FldId"),10);b=parseInt(c.attr("EntId"),10)}else{a=wry;b=han}
var d=xqn();var e=xjr.find("#d1848_Field1757");e.html("");if(ymr(d)){e.prepend("<option value='-1'>您正在新建...</option>");zjj();return}
for(var i=0;i<d.Vld.length;i++){var f=d.Vld[i];e.append("<option value='"+f.Id+"' EntId="+b+" FldId="+a+">["+lpu(f.vlId)+"]     "+f.err+"</option>")}
if(d.Vld.length<1){e.prepend("<option value='-1'>您正在新建...</option>");zjj()}else{e.get(0).selectedIndex=0;zjj(d.Vld[0])}}
function ney(){if(ymr(jwj))return;var a=xjr.find("#d1848_Field1757");var b=a.find("option:selected");var c=b.val();if(ymr(c)||c=="-1")return;c=parseInt(c,10);var d=kpr(c);if(ymr(d))return;var e=null;if(d.json.Vld.length>d.index){e=d.json.Vld[d.index]}else e=lhy();zjj(e)}
function zjj(a){if(ymr(a))a=lhy();xjr.find("#d1848_Condition").val(a.cdn);xjr.find("#d1848_ErrorMsg").val(a.err);xjr.find("#d1848_OkMsg").val(a.ok);xjr.find("#d1848_WarnMsg").val(a.warn);xjr.find("#d1848_VlType").find("input[value="+a.vlId+"]").attr("checked",true);if(a.vlId==1){}else if(a.vlId==2){xjr.find("#d1848_CompOpT").val(a.compT);xjr.find("#d1848_CompV").val(a.compV)}else if(a.vlId==3){xjr.find("#d1848_MinValue").val(a.minV);xjr.find("#d1848_MaxValue").val(a.maxV)}else if(a.vlId==4){xjr.find("#d1848_RExp").val(a.rExp)}else if(a.vlId==5){if(!ymr(a.ovt))xjr.find("#d1848_OnlyValueType").find("input[value="+a.ovt+"]").attr("checked",true)}else if(a.vlId==6){xjr.find("#d1848_FunctionName").val(a.jsFun)}
acb(a.vlId)}
function lpu(a){if(a==1)return"非空";else if(a==2)return"值比较";else if(a==3)return"值范围";else if(a==4)return"正则表达式";else if(a==5)return"值唯一";else if(a==6)return"执行Js函数来验证";else return""}
function aff(){var a=xjr.find("#d1848_Field1757");a.find("option[value='-1']").remove();a.prepend("<option value='-1'>您正在新建...</option>");a.get(0).selectedIndex=0;acb(1);zjj(null)}
function mlq(){if(ymr(jwj)){jwj={MaxVlId:1,Ent:[]}}
var a=-1;var b=-1;var c=null;if(!isFlowNode){c=window.top.bkj;if(ymr(c)||c.length<1)return;a=parseInt(c.attr("FldId"),10);b=parseInt(c.attr("EntId"),10)}else{a=wry;b=han}
var d=xqn();var e=xjr.find("#d1848_Field1757");var f=e.find("option:selected");var g=f.val();var h=false;if(ymr(g)||g=="-1")h=true;if(h){var j=lhy();d.Vld.push(j);yqb(j,c,a,b);e.find("option[value='-1']").remove();e.append("<option value='"+j.Id+"' EntId="+b+" FldId="+a+">["+lpu(j.vlId)+"]     "+j.err+"</option>");e.get(0).selectedIndex=e.children().length-1;art.VLdialog({content:'添加成功',time:0.6})}else{g=parseInt(g,10);for(var i=0;i<d.Vld.length;i++){if(d.Vld[i].Id==g){var j=d.Vld[i];yqb(j,c,a,b);e.find("option:selected").text("["+lpu(j.vlId)+"]     "+j.err);art.VLdialog({content:'保存成功',time:0.6});break}}}}
function yqb(a,b,c,d){a.cdn=xjr.find("#d1848_Condition").val();a.err=xjr.find("#d1848_ErrorMsg").val();a.ok=xjr.find("#d1848_OkMsg").val();a.warn=xjr.find("#d1848_WarnMsg").val();a.vlId=parseInt(xjr.find("#d1848_VlType").find("input:checked").attr("value"),10);a.compT=1;a.compV="";a.minV="";a.maxV="";a.rExp="";a.jsFun="";if(a.vlId==1){}else if(a.vlId==2){var e=xjr.find("#d1848_CompOpT").val();if(!ymr(e))a.compT=parseInt(e,10);else a.compT=1;a.compV=xjr.find("#d1848_CompV").val()}else if(a.vlId==3){a.minV=xjr.find("#d1848_MinValue").val();a.maxV=xjr.find("#d1848_MaxValue").val()}else if(a.vlId==4){a.rExp=xjr.find("#d1848_RExp").val()}else if(a.vlId==5){a.ovt=parseInt(xjr.find("#d1848_OnlyValueType").find("input:checked").attr("value"),10)}else if(a.vlId==6){a.jsFun=xjr.find("#d1848_FunctionName").val()}
if(!isFlowNode){hhv(jwj);var f=window.top.gjy(d,c);f.IsValidate=true;if(f.OperateType==0)f.OperateType=3;var g=b;var h=g.next();var i=false;while(!ymr(h)&&h.length>0){if(h.attr("iserr")=="1"){i=true;break}else{g=h;h=h.next()}}
if(!i){g.after("<div iserr=1 class=\"form-vld\"></div>")}}}
function kwc(){if(!confirm('确定要删除当前验证吗?'))return;var a=xjr.find("#d1848_Field1757");var b=a.find("option:selected");var c=parseInt(b.val(),10);if(ymr(c)||c==-1){art.VLdialog({content:'您正在新建此验证',time:1});return}
var d=kpr(c);if(ymr(d)){art.VLdialog({content:'此验证已经被删除',time:1});return}
if(d.json.Vld.length>d.index){d.json.Vld.splice(d.index,1);b.remove()}
hhv(jwj);art.VLdialog({content:'成功删除',time:0.7});ney()}