import{g as A}from"./index.es.DmevZXPX.js";import{o as G,V as H}from"./elementPlus.CXoFsoPv.js";import{_ as b}from"./index.vue_vue_type_script_setup_true_name_svgIcon_lang.EO34UlUs.js";import{l as J,m as K,a as W}from"./api.Chxgk-Xp.js";import{w as x}from"./index.fM6cvGYs.js";import{d as X,r as _,w as Y,ai as i,aq as Z,o as c,c as C,U as a,u as g,D as ee,a as M,O as n,S as z,F as te,ae,T as V,P as v,M as k,ah as ne}from"./vue.1RczIYhx.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-red-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=A(ne),U={children:"children",label:"name",icon:"icon",isLeaf:(t,e)=>!e.data.is_catalog},w=_(),D=B;let u=_(""),f=_(!1),l=_({}),L=_(null);Y(u,t=>{w.value.filter(t)});const S=(t,e)=>t?ae(e).name.indexOf(t)!==-1:!0,$=(t,e)=>{t.level!==0&&J({parent:t.data.id}).then(r=>{e(r.data)})},F=(t,e)=>{l.value=t,L.value=e,D("treeClick",t)},N=t=>{if(t==="update"){if(!l.value.id){x("请选择菜单！");return}D("updateDept",t,l.value)}else D("updateDept",t)},P=()=>{if(!l.value.id){x("请选择菜单！");return}D("deleteDept",l.value.id,()=>{l.value={}})},T=async t=>{var s;if(!l.value.id){x("请选择菜单！");return}if(f.value)return;const e=((s=L.value)==null?void 0:s.parent.childNodes)||[],r=e.findIndex(m=>m.data.id===l.value.id),h=e.find(m=>m.data.id===l.value.id);if(t==="up"){if(r===0)return;e.splice(r-1,0,h),e.splice(r+1,1),f.value=!0,await K({menu_id:l.value.id}),f.value=!1}t==="down"&&(e.splice(r+2,0,h),e.splice(r,1),f.value=!0,await W({menu_id:l.value.id}),f.value=!1)};return y({treeRef:w}),(t,e)=>{const r=i("el-input"),h=i("Menu"),s=i("el-icon"),m=i("QuestionFilled"),d=i("el-tooltip"),R=i("Plus"),I=i("Edit"),O=i("Top"),Q=i("Bottom"),q=i("Delete"),p=Z("auth");return c(),C(te,null,[a(r,{modelValue:g(u),"onUpdate:modelValue":e[0]||(e[0]=o=>ee(u)?u.value=o:u=o),"prefix-icon":g(G),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(h)]),_: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:w,data:t.treeData,props:U,"filter-node-method":S,load:$,lazy:"",indent:45,onNodeClick:F,"highlight-current":""},{default:n(({node:o,data:j})=>[a(g(E),{node:o,showLabelLine:!1,indent:32},{default:n(()=>[j.status?(c(),C("span",ie,[a(b,{name:o.data.icon,color:"var(--el-color-primary)"},null,8,["name"]),z("  "+V(o.label),1)])):(c(),C("span",re,[a(b,{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=>N("create")),class:"mtc-tags-icon"},{default:n(()=>[a(R)]),_:1})),[[p,"menu:Create"]])]),_:1}),a(d,{effect:"dark",content:"编辑"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[2]||(e[2]=o=>N("update")),class:"mtc-tags-icon"},{default:n(()=>[a(I)]),_:1})),[[p,"menu:Update"]])]),_:1}),a(d,{effect:"dark",content:"上移"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[3]||(e[3]=o=>T("up")),class:"mtc-tags-icon"},{default:n(()=>[a(O)]),_:1})),[[p,"menu:MoveUp"]])]),_:1}),a(d,{effect:"dark",content:"下移"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[4]||(e[4]=o=>T("down")),class:"mtc-tags-icon"},{default:n(()=>[a(Q)]),_:1})),[[p,"menu:MoveDown"]])]),_:1}),a(d,{effect:"dark",content:"删除"},{default:n(()=>[v((c(),k(s,{size:"16",onClick:e[5]||(e[5]=o=>P()),class:"mtc-tags-icon"},{default:n(()=>[a(q)]),_:1})),[[p,"menu:Delete"]])]),_:1})])])],64)}}}),he=oe(de,[["__scopeId","data-v-027d3c6f"]]);export{he as default};
