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