var f=(g,p,r)=>new Promise((m,s)=>{var h=i=>{try{d(r.next(i))}catch(n){s(n)}},y=i=>{try{d(r.throw(i))}catch(n){s(n)}},d=i=>i.done?m(i.value):Promise.resolve(i.value).then(h,y);d((r=r.apply(g,p)).next())});import{a as x,z as F,b as l,o as S,k as G,e as a,w as o,K as v,u as c,V as I,E as w,G as K,aP as H,a$ as U,c as j,b0 as C,i as q,U as J,F as Q,a5 as W,aa as X}from"./ant-design-vue-710243d9.js";import{a as Y,f as D,g as P}from"./index-2a45336b.js";import{u as Z}from"./usePagination-7442a465.js";import ee from"./EditRoleDialog-1a8a905b.js";import{l as te,w as O,f as ae}from"./lodash-es-7cb071db.js";import"./tinymce-3184e0f1.js";import"./echarts-ca5d9323.js";import"./cropper-47c8e461.js";import"./qrcode-bec2257a.js";import"./jschardet-bd496279.js";import"./useForm-269e95cd.js";const oe={class:"ant-tree-title__name"},ne={class:"ant-tree-title__actions"},ye={__name:"Role",props:{value:{type:String,default:""}},emits:["change","update:value"],setup(g,{emit:p}){const r=g,m=Y(),{listData:s,loading:h,showLoading:y,hideLoading:d}=Z(),i=x(),n=x([r.value]);F(()=>r.value,e=>{var t;e!==((t=n.value)==null?void 0:t[0])&&(n.value=[e])}),k();function k(){return f(this,null,function*(){try{y();const{code:e,data:t}=yield D.common.getPageList().catch(()=>{throw new Error});if(d(),P("http.code.success")===e){const{records:u}=t;s.value=u,s.value.length&&(n.value=[te(O(s.value),"id")],E())}}catch(e){d()}})}function $({id:e}){W.confirm({title:"删除提示",content:"确认删除？",okText:"确认",onOk:()=>new Promise((t,u)=>{f(this,null,function*(){try{const{code:_}=yield D.common.del(e).catch(()=>{throw new Error});P("http.code.success")===_&&(t(),X.success("删除成功"),yield k())}catch(_){u()}})})})}function L(e){e.length&&(n.value=e,E())}function M(){return f(this,null,function*(){yield k()})}function E(){const e=O(n.value),t=ae(s.value,{id:e});p("update:value",e),p("change",t)}return(e,t)=>{const u=l("a-input-search"),_=l("x-action-button"),R=l("a-menu-item"),N=l("a-menu"),V=l("a-dropdown"),B=l("a-tree"),T=l("a-spin"),z=l("x-scrollbar"),A=l("a-card");return S(),G(Q,null,[a(A,{"body-style":{height:"calc(100% - 56px - 47px)",padding:0},style:J({position:"sticky",top:c(m).mainOffsetTop,height:c(m).mainHeight})},{title:o(()=>[a(u,{placeholder:"搜索角色"})]),actions:o(()=>[v("span",{onClick:t[2]||(t[2]=b=>e.$refs.editRoleDialogRef.handleCreate())},[a(c(I)),w(" 新建角色 ")])]),default:o(()=>[a(z,{class:"pa-8-2"},{default:o(()=>[a(T,{spinning:c(h)},{default:o(()=>[a(B,{"block-node":"","selected-keys":n.value,"tree-data":c(s),"field-names":{key:"id",children:"children"},onSelect:L},{title:o(({role_name:b})=>[v("span",oe,K(b),1),v("span",ne,[a(V,{trigger:["click"],onClick:t[1]||(t[1]=H(()=>{},["stop"]))},{overlay:o(()=>[a(N,null,{default:o(()=>[a(R,{onClick:t[0]||(t[0]=se=>e.$refs.editRoleDialogRef.handleEdit())},{default:o(()=>[w(" 编辑 ")]),_:1}),a(R,{onClick:$},{default:o(()=>[w("删除")]),_:1})]),_:1})]),default:o(()=>[a(_,null,{default:o(()=>[a(c(U))]),_:1})]),_:1})])]),_:1},8,["selected-keys","tree-data"]),c(s).length?q("",!0):(S(),j(c(C),{key:0,image:c(C).PRESENTED_IMAGE_SIMPLE},null,8,["image"]))]),_:1},8,["spinning"])]),_:1})]),_:1},8,["body-style","style"]),a(ee,{ref_key:"editRoleDialogRef",ref:i,onOk:M},null,512)],64)}}};export{ye as default};
