var c=(s,n,l)=>new Promise((f,o)=>{var v=a=>{try{i(l.next(a))}catch(e){o(e)}},b=a=>{try{i(l.throw(a))}catch(e){o(e)}},i=a=>a.done?f(a.value):Promise.resolve(a.value).then(v,b);i((l=l.apply(s,n)).next())});import{d as g,b as x,c as I}from"./role-manage-91cdffc1.js";import{d as V,r as k,K as C,j as u,o as $,h as B,w as r,b as j,e as d,k as N,E as F}from"./index-90c78f99.js";const q={class:"flex justify-center"},U=V({__name:"role-dialog",props:{visible:{type:Boolean,default:!1,required:!0},data:Object},emits:["close"],setup(s,{emit:n}){const l=s,f=k(),o=k({roleName:"",remark:"",roleId:void 0}),v={roleName:[{required:!0,message:"请输入角色名称"}]},b=()=>c(this,null,function*(){const a=(yield g({id:l.data&&l.data.roleId})).data,{name:e,describe:m,id:p}=a;o.value={roleName:e,remark:m,roleId:p}}),i=a=>c(this,null,function*(){a&&(yield a.validate(e=>c(this,null,function*(){e&&(yield(l.data&&l.data.roleId?x:I)(o.value),F.success(`${l.data&&l.data.roleId?"编辑":"新增"}成功！`),n("close",!0))})))});return C(()=>l.visible,a=>{a&&l.data&&l.data.roleId?b():o.value={roleName:"",remark:"",roleId:void 0}}),(a,e)=>{const m=u("el-input"),p=u("el-form-item"),w=u("el-form"),_=u("el-button"),y=u("el-dialog");return $(),B(y,{"model-value":s.visible,title:`${s.data&&s.data.roleId?"编辑":"添加"}角色`,width:574,"destroy-on-close":"",onClose:e[5]||(e[5]=t=>n("close"))},{footer:r(()=>[j("div",q,[d(_,{type:"primary",onClick:e[3]||(e[3]=t=>i(f.value))},{default:r(()=>[N("确定")]),_:1}),d(_,{onClick:e[4]||(e[4]=t=>n("close"))},{default:r(()=>[N("取消")]),_:1})])]),default:r(()=>[d(w,{ref_key:"formRef",ref:f,"label-suffix":":",model:o.value,rules:v,"label-width":"90"},{default:r(()=>[d(p,{label:"角色名称",prop:"roleName"},{default:r(()=>[d(m,{modelValue:o.value.roleName,"onUpdate:modelValue":e[0]||(e[0]=t=>o.value.roleName=t),placeholder:"请输入",maxlength:"20",onInput:e[1]||(e[1]=t=>o.value.roleName=t.replace(/[^\u4E00-\u9FA5a-zA-Z0-9]/g,""))},null,8,["modelValue"])]),_:1}),d(p,{label:"备注"},{default:r(()=>[d(m,{modelValue:o.value.remark,"onUpdate:modelValue":e[2]||(e[2]=t=>o.value.remark=t),placeholder:"请输入",type:"textarea","show-word-limit":"",maxlength:"20"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}});export{U as _};
