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