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