var T=Object.defineProperty;var v=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var k=(t,o,e)=>o in t?T(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,g=(t,o)=>{for(var e in o||(o={}))U.call(o,e)&&k(t,e,o[e]);if(v)for(var e of v(o))V.call(o,e)&&k(t,e,o[e]);return t};var x=(t,o,e)=>new Promise((i,s)=>{var d=a=>{try{n(e.next(a))}catch(r){s(r)}},u=a=>{try{n(e.throw(a))}catch(r){s(r)}},n=a=>a.done?i(a.value):Promise.resolve(a.value).then(d,u);n((e=e.apply(t,o)).next())});import{h as j,f as y,g as q}from"./index-2a45336b.js";import{u as z}from"./useForm-269e95cd.js";import{c as G}from"./lodash-es-7cb071db.js";import{a as H,b as p,o as I,c as J,w as _,e as h,u as l}from"./ant-design-vue-710243d9.js";import"./tinymce-3184e0f1.js";import"./echarts-ca5d9323.js";import"./cropper-47c8e461.js";import"./qrcode-bec2257a.js";import"./jschardet-bd496279.js";const oe={__name:"EditRoleDialog",emits:["ok"],setup(t,{expose:o,emit:e}){const{modal:i,showModal:s,hideModal:d,showLoading:u,hideLoading:n}=j(),{formRecord:a,formData:r,formRef:w,formRules:C,resetForm:b}=z(),R=H("取消");function E(){s({type:"create",title:"新建角色"})}function D(f={}){s({type:"edit",title:"编辑角色"}),a.value=f,r.value=G(f)}function F(){w.value.validateFields().then(f=>x(this,null,function*(){try{u();const m=g({},f);let c=null;switch(i.value.type){case"create":c=yield y.common.create(m).catch(()=>{throw new Error});break;case"edit":c=yield y.common.update(m).catch(()=>{throw new Error});break}n(),q("http.code.success")===(c==null?void 0:c.code)&&(d(),e("ok"))}catch(m){n()}})).catch(()=>{n()})}function L(){d()}function M(){b(),n()}return o({handleCreate:E,handleEdit:D}),(f,m)=>{const c=p("a-input"),B=p("a-form-item"),O=p("a-form"),A=p("a-modal");return I(),J(A,{open:l(i).open,title:l(i).title,width:480,"confirm-loading":l(i).confirmLoading,"after-close":M,"cancel-text":R.value,onOk:F,onCancel:L},{default:_(()=>[h(O,{ref_key:"formRef",ref:w,model:l(r),rules:l(C),"label-col":{style:{width:"90px"}}},{default:_(()=>[h(B,{label:"角色名称",name:"name"},{default:_(()=>[h(c,{value:l(r).name,"onUpdate:value":m[0]||(m[0]=N=>l(r).name=N)},null,8,["value"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["open","title","confirm-loading","cancel-text"])}}};export{oe as default};
