import{_ as U}from"./Picker-D56_1Pug.js";import{a as v,s as k}from"./index-D7dBOFlH.js";import{F as E,G as C,H as I,i as M,k as B,a as t}from"./element-plus-DckSU5ni.js";import{x as c,s as F,k as _,l as R,y as S,O as r,F as l,C as N,u as s,K as w,z as q}from"./vue-vendor-vBC20LeU.js";import"./index-DwuhEmSW.js";import"./index.vue_vue_type_script_setup_true_lang-C2H7PsW9.js";import"./axios-CG2WSiiR.js";const z={class:"user-setting"},D={class:"flex align-center"},G=c({name:"UserSetting"}),P=c({...G,setup(H){const p=F(),m=v(),e=_({avatar:"",account:"",name:"",password_old:"",password:"",password_confirm:""}),g=_({avatar:[{required:!0,message:"头像不能为空",trigger:["change","blur"]}],name:[{required:!0,message:"请输入名称",trigger:["change","blur"]}]}),u=async()=>{const i=m.userInfo;for(const o in e)e[o]=i[o]},V=async()=>{if(e.password_old||e.password||e.password_confirm){if(!e.password_old){t.error("请输入当前密码");return}if(!e.password){t.error("请输入新的密码");return}if(!e.password_confirm){t.error("请输入确定密码");return}if(e.password_confirm!=e.password){t.error("两次输入的密码不一样");return}}if(e.password_old&&e.password&&e.password_confirm){if(e.password_old.length<6||e.password_old.length>32){t.error("密码长度在6到32之间");return}if(e.password.length<6||e.password.length>32){t.error("密码长度在6到32之间");return}if(e.password_confirm.length<6||e.password_confirm.length>32){t.error("密码长度在6到32之间");return}}await k(e),t.success("设置成功"),m.getUserInfo()},y=async()=>{await p.value?.validate(),V()};return R(()=>{u()}),(i,o)=>{const b=U,d=I,n=M,h=C,f=B,x=E;return q(),S("div",z,[r(x,{class:"!border-none",shadow:"never"},{default:l(()=>[r(h,{ref_key:"formRef",ref:p,model:s(e),rules:s(g),"label-width":"90px"},{default:l(()=>[r(d,{label:"头像：",prop:"avatar"},{default:l(()=>[r(b,{modelValue:s(e).avatar,"onUpdate:modelValue":o[0]||(o[0]=a=>s(e).avatar=a),type:"image",limit:1},null,8,["modelValue"])]),_:1}),r(d,{label:"账号：",prop:"account"},{default:l(()=>[r(n,{style:{width:"400px"},modelValue:s(e).account,"onUpdate:modelValue":o[1]||(o[1]=a=>s(e).account=a),disabled:""},null,8,["modelValue"])]),_:1}),r(d,{label:"名称：",prop:"name"},{default:l(()=>[r(n,{style:{width:"400px"},modelValue:s(e).name,"onUpdate:modelValue":o[2]||(o[2]=a=>s(e).name=a),placeholder:"请输入名称"},null,8,["modelValue"])]),_:1}),r(d,{label:"当前密码：",prop:"password_old"},{default:l(()=>[r(n,{style:{width:"400px"},modelValue:s(e).password_old,"onUpdate:modelValue":o[3]||(o[3]=a=>s(e).password_old=a),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])]),_:1}),r(d,{label:"新的密码：",prop:"password"},{default:l(()=>[r(n,{style:{width:"400px"},modelValue:s(e).password,"onUpdate:modelValue":o[4]||(o[4]=a=>s(e).password=a),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])]),_:1}),r(d,{label:"确定密码：",prop:"password_confirm"},{default:l(()=>[r(n,{style:{width:"400px"},modelValue:s(e).password_confirm,"onUpdate:modelValue":o[5]||(o[5]=a=>s(e).password_confirm=a),modelModifiers:{trim:!0},placeholder:"修改密码时必填, 不修改密码时留空",type:"password","show-password":""},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"]),N("div",D,[r(f,{type:"primary",onClick:y},{default:l(()=>[...o[6]||(o[6]=[w("保存",-1)])]),_:1}),r(f,{onClick:u},{default:l(()=>[...o[7]||(o[7]=[w("重置",-1)])]),_:1})])]),_:1})])}}});export{P as default};
