1 |
- import{d as D,e as M,o as i,c as u,f as m,B as g,C as k,aa as b,G as N,D as y,a as h,E as v,a0 as O,F as T,_ as j}from"./index-24b5bd0d.js";import{V}from"./vuedraggable.umd-d537df3c.js";import{_ as A}from"./_plugin-vue_export-helper-1b428a4d.js";const B={class:"menu_bottom"},F=["onClick"],G={key:0,class:"submenu"},L={class:"menu_bottom subtitle"},P=["onClick"],S=["onClick"],q=A(D({__name:"MenuPreviewer",props:{modelValue:{},activeIndex:{},parentIndex:{},accountId:{}},emits:["update:modelValue","menu-clicked","submenu-clicked"],setup(f,{emit:C}){const d=f,s=C,o=M({get:()=>d.modelValue,set:n=>s("update:modelValue",n)}),E=()=>{const n=o.value.length,l={name:"\u83DC\u5355\u540D\u79F0",children:[],reply:{type:"text",accountId:d.accountId}};o.value[n]=l,I(l,n-1)},I=(n,l)=>{s("menu-clicked",n,l)},x=(n,l,a)=>{s("submenu-clicked",n,l,a)},w=({oldIndex:n,newIndex:l})=>{if(d.activeIndex==="__MENU_NOT_SELECTED__")return;let a=new Array(o.value.length).fill(!1);a[d.parentIndex]=!0;const[e]=a.splice(n,1);a.splice(l,0,e);const t=a.indexOf(!0),c=o.value[t];s("menu-clicked",c,t)},U=({newIndex:n})=>{var t;const l=d.parentIndex,a=n,e=(t=o.value[l])==null?void 0:t.children;if(e&&(e==null?void 0:e.length)>0){const c=e[a];s("submenu-clicked",c,l,a)}};return(n,l)=>{const a=j;return i(),u(T,null,[m(h(V),{modelValue:h(o),"onUpdate:modelValue":l[0]||(l[0]=e=>O(o)?o.value=e:null),"item-key":"id","ghost-class":"draggable-ghost",animation:400,onEnd:w},{item:g(({element:e,index:t})=>[k("div",B,[k("div",{onClick:c=>I(e,t),class:b(["menu_item",{active:d.activeIndex===`${t}`}])},[m(a,{icon:"ep:fold",color:"black"}),N(y(e.name),1)],10,F),d.parentIndex===t&&e.children?(i(),u("div",G,[m(h(V),{modelValue:e.children,"onUpdate:modelValue":c=>e.children=c,"item-key":"id","ghost-class":"draggable-ghost",animation:400,onEnd:U},{item:g(({element:c,index:r})=>[k("div",L,[e.children?(i(),u("div",{key:0,class:b(["menu_subItem",{active:d.activeIndex===`${t}-${r}`}]),onClick:p=>x(c,t,r)},y(c.name),11,P)):v("",!0)])]),_:2},1032,["modelValue","onUpdate:modelValue"]),!e.children||e.children.length<5?(i(),u("div",{key:0,class:"menu_bottom menu_addicon",onClick:c=>((r,p)=>{const _=p.children.length,$={name:"\u5B50\u83DC\u5355\u540D\u79F0",reply:{type:"text",accountId:d.accountId}};p.children[_]=$,x(p.children[_],r,_)})(t,e)},[m(a,{icon:"ep:plus",class:"plus"})],8,S)):v("",!0)])):v("",!0)])]),_:1},8,["modelValue"]),h(o).length<3?(i(),u("div",{key:0,class:"menu_bottom menu_addicon",onClick:E},[m(a,{icon:"ep:plus",class:"plus"})])):v("",!0)],64)}}}),[["__scopeId","data-v-7c5212d5"]]);export{q as default};
|