import{r as m}from"./index-8db2df2c.js";import{_ as F}from"./index.vue_vue_type_script_setup_true_lang-b9ebc9cb.js";import{M as f,I as S,F as q,h as A,e as M,f as O}from"./ui-ba7aaa7e.js";import{e as P,l as T,r as d,P as B,a3 as C,a4 as r,f as l}from"./vue-bf422dc1.js";function J(s){return m.post({url:"/adminapi/permission/admin/list",params:s})}function K(s){return m.post({url:"/adminapi/permission/admin/delete",params:s})}function E(s){return m.post({url:"/adminapi/permission/admin/edit",params:s})}function N(s){return m.post({url:"/adminapi/permission/admin/detail",params:s})}function j(){return m.post({url:"/adminapi/permission/role/listSimpleTree"})}const L={name:"AdminEditPopup"},Q=P({...L,emits:["success"],setup(s,{expose:b,emit:v}){const p={username:"",nickname:"",password:"",avatar:"",email:"",mobile:"",id:""},a=T({...p}),V=({name:t,url:e})=>{a[t]=e},y=d([]),g=async()=>{const{data:t}=await j();y.value=t.list},u=d(!1),c=d("添加管理员"),w=t=>{if(t)c.value="编辑管理员",k(t);else{c.value="添加管理员";for(const e in p)a[e]=p[e]}g(),u.value=!0},k=async t=>{const{data:e}=await N({id:t});for(const o in a)e[o]!=null&&e[o]!==void 0&&(o==="role"?a[o]=e[o].map(i=>i.id):a[o]=e[o])};b({init:w});const _=d(null),U={role:[{required:!0,message:"必填",type:"error"}],username:[{required:!0,message:"必填",type:"error"}]},x=v,I=async()=>{const t=await _.value.validate();if(typeof t!="object"&&t)try{const e=await E(a);e.code===1?(f.success("操作成功"),u.value=!1,x("success")):f.error(e.msg)}catch(e){f.error(e.msg)}};return(t,e)=>{const o=S,i=q,R=A,h=M,D=O;return B(),C(D,{visible:u.value,"onUpdate:visible":e[5]||(e[5]=n=>u.value=n),"close-on-overlay-click":!1,"destroy-on-close":!0,header:c.value,"on-confirm":I},{default:r(()=>[l(h,{ref_key:"formRef",ref:_,"label-align":"left",data:a,rules:U,"label-width":80},{default:r(()=>[l(i,{label:"用户名",name:"username"},{default:r(()=>[l(o,{modelValue:a.username,"onUpdate:modelValue":e[0]||(e[0]=n=>a.username=n),clearable:"",placeholder:"请输入管理员用户名"},null,8,["modelValue"])]),_:1}),l(i,{label:"昵称",name:"nickname"},{default:r(()=>[l(o,{modelValue:a.nickname,"onUpdate:modelValue":e[1]||(e[1]=n=>a.nickname=n),clearable:"",placeholder:"请输入昵称"},null,8,["modelValue"])]),_:1}),l(i,{label:"密码",name:"password"},{default:r(()=>[l(o,{modelValue:a.password,"onUpdate:modelValue":e[2]||(e[2]=n=>a.password=n),clearable:"",placeholder:"留空则不更改"},null,8,["modelValue"])]),_:1}),l(i,{label:"头像",name:"avatar"},{default:r(()=>[l(F,{theme:"image",app:"admin",initial:a,name:"avatar",data:{type:"image"},onUpdate:V},null,8,["initial"])]),_:1}),l(i,{label:"邮箱",name:"email"},{default:r(()=>[l(o,{modelValue:a.email,"onUpdate:modelValue":e[3]||(e[3]=n=>a.email=n),clearable:"",placeholder:"请输入邮箱"},null,8,["modelValue"])]),_:1}),l(i,{label:"手机",name:"mobile"},{default:r(()=>[l(R,{modelValue:a.mobile,"onUpdate:modelValue":e[4]||(e[4]=n=>a.mobile=n),clearable:"",placeholder:"请输入手机",style:{width:"500px"},theme:"column",min:0},null,8,["modelValue"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{Q as _,K as d,J as l};
