import{a as q,r as u,w as G,aj as l,c as w,o as C,S as t,b as v,u as r,y as S,K as a,L as x,T as N,P as E,Q as g,R as J,ai as W,ae as X}from"./vue.D1BjjNmv.js";import{g as Y}from"./index.es.DmevZXPX.js";import{A as Z,ar as ee,an as L}from"./index.CL7yl-Wb.js";import{d as te,a as oe,l as ae}from"./api.BbNWdaep.js";import{_ as ne}from"./_plugin-vue_export-helper.DlAUqK2U.js";const le={class:"dept-tree-com"},se={class:"tc-head"},ie={key:0,class:"text-center font-black font-normal"},de={key:1,color:"var(--el-color-primary)"},re={class:"tree-tags"},ce=q({__name:"index",props:{treeData:{default:()=>[]}},emits:["treeClick","deleteDept","updateDept"],setup(ue,{expose:B,emit:R}){const F=Y(W),H={children:"children",label:"name",isLeaf:(o,e)=>!e.data.hasChild},h=R;let p=u(""),c=u(!1),f=u(!1),s=u({}),T=u(null);const D=u();G(p,o=>{D.value.filter(o)});const I=(o,e)=>{var n;return o?((n=X(e).name)==null?void 0:n.indexOf(o))!==-1:!0},P=(o,e)=>{o.level!==0&&ae({parent:o.data.id}).then(n=>{e(n.data)})},M=(o,e)=>{s.value=o,T.value=e,h("treeClick",o)},y=o=>{if(o==="update"){if(!s.value.id){L("请选择菜单！");return}h("updateDept",o,s.value)}else h("updateDept",o)},U=()=>{if(!s.value.id){L("请选择菜单！");return}h("deleteDept",s.value.id,()=>{s.value={}})},z=async o=>{var i;if(!s.value.id){L("请选择菜单！");return}if(f.value)return;const e=((i=T.value)==null?void 0:i.parent.childNodes)||[],n=e.findIndex(m=>m.data.id===s.value.id),k=e.find(m=>m.data.id===s.value.id);if(o==="up"){if(n===0)return;e.splice(n-1,0,k),e.splice(n+1,1),f.value=!0,await te({dept_id:s.value.id}),f.value=!1}o==="down"&&(e.splice(n+2,0,k),e.splice(n,1),f.value=!0,await oe({dept_id:s.value.id}),f.value=!1)};return B({treeRef:D}),(o,e)=>{const n=l("el-input"),k=l("HomeFilled"),i=l("el-icon"),m=l("View"),$=l("Hide"),V=l("SvgIcon"),j=l("Plus"),_=l("el-tooltip"),A=l("Edit"),K=l("Top"),O=l("Bottom"),Q=l("Delete");return C(),w(J,null,[t(n,{modelValue:r(p),"onUpdate:modelValue":e[0]||(e[0]=d=>S(p)?p.value=d:p=d),"prefix-icon":r(Z),placeholder:"请输入部门名称"},null,8,["modelValue","prefix-icon"]),v("div",le,[v("div",se,[t(i,{size:"16",color:"#606266",class:"tc-head-icon"},{default:a(()=>[t(k)]),_:1}),e[6]||(e[6]=v("span",{class:"tc-head-txt"},"部门架构",-1)),t(i,{size:"16",color:"#606266",onClick:e[1]||(e[1]=()=>S(c)?c.value=!r(c):c=!r(c)),class:"tc-head-icon"},{default:a(()=>[x(t(m,null,null,512),[[N,!r(c)]]),x(t($,null,null,512),[[N,r(c)]])]),_:1})]),t(r(ee),{ref_key:"treeRef",ref:D,data:o.treeData,props:H,"filter-node-method":I,load:P,lazy:"",indent:38,onNodeClick:M,"highlight-current":""},{default:a(({node:d,data:b})=>[t(r(F),{node:d,showLabelLine:!1,indent:32},{default:a(()=>[b.status?(C(),w("span",ie,[t(V,{name:"iconfont icon-shouye",color:"var(--el-color-primary)"}),E(" "+g(d.label)+" ",1),x(v("span",null,"（"+g(b.dept_user_count)+"人）",513),[[N,r(c)]])])):(C(),w("span",de,[t(V,{name:"iconfont icon-shouye"}),E(" "+g(d.label),1)]))]),_:2},1032,["node"])]),_:1},8,["data"]),v("div",re,[t(_,{effect:"dark",content:"新增"},{default:a(()=>[t(i,{size:"16",onClick:e[2]||(e[2]=d=>y("create")),class:"mlt-icon"},{default:a(()=>[t(j)]),_:1})]),_:1}),t(_,{effect:"dark",content:"编辑"},{default:a(()=>[t(i,{size:"16",onClick:e[3]||(e[3]=d=>y("update")),class:"mlt-icon"},{default:a(()=>[t(A)]),_:1})]),_:1}),t(_,{effect:"dark",content:"上移"},{default:a(()=>[t(i,{size:"16",onClick:e[4]||(e[4]=d=>z("up")),class:"mlt-icon"},{default:a(()=>[t(K)]),_:1})]),_:1}),t(_,{effect:"dark",content:"下移"},{default:a(()=>[t(i,{size:"16",onClick:e[5]||(e[5]=d=>z("down")),class:"mlt-icon"},{default:a(()=>[t(O)]),_:1})]),_:1}),t(_,{effect:"dark",content:"删除"},{default:a(()=>[t(i,{size:"16",onClick:U,class:"mlt-icon"},{default:a(()=>[t(Q)]),_:1})]),_:1})])])],64)}}}),he=ne(ce,[["__scopeId","data-v-0a1dffe4"]]);export{he as default};
