import{B as b,a8 as v,a as V,I as m,C as y,D as C,H as n,P as l,G as S,a7 as I,u as r,V as f,U as p}from"./vue-DweYBrEc.js";import{x as N,b as R,G as $,ae as x,_ as L}from"./index-fNs72j9w.js";import{b as u}from"./validate-CEOscgyN.js";import{F as i}from"./index-BlEwok4a.js";import"./index-CgMrKa77.js";import"./index-DMA3A9_B.js";const U={class:"user-views"},B={class:"change-password"},k=b({__name:"changePassword",setup(q){const{t:s}=N.useI18n(),P=R(),w=v("formRef"),e=V({formSubmitLoading:!1,form:{oldPassword:"",newPassword:"",confirmPassword:""},rules:{oldPassword:[u({name:"required",title:s("user.account.changePassword.Old password")})],newPassword:[u({name:"required",title:s("user.account.changePassword.New password")}),u({name:"password"})],confirmPassword:[u({name:"required",title:s("user.account.changePassword.Confirm new password")}),u({name:"password"}),{validator:(d,o,a)=>{(e.form.newPassword||e.form.confirmPassword)&&(e.form.newPassword==e.form.confirmPassword?a():a(new Error(s("user.account.changePassword.The duplicate password does not match the new password")))),a()},trigger:"blur"}]}}),c=()=>{var d;(d=w.value)==null||d.validate(o=>{o&&(e.formSubmitLoading=!0,x(e.form).then(a=>{e.formSubmitLoading=!1,a.code==1&&P.logout()}).catch(()=>{e.formSubmitLoading=!1}))})};return(d,o)=>{const a=m("el-button"),g=m("el-form-item"),h=m("el-form"),_=m("el-card");return y(),C("div",U,[n(_,{class:"user-views-card",shadow:"hover",header:r(s)("user.account.changePassword.Change Password")},{default:l(()=>[S("div",B,[n(h,{model:e.form,rules:e.rules,"label-position":"top",ref_key:"formRef",ref:w,onKeyup:o[5]||(o[5]=I(t=>c(),["enter"]))},{default:l(()=>[n(i,{label:r(s)("user.account.changePassword.Old password"),type:"password",modelValue:e.form.oldPassword,"onUpdate:modelValue":o[0]||(o[0]=t=>e.form.oldPassword=t),prop:"oldPassword","input-attr":{showPassword:!0},placeholder:r(s)("user.account.changePassword.Please enter your current password")},null,8,["label","modelValue","placeholder"]),n(i,{label:r(s)("user.account.changePassword.New password"),type:"password",modelValue:e.form.newPassword,"onUpdate:modelValue":o[1]||(o[1]=t=>e.form.newPassword=t),prop:"newPassword","input-attr":{showPassword:!0},placeholder:r(s)("Please input field",{field:r(s)("user.account.changePassword.New password")})},null,8,["label","modelValue","placeholder"]),n(i,{label:r(s)("user.account.changePassword.Confirm new password"),type:"password",modelValue:e.form.confirmPassword,"onUpdate:modelValue":o[2]||(o[2]=t=>e.form.confirmPassword=t),prop:"confirmPassword","input-attr":{showPassword:!0},placeholder:r(s)("Please input field",{field:r(s)("user.account.changePassword.Confirm new password")})},null,8,["label","modelValue","placeholder"]),n(g,{class:"submit-buttons"},{default:l(()=>[n(a,{onClick:o[3]||(o[3]=t=>r($)(r(w)))},{default:l(()=>[f(p(d.$t("Reset")),1)]),_:1}),n(a,{type:"primary",loading:e.formSubmitLoading,onClick:o[4]||(o[4]=t=>c())},{default:l(()=>[f(p(d.$t("Save")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"])])]),_:1},8,["header"])])}}}),O=L(k,[["__scopeId","data-v-9cc2dcfb"]]);export{O as default};
