import{d as H,u as K,r as m,a as Q,o as W,f as R,i as n,w as o,k as f,l as v,p as r,v as d,h as M,y,j as V,M as S,ac as C,ao as X,ap as Y,m as w,E as x,L as Z,_ as ee}from"./index-htML_UHV.js";import{g as le,e as te,a as ae,d as ne}from"./menus-shMhw8ZU.js";const oe={class:"menus-container"},se={class:"custom-tree-node"},ue=["src"],ie={class:"dialog-footer"},re=H({__name:"menuManage",setup(de){const{t:u}=K(),j=m("https://api.raycos.net/uploaders"),g=m([]),l=m({parent_id:0,menu_name:""}),q=Q({title:[{required:!0,message:u("place")+u("menu_title")+"!",trigger:"blur"}],identifier:[{required:!0,message:u("place")+u("menu_identifier")+"!",trigger:"blur"}],auth_regular:[{required:!0,message:u("place")+u("menu_auth_regular")+"!",trigger:"blur"}]}),p=m(!1),$=m(""),h=m(""),N=m({}),U=m(),E=()=>{p.value=!1,N.value={}},I=e=>{l.value.menu_name},F=e=>{e===""&&(h.value="0"),Object.assign(l,{parent_id:e?e.id:0}),$.value=e||{},p.value=!0},A=(e,t)=>{Z.confirm(u("menu_delet_info"),u("prompt"),{type:"warning"}).then(()=>{ne(t.id).then(()=>{const s=e.parent,c=s.data.children||s.data,i=c.findIndex(_=>_.id===t.id);c.splice(i,1)})}).catch(()=>{})},D=e=>{Object.assign(l,JSON.parse(JSON.stringify(e))),N.value=l,h.value=e.parent_id,$.value=e,l.value.menu_name="编辑菜单",p.value=!0},J=e=>{U.value.validate(t=>{if(t){const{id:s}=l.value;s?te(s,l.value).then(c=>{p.value=!1,x.success(u("sub_success")),B()}):ae(l.value).then(c=>{const i=$.value;l.value.parent_id===0?g.value.push(c):(i.children||(i.children=[]),i.children.push(c)),p.value=!1,x.success(u("sub_success"))})}else return x.error(u("form_erroe")),!1})},B=()=>{le().then(e=>{g.value=e})},k=e=>!0;return W(()=>{B()}),(e,t)=>{const s=r("el-button"),c=r("el-tree"),i=r("el-input"),_=r("el-form-item"),T=r("el-icon"),G=r("el-upload"),L=r("el-switch"),P=r("el-form"),z=r("el-dialog");return d(),R("div",oe,[n(c,{data:g.value,"node-key":"identifier","expand-on-click-node":!0},{default:o(({node:a,data:b})=>[M("span",se,[M("span",null,y(b.title),1),M("span",null,[k(["menuManage:add"])?(d(),f(s,{key:0,type:"primary",text:"",disabled:a.level===4,icon:V(S),title:a.level===4?"菜单最多添加三级":"增加",onClick:C(O=>F(b),["stop"])},null,8,["disabled","icon","title","onClick"])):v("",!0),k(["menuManage:del"])?(d(),f(s,{key:1,type:"danger",text:"",icon:V(X),title:e.$t("delete"),onClick:C(O=>A(a,b),["stop"])},null,8,["icon","title","onClick"])):v("",!0),k(["menuManage:edit"])?(d(),f(s,{key:2,type:"primary",text:"",icon:V(Y),title:e.$t("edit"),onClick:C(O=>D(b),["stop"])},null,8,["icon","title","onClick"])):v("",!0)])])]),_:1},8,["data"]),g.value?(d(),f(s,{key:0,text:"",style:{"margin-top":"10px","margin-left":"20px"},onClick:t[0]||(t[0]=a=>F(""))},{default:o(()=>[w(y(e.$t("add_top_menu")),1)]),_:1})):v("",!0),n(z,{title:l.value.menu_name?e.$t("edit_menu"):e.$t("add_menu"),modelValue:p.value,"onUpdate:modelValue":t[6]||(t[6]=a=>p.value=a),width:"500px",class:"!rounded-lg","close-on-click-modal":!1,"close-on-press-escape":!1,onClose:E},{footer:o(()=>[M("span",ie,[n(s,{onClick:E},{default:o(()=>[w(y(e.$t("cancel")),1)]),_:1}),n(s,{type:"primary",onClick:t[5]||(t[5]=a=>J("menuFormRef"))},{default:o(()=>[w(y(e.$t("submit")),1)]),_:1})])]),default:o(()=>[n(P,{model:l.value,rules:q,ref_key:"menuFormRef",ref:U,"label-width":"100px"},{default:o(()=>[n(_,{label:e.$t("menu_title"),prop:"title"},{default:o(()=>[n(i,{modelValue:l.value.title,"onUpdate:modelValue":t[1]||(t[1]=a=>l.value.title=a)},null,8,["modelValue"])]),_:1},8,["label"]),n(_,{label:e.$t("menu_identifier"),prop:"identifier"},{default:o(()=>[n(i,{modelValue:l.value.identifier,"onUpdate:modelValue":t[2]||(t[2]=a=>l.value.identifier=a)},null,8,["modelValue"])]),_:1},8,["label"]),n(_,{label:e.$t("menu_auth_regular"),prop:"auth_regular"},{default:o(()=>[n(i,{modelValue:l.value.auth_regular,"onUpdate:modelValue":t[3]||(t[3]=a=>l.value.auth_regular=a),type:"textarea"},null,8,["modelValue"])]),_:1},8,["label"]),h.value!=="0"?(d(),f(_,{key:0,label:e.$t("menu_icon"),prop:"icon"},{default:o(()=>[n(G,{class:"site-logo",action:j.value,"show-file-list":!1,"on-success":a=>{l.value.icon=a.url},multiple:!1},{default:o(()=>[l.value.icon?(d(),R("img",{key:0,src:l.value.icon,class:"site-logo-img"},null,8,ue)):(d(),f(T,{key:1},{default:o(()=>[n(V(S))]),_:1}))]),_:1},8,["action","on-success"])]),_:1},8,["label"])):v("",!0),h.value!=="0"&&k(["UserMenu:get"])?(d(),f(_,{key:1,label:e.$t("menu_show_home"),prop:"show_home"},{default:o(()=>[n(L,{modelValue:l.value.show_home,"onUpdate:modelValue":t[4]||(t[4]=a=>l.value.show_home=a),"active-value":1,"inactive-value":2,onChange:I},null,8,["modelValue"])]),_:1},8,["label"])):v("",!0)]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])])}}}),pe=ee(re,[["__scopeId","data-v-82273c98"]]);export{pe as default};
