import{A as e,B as a,C as l,a7 as t,e as o,X as s,E as d}from"./vendor-element-DupX9wXy.js";import{d as r,a7 as i}from"./index-CY1ySRal.js";import{q as u,c as n,bM as m,r as p,a2 as c,S as v,D as f,v as g,E as V,M as y,u as h,J as b,h as _}from"./vendor-core-Di0OO4oJ.js";const w=u({__name:"role-edit-dialog",props:{modelValue:{type:Boolean,default:!1},dialogType:{default:"add"},roleData:{default:void 0}},emits:["update:modelValue","success"],setup(u,{emit:w}){const{width:D}=m(),x=r(),j=n(()=>{var e;const a=(null==(e=x.info)?void 0:e.roles)||[];return!(a.includes("R_ADMIN")||a.includes("R_SUPER"))&&D.value<768}),U=u,C=w,R=p(),T=n({get:()=>U.modelValue,set:e=>C("update:modelValue",e)}),k=c({name:[{required:!0,message:"请输入角色名称",trigger:"blur"},{min:2,max:20,message:"长度在 2 到 20 个字符",trigger:"blur"}],description:[{required:!0,message:"请输入角色描述",trigger:"blur"}]}),q=c({id:void 0,name:"",description:"",status:1});v(()=>U.modelValue,e=>{e&&E()});const E=()=>{"edit"===U.dialogType&&U.roleData?Object.assign(q,{id:U.roleData.id,name:U.roleData.name,description:U.roleData.description,status:U.roleData.status}):Object.assign(q,{id:void 0,name:"",description:"",status:1})},M=()=>{var e;T.value=!1,null==(e=R.value)||e.resetFields()},P=()=>{return e=null,a=null,l=function*(){if(R.value)try{yield R.value.validate(),yield i(q);const e="add"===U.dialogType?"新增成功":"修改成功";d.success(e),C("success"),M()}catch(e){}},new Promise((t,o)=>{var s=e=>{try{r(l.next(e))}catch(a){o(a)}},d=e=>{try{r(l.throw(e))}catch(a){o(a)}},r=e=>e.done?t(e.value):Promise.resolve(e.value).then(s,d);r((l=l.apply(e,a)).next())});var e,a,l};return(d,r)=>{const i=l,n=a,m=t,p=e,c=o,v=s;return g(),f(v,{modelValue:h(T),"onUpdate:modelValue":r[3]||(r[3]=e=>_(T)?T.value=e:null),title:"add"===u.dialogType?"新增角色":"编辑角色",width:h(j)?"90%":"30%","align-center":"",onClose:M},{footer:V(()=>[y(c,{onClick:M},{default:V(()=>[...r[4]||(r[4]=[b("取消",-1)])]),_:1}),y(c,{type:"primary",onClick:P},{default:V(()=>[...r[5]||(r[5]=[b("提交",-1)])]),_:1})]),default:V(()=>[y(p,{ref_key:"formRef",ref:R,model:h(q),rules:h(k),"label-width":h(j)?"auto":"120px","label-position":h(j)?"top":"right"},{default:V(()=>[y(n,{label:"角色名称",prop:"name"},{default:V(()=>[y(i,{modelValue:h(q).name,"onUpdate:modelValue":r[0]||(r[0]=e=>h(q).name=e),placeholder:"请输入角色名称"},null,8,["modelValue"])]),_:1}),y(n,{label:"描述",prop:"description"},{default:V(()=>[y(i,{modelValue:h(q).description,"onUpdate:modelValue":r[1]||(r[1]=e=>h(q).description=e),type:"textarea",rows:3,placeholder:"请输入角色描述"},null,8,["modelValue"])]),_:1}),y(n,{label:"启用"},{default:V(()=>[y(m,{modelValue:h(q).status,"onUpdate:modelValue":r[2]||(r[2]=e=>h(q).status=e),"active-value":1,"inactive-value":0},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules","label-width","label-position"])]),_:1},8,["modelValue","title","width"])}}});export{w as default};
