import{a as x,e as D,b as F}from"./role-a0a31a82.js";import{M as c,I as R,F as U,e as I,f as M}from"./ui-ba7aaa7e.js";import{e as P,l as h,r as u,P as A,a3 as B,a4 as i,f as s}from"./vue-bf422dc1.js";const C={name:"EditPopup"},L=P({...C,emits:["success"],setup(E,{expose:p,emit:_}){const m={name:"",remark:"",id:0},a=h({...m}),r=u(!1),d=u(),v=o=>{if(d.value=o?"编辑角色":"添加角色",o)b(o);else for(const e in m)a[e]=m[e];r.value=!0},b=async o=>{const{data:e}=await x({id:o});for(const t in a)e[t]!=null&&e[t]!==void 0&&(t==="role"?a[t]=e[t].map(n=>n.id):a[t]=e[t])};p({init:v});const f=u(),k={name:[{required:!0,message:"必填",type:"error"}]},y=_,g=async()=>{const o=await f.value.validate();if(typeof o!="object"&&o)try{const e=a.id>0?await D(a):await F(a);if(e.code!==1){c.error(e.msg);return}c.success("操作成功"),r.value=!1,y("success")}catch(e){c.error(e.msg)}};return(o,e)=>{const t=R,n=U,V=I,w=M;return A(),B(w,{visible:r.value,"onUpdate:visible":e[2]||(e[2]=l=>r.value=l),"close-on-overlay-click":!1,"destroy-on-close":!0,header:d.value,"on-confirm":g},{default:i(()=>[s(V,{ref_key:"formRef",ref:f,"label-align":"left",data:a,rules:k,"label-width":80},{default:i(()=>[s(n,{label:"角色名",name:"name"},{default:i(()=>[s(t,{modelValue:a.name,"onUpdate:modelValue":e[0]||(e[0]=l=>a.name=l),clearable:"",placeholder:"请输入角色名"},null,8,["modelValue"])]),_:1}),s(n,{label:"备注",name:"remark"},{default:i(()=>[s(t,{modelValue:a.remark,"onUpdate:modelValue":e[1]||(e[1]=l=>a.remark=l),clearable:"",placeholder:"请输入备注"},null,8,["modelValue"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{L as _};
