
var User={"IsAdd":true,"IsChangePwd":false};var cst=2054;var oxe="DefaultF_";var lsf=null;var ybi=null;var znu=new Array();$(window).load(function(){var a=tzm("optype");if(!ymr(a)&&!isNaN(a))a=parseInt(a,10);else a=-1;if(a==2)User.IsAdd=false;if(!User.IsAdd){$("#d2054_PWD").val("123456");$("#d2054_PWD2").val("123456");$("[areaid=25]").hide();$("[areaid=33]").hide();$("[areaid=41]").show();$("#d2054_UserName").attr("readonly","readonly")}
ybi=mmj();$("#btn_updateUserMsg").unbind("click").bind("click",function(){if(User.IsAdd)xgj();else pjx()});$("li[areaid=41]").find("a").removeAttr("click").unbind("click").bind("click",function(){lby(this)})});function lby(a){$("#d2054_PWD").val("");$("#d2054_PWD2").val("");$("[areaid=25]").show();$("[areaid=33]").show();$("[areaid=41]").hide();User.IsChangePwd=true}
function xgj(){var d=yci(cst,oxe);var e=null;var f=col(cst,oxe);e=f.$form;if(e==null){art.VLdialog.alert("获取表单的HTML对象失败。请确认代码正确。",function(){},433,"提示");return}
var g=sme(e,false,cst,oxe,true,cst,d,true);if(ymr(g)||g==false){art.VLdialog.alert("获取表单数据失败。请确认输入是否正确。",function(){},433,"提示");return}
for(var i=0;i<znu.length;i++){if(znu[i].UserName==g.UserName){var h=$("#d"+cst+"_UserName");h.val("");h.blur();art.VLdialog.alert("当前用户已存在，请重新输入。",function(){},644,"提示");return}else if(znu[i].Email==g.Email){var h=$("#d"+cst+"_Email");h.val("");h.blur();h.change();art.VLdialog.alert("Email已存在，请重新输入。",function(){},664,"提示");return}}
var j="/WebServices/System/User.asmx/xgj";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:j,data:"{model:"+JSON2.stringify(g)+"}",dataType:'json',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},success:function(a){a=hmy(a);if(a.IsOK){art.VLdialog.tips('提交成功！您可以继续新建用户！',1);var b=parseInt(g.CurSystemId,10);var c={"UserName":g.UserName,"Email":g.Email};znu.push(c);lwg(cst,oxe,ybi,null,false);pet(cst,oxe,1)}else art.VLdialog.alert("提交失败。原因："+a.ErrorMsg,function(){},320,"提示")}})}
function pjx(){var c=yci(cst,oxe);var d=null;var e=col(cst,oxe);d=e.$form;if(d==null){art.VLdialog.alert("获取表单的HTML对象失败。请确认代码正确。",function(){},4,"提示");return}
var f=sme(d,false,cst,oxe,true,cst,c,true);if(ymr(f)||f==false){art.VLdialog.alert("获取表单数据失败。请确认输入是否正确。",function(){},4,"提示");return}
f.UserId=parseInt(DcxForm.GetMKeyValue(cst,oxe),10);var g="/WebServices/System/User.asmx/SetUserMsg";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:g,data:"{model:"+JSON2.stringify(f)+"}",dataType:'json',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},success:function(a){a=hmy(a);if(a)art.VLdialog.tips('提交成功！',1);else art.VLdialog.alert("保存失败。",function(){},8,"提示")}})}
function mmj(){var a=yci(cst,oxe);var b=null;var c=col(cst,oxe);b=c.$form;if(b==null){art.VLdialog.alert("获取表单的HTML对象失败。请确认代码正确。",function(){},4,"提示");return null}
return sme(b,false,cst,oxe,false,cst,a,true)}
function rmb(){var e="/WebServices/DataSource/DataSource.asmx/rmb";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:"{}",dataType:'json',success:function(a){a=hmy(a);if(!ymr(a)&&a.length>0){var b=$("#d"+cst+"_PositionId");var c="";var d=new nzy();for(var i=0;i<a.length;i++){d.append("<option value=\""+a[i].PositionId+"\">"+a[i].PositionName+"</option>\n")}
b.html(d.toString());if(!ymr(ybi)&&!ymr(b.val()))ybi.PositionId=parseInt(b.val(),10)}},beforeSend:function(a){},complete:function(a,b){},error:function(a){}})}