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