import{a as A,r as u,w as G,aj as a,c as w,o as C,S as t,b as v,u as r,y as S,K as l,L as x,T as N,P as E,Q as T,R as J,ai as W,ae as X}from"./vue.D1BjjNmv.js";import{g as Y}from"./index.es.DmevZXPX.js";import{x as Z,a1 as ee,T as g}from"./index.Df8UJ10K.js";import{l as te,d as oe,a as le}from"./api.CryKD3hM.js";import{_ as ne}from"./_plugin-vue_export-helper.DlAUqK2U.js";const ae={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=A({__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({}),L=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&&te({parent:o.data.id}).then(n=>{e(n.data)})},M=(o,e)=>{s.value=o,L.value=e,h("treeClick",o)},y=o=>{if(o==="update"){if(!s.value.id){g("请选择菜单！");return}h("updateDept",o,s.value)}else h("updateDept",o)},U=()=>{if(!s.value.id){g("请选择菜单！");return}h("deleteDept",s.value.id,()=>{s.value={}})},z=async o=>{var i;if(!s.value.id){g("请选择菜单！");return}if(f.value)return;const e=((i=L.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 oe({dept_id:s.value.id}),f.value=!1}o==="down"&&(e.splice(n+2,0,k),e.splice(n,1),f.value=!0,await le({dept_id:s.value.id}),f.value=!1)};return B({treeRef:D}),(o,e)=>{const n=a("el-input"),k=a("HomeFilled"),i=a("el-icon"),m=a("View"),$=a("Hide"),V=a("SvgIcon"),j=a("Plus"),_=a("el-tooltip"),K=a("Edit"),O=a("Top"),Q=a("Bottom"),q=a("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",ae,[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]=()=>S(c)?c.value=!r(c):c=!r(c)),class:"tc-head-icon"},{default:l(()=>[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:l(({node:d,data:b})=>[t(r(F),{node:d,showLabelLine:!1,indent:32},{default:l(()=>[b.status?(C(),w("span",ie,[t(V,{name:"iconfont icon-shouye",color:"var(--el-color-primary)"}),E(" "+T(d.label)+" ",1),x(v("span",null,"（"+T(b.dept_user_count)+"人）",513),[[N,r(c)]])])):(C(),w("span",de,[t(V,{name:"iconfont icon-shouye"}),E(" "+T(d.label),1)]))]),_:2},1032,["node"])]),_:1},8,["data"]),v("div",re,[t(_,{effect:"dark",content:"新增"},{default:l(()=>[t(i,{size:"16",onClick:e[2]||(e[2]=d=>y("create")),class:"mlt-icon"},{default:l(()=>[t(j)]),_:1})]),_:1}),t(_,{effect:"dark",content:"编辑"},{default:l(()=>[t(i,{size:"16",onClick:e[3]||(e[3]=d=>y("update")),class:"mlt-icon"},{default:l(()=>[t(K)]),_:1})]),_:1}),t(_,{effect:"dark",content:"上移"},{default:l(()=>[t(i,{size:"16",onClick:e[4]||(e[4]=d=>z("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=>z("down")),class:"mlt-icon"},{default:l(()=>[t(Q)]),_:1})]),_:1}),t(_,{effect:"dark",content:"删除"},{default:l(()=>[t(i,{size:"16",onClick:U,class:"mlt-icon"},{default:l(()=>[t(q)]),_:1})]),_:1})])])],64)}}}),he=ne(ce,[["__scopeId","data-v-50724fd0"]]);export{he as default};
