import{g as j}from"./index.es.DmevZXPX.js";import{ae as q,a8 as H,a1 as C}from"./index.lP_uh0LI.js";import{_ as T}from"./index.vue_vue_type_script_setup_true_name_svgIcon_lang.DrINYQVe.js";import{m as J,a as K,l as W}from"./api.CMIu0bJC.js";import{d as X,a as _,m as Y,b as i,x as Z,e as w,f as c,g as a,s as M,u as g,$ as ee,l as z,w as n,A as V,z as v,h as k,F as te,G as ae,v as ne}from"./vue.BxlDVA1H.js";import{_ as oe}from"./_plugin-vue_export-helper.DlAUqK2U.js";const le={class:"menu-tree-com"},se={class:"mtc-head"},ie={key:0,class:"text-center font-black font-normal"},re={key:1,class:"text-center font-black text-700 font-normal"},ce={class:"mtc-tags"},de=X({__name:"index",props:{treeData:{default:()=>[]}},emits:["treeClick","deleteDept","updateDept"],setup(ue,{expose:y,emit:B}){const E=j(ae),$={children:"children",label:"name",icon:"icon",isLeaf:(t,e)=>!e.data.is_catalog},x=_(),h=B;let u=_(""),f=_(!1),l=_({}),b=_(null);Y(u,t=>{x.value.filter(t)});const U=(t,e)=>t?ne(e).name.indexOf(t)!==-1:!0,F=(t,e)=>{t.level!==0&&W({parent:t.data.id}).then(r=>{e(r.data)})},R=(t,e)=>{l.value=t,b.value=e,h("treeClick",t)},L=t=>{if(t==="update"){if(!l.value.id){C("请选择菜单！");return}h("updateDept",t,l.value)}else h("updateDept",t)},S=()=>{if(!l.value.id){C("请选择菜单！");return}h("deleteDept",l.value.id,()=>{l.value={}})},N=async t=>{var s;if(!l.value.id){C("请选择菜单！");return}if(f.value)return;const e=((s=b.value)==null?void 0:s.parent.childNodes)||[],r=e.findIndex(m=>m.data.id===l.value.id),D=e.find(m=>m.data.id===l.value.id);if(t==="up"){if(r===0)return;e.splice(r-1,0,D),e.splice(r+1,1),f.value=!0,await J({menu_id:l.value.id}),f.value=!1}t==="down"&&(e.splice(r+2,0,D),e.splice(r,1),f.value=!0,await K({menu_id:l.value.id}),f.value=!1)};return y({treeRef:x}),(t,e)=>{const r=i("el-input"),D=i("Menu"),s=i("el-icon"),m=i("QuestionFilled"),d=i("el-tooltip"),I=i("Plus"),P=i("Edit"),Q=i("Top"),A=i("Bottom"),G=i("Delete"),p=Z("auth");return c(),w(te,null,[a(r,{modelValue:g(u),"onUpdate:modelValue":e[0]||(e[0]=o=>ee(u)?u.value=o:u=o),"prefix-icon":g(q),placeholder:"请输入菜单名称"},null,8,["modelValue","prefix-icon"]),M("div",le,[M("div",se,[a(s,{size:"16",color:"#606266",class:"mtc-head-icon"},{default:n(()=>[a(D)]),_:1}),e[6]||(e[6]=z(" 菜单列表 ")),a(d,{effect:"dark",placement:"right",content:"1.红色菜单代表状态禁用; 2.添加菜单，如果是目录，组件地址为空即可; 3.添加根节点菜单，父级ID为空即可; 4.支持拖拽菜单;"},{default:n(()=>[a(s,{size:"16",color:"var(--el-color-primary)",class:"mtc-tooltip"},{default:n(()=>[a(m)]),_:1})]),_:1})]),a(g(H),{ref_key:"treeRef",ref:x,data:t.treeData,props:$,"filter-node-method":U,load:F,lazy:"",indent:45,onNodeClick:R,"highlight-current":""},{default:n(({node:o,data:O})=>[a(g(E),{node:o,showLabelLine:!1,indent:32},{default:n(()=>[O.status?(c(),w("span",ie,[a(T,{name:o.data.icon,color:"var(--el-color-primary)"},null,8,["name"]),z("  "+V(o.label),1)])):(c(),w("span",re,[a(T,{name:o.data.icon},null,8,["name"]),z(" "+V(o.label),1)]))]),_:2},1032,["node"])]),_:1},8,["data"]),M("div",ce,[a(d,{effect:"dark",content:"新增"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[1]||(e[1]=o=>L("create")),class:"mtc-tags-icon"},{default:n(()=>[a(I)]),_:1})),[[p,"menu:Create"]])]),_:1}),a(d,{effect:"dark",content:"编辑"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[2]||(e[2]=o=>L("update")),class:"mtc-tags-icon"},{default:n(()=>[a(P)]),_:1})),[[p,"menu:Update"]])]),_:1}),a(d,{effect:"dark",content:"上移"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[3]||(e[3]=o=>N("up")),class:"mtc-tags-icon"},{default:n(()=>[a(Q)]),_:1})),[[p,"menu:MoveUp"]])]),_:1}),a(d,{effect:"dark",content:"下移"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[4]||(e[4]=o=>N("down")),class:"mtc-tags-icon"},{default:n(()=>[a(A)]),_:1})),[[p,"menu:MoveDown"]])]),_:1}),a(d,{effect:"dark",content:"删除"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[5]||(e[5]=o=>S()),class:"mtc-tags-icon"},{default:n(()=>[a(G)]),_:1})),[[p,"menu:Delete"]])]),_:1})])])],64)}}}),he=oe(de,[["__scopeId","data-v-d9f3ad4f"]]);export{he as default};
