import{d as e,a as l,c as a,r as o,w as r,y as t,f as d,z as s,p as i,u,l as m,I as n,O as p}from"./index-ip5gDR6L.js";/* empty css                  *//* empty css                   *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                 */import{E as c,a as f}from"./index-CxGOZAw2.js";import{E as g}from"./index-DfrOVkw6.js";import{E as V}from"./index-B1Z255S_.js";import{E as b}from"./index-opP5No9I.js";import{E as y}from"./index-BpP4itD-.js";const j=e({__name:"role-edit-dialog",props:{modelValue:{type:Boolean,default:!1},dialogType:{default:"add"},roleData:{default:void 0}},emits:["update:modelValue","success"],setup(e,{emit:j}){const v=e,x=j,h=l(),_=a({get:()=>v.modelValue,set:e=>x("update:modelValue",e)}),C=o({roleName:[{required:!0,message:"请输入角色名称",trigger:"blur"},{min:2,max:20,message:"长度在 2 到 20 个字符",trigger:"blur"}],roleCode:[{required:!0,message:"请输入角色编码",trigger:"blur"},{min:2,max:50,message:"长度在 2 到 50 个字符",trigger:"blur"}],description:[{required:!0,message:"请输入角色描述",trigger:"blur"}]}),w=o({roleId:0,roleName:"",roleCode:"",description:"",createTime:"",enabled:!0});r(()=>v.modelValue,e=>{e&&N()}),r(()=>v.roleData,e=>{e&&v.modelValue&&N()},{deep:!0});const N=()=>{"edit"===v.dialogType&&v.roleData?Object.assign(w,v.roleData):Object.assign(w,{roleId:0,roleName:"",roleCode:"",description:"",createTime:"",enabled:!0})},T=()=>{var e;_.value=!1,null==(e=h.value)||e.resetFields()},E=()=>{return e=this,l=null,a=function*(){if(h.value)try{yield h.value.validate();const e="add"===v.dialogType?"新增成功":"修改成功";p.success(e),x("success"),T()}catch(e){}},new Promise((o,r)=>{var t=e=>{try{s(a.next(e))}catch(l){r(l)}},d=e=>{try{s(a.throw(e))}catch(l){r(l)}},s=e=>e.done?o(e.value):Promise.resolve(e.value).then(t,d);s((a=a.apply(e,l)).next())});var e,l,a};return(l,a)=>{const o=g,r=f,p=V,j=c,v=b,x=y;return d(),t(x,{modelValue:u(_),"onUpdate:modelValue":a[4]||(a[4]=e=>n(_)?_.value=e:null),title:"add"===e.dialogType?"新增角色":"编辑角色",width:"30%","align-center":"",onClose:T},{footer:s(()=>[i(v,{onClick:T},{default:s(()=>[...a[5]||(a[5]=[m("取消",-1)])]),_:1}),i(v,{type:"primary",onClick:E},{default:s(()=>[...a[6]||(a[6]=[m("提交",-1)])]),_:1})]),default:s(()=>[i(j,{ref_key:"formRef",ref:h,model:u(w),rules:u(C),"label-width":"120px"},{default:s(()=>[i(r,{label:"角色名称",prop:"roleName"},{default:s(()=>[i(o,{modelValue:u(w).roleName,"onUpdate:modelValue":a[0]||(a[0]=e=>u(w).roleName=e),placeholder:"请输入角色名称"},null,8,["modelValue"])]),_:1}),i(r,{label:"角色编码",prop:"roleCode"},{default:s(()=>[i(o,{modelValue:u(w).roleCode,"onUpdate:modelValue":a[1]||(a[1]=e=>u(w).roleCode=e),placeholder:"请输入角色编码"},null,8,["modelValue"])]),_:1}),i(r,{label:"描述",prop:"description"},{default:s(()=>[i(o,{modelValue:u(w).description,"onUpdate:modelValue":a[2]||(a[2]=e=>u(w).description=e),type:"textarea",rows:3,placeholder:"请输入角色描述"},null,8,["modelValue"])]),_:1}),i(r,{label:"启用"},{default:s(()=>[i(p,{modelValue:u(w).enabled,"onUpdate:modelValue":a[3]||(a[3]=e=>u(w).enabled=e)},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});export{j as _};
