import{I as g,r as j,h as b,F as k,W as y}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897318.js";import"./index.170379627897319.js";import"./index.170379627897314.js";import{c as h,v as w,d as x}from"./center.1703796278973.js";import"./default.1703796278973.js";import"./index.1703796278973299.js";import{d as q,k as p,o as B,c as C,a as i,b as t,u as a}from"./vue.1703796278973.js";import{aN as F}from"./index.17037962789733.js";const $=q({__name:"EditPasswordDialog",props:{visible:{type:Boolean}},emits:["ok","update:visible"],setup(L,{emit:u}){const d=p(!1),m=p(),s=p({oldPassword:"",newPassword:"",confirmPassword:""}),c={old:async(l,e)=>{if(!e)return Promise.reject();try{const r=await h(e);return r.status===200&&!r.result.passed?Promise.reject(r.result.reason):Promise.resolve()}catch{return Promise.reject("验证失败")}},new:async(l,e)=>{if(e){if(s.value.confirmPassword&&e!==s.value.confirmPassword)return Promise.reject("两次密码输入不一致")}else return Promise.reject();try{const r=await w("password",e);return r.status===200&&!r.result.passed?Promise.reject(r.result.reason):Promise.resolve()}catch{return Promise.reject("验证失败")}},confirm:async(l,e)=>{var r;if(e)s.value.newPassword&&e!==s.value.newPassword&&((r=m.value)==null||r.validate("newPassword"));else return Promise.reject();try{const o=await w("password",e);return o.status===200&&!o.result.passed?Promise.reject(o.result.reason):Promise.resolve()}catch{return Promise.reject("验证失败")}}},_=()=>{var l;(l=m.value)==null||l.validate().then(()=>{d.value=!0;const e={oldPassword:s.value.oldPassword,newPassword:s.value.newPassword};x(e).then(r=>{r.status===200&&(F.success("保存成功"),u("ok"),u("update:visible",!1))}).finally(()=>d.value=!1)})};return console.clear(),(l,e)=>{const r=g,o=j,f=b,P=k,v=y;return B(),C(v,{visible:"",title:"重置密码",onOk:_,width:"520px",confirmLoading:a(d),onCancel:e[3]||(e[3]=n=>u("update:visible",!1))},{default:i(()=>[t(P,{model:a(s),layout:"vertical",ref_key:"formRef",ref:m},{default:i(()=>[t(o,{label:"旧密码",name:"oldPassword",rules:[{required:!0,message:"请输入密码"},{validator:c.old,trigger:"blur"}]},{default:i(()=>[t(r,{value:a(s).oldPassword,"onUpdate:value":e[0]||(e[0]=n=>a(s).oldPassword=n),placeholder:"请输入旧密码"},null,8,["value"])]),_:1},8,["rules"]),t(o,{label:"密码",name:"newPassword",rules:[{required:!0,message:"请输入密码"},{validator:c.new,trigger:"blur"}]},{default:i(()=>[t(f,{value:a(s).newPassword,"onUpdate:value":e[1]||(e[1]=n=>a(s).newPassword=n),placeholder:"请输入密码"},null,8,["value"])]),_:1},8,["rules"]),t(o,{label:"确认密码",name:"confirmPassword",rules:[{required:!0,message:"请输入确认密码"},{validator:c.confirm,trigger:"blur"}]},{default:i(()=>[t(f,{value:a(s).confirmPassword,"onUpdate:value":e[2]||(e[2]=n=>a(s).confirmPassword=n),placeholder:"请再次输入密码"},null,8,["value"])]),_:1},8,["rules"])]),_:1},8,["model"])]),_:1},8,["confirmLoading"])}}});export{$ as _};
