var $url="/settings/usersLayerProfile",data=utils.init({userId:utils.getQueryInt("userId"),uploadUrl:null,uploadFileList:[],form:null,groups:null,styles:null}),methods={apiGet:function(){var t=this;$api.get($url,{params:{userId:this.userId}}).then(function(s){var i=s.data;if(t.form=_.assign({},i.user),t.groups=i.groups,t.styles=i.styles,0===this.userId)for(var r=0;r<i.styles.length;r++){var a=i.styles[r];t.form[utils.toCamelCase(a.attributeName)]=a.defaultValue}t.form.avatarUrl&&t.uploadFileList.push({name:"avatar",url:t.form.avatarUrl})}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,this.form).then(function(s){utils.success(t.form.id>0?"用户编辑成功！":"用户添加成功！"),utils.closeLayer(!0)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},validatePass:function(t,s,i){""===s?i(new Error("请再次输入密码")):s!==this.form.password?i(new Error("两次输入密码不一致!")):i()},btnSubmitClick:function(){var t=this;this.$refs.form.validate(function(s){s&&t.apiSubmit()})},uploadBefore:t=>/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.webp)$/i.exec(t.name)?!!(t.size/1024/1024<10)||(utils.error("头像图片大小不能超过 10MB!"),!1):(utils.error("头像只能是图片格式，请选择有效的文件上传!"),!1),uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(t,s,i){this.form.avatarUrl=t.value,utils.loading(this,!1),i.length>1&&i.splice(0,1)},uploadError:function(t){utils.loading(this,!1);var s=JSON.parse(t.message);utils.error(s.message)},uploadRemove(t){this.form.avatarUrl=null},btnCancelClick:function(){utils.closeLayer()}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.uploadUrl=$apiUrl+$url+"/actions/upload?userId="+this.userId,this.apiGet()}});