import{d as L,r as c,a as P,o as z,f as $,i as n,w as o,k as _,l as f,p as i,v as r,h as y,y as H,j as M,L as O,a4 as x,ae as Q,af as W,m as b,E as C,K as X,_ as Y}from"./index-ByQGGPf6.js";import{g as Z,e as ee,a as le,d as te}from"./menus-DJ0yMdKe.js";const ae={class:"menus-container"},ne={class:"custom-tree-node"},oe=["src"],se={class:"dialog-footer"},ue=L({__name:"menuManage",setup(ie){const R=c("https://api.raycos.net/uploaders"),v=c([]),e=c({parent_id:0,menu_name:""}),S=P({title:[{required:!0,message:"请输入菜单标题！",trigger:"blur"}],identifier:[{required:!0,message:"请输入菜单标识！",trigger:"blur"}],auth_regular:[{required:!0,message:"请输入菜单权限！",trigger:"blur"}]}),m=c(!1),V=c(""),g=c(""),w=c({}),N=c(),U=()=>{m.value=!1,w.value={}},j=a=>{e.value.menu_name},E=a=>{a===""&&(g.value="0"),Object.assign(e,{parent_id:a?a.id:0}),V.value=a||{},m.value=!0},q=(a,l)=>{X.confirm("确定要删除这个菜单吗？如果有子菜单，子菜单也会被一并删除！","提示",{type:"warning"}).then(()=>{te(l.id).then(()=>{const s=a.parent,d=s.data.children||s.data,u=d.findIndex(p=>p.id===l.id);d.splice(u,1)})}).catch(()=>{})},A=a=>{Object.assign(e,JSON.parse(JSON.stringify(a))),w.value=e,g.value=a.parent_id,V.value=a,e.value.menu_name="编辑菜单",m.value=!0},D=a=>{N.value.validate(l=>{if(l){const{id:s}=e.value;s?ee(s,e.value).then(d=>{m.value=!1,C.success("保存成功！"),F()}):le(e.value).then(d=>{const u=V.value;e.value.parent_id===0?v.value.push(d):(u.children||(u.children=[]),u.children.push(d)),m.value=!1,C.success("保存成功！")})}else return C.error("表单填写有误，请检查！"),!1})},F=()=>{Z().then(a=>{v.value=a})},h=a=>!0;return z(()=>{F()}),(a,l)=>{const s=i("el-button"),d=i("el-tree"),u=i("el-input"),p=i("el-form-item"),I=i("el-icon"),J=i("el-upload"),T=i("el-switch"),G=i("el-form"),K=i("el-dialog");return r(),$("div",ae,[n(d,{data:v.value,"node-key":"identifier","expand-on-click-node":!0},{default:o(({node:t,data:k})=>[y("span",ne,[y("span",null,H(k.title),1),y("span",null,[h(["menuManage:add"])?(r(),_(s,{key:0,type:"primary",text:"",disabled:t.level===4,icon:M(O),title:t.level===4?"菜单最多添加三级":"增加",onClick:x(B=>E(k),["stop"])},null,8,["disabled","icon","title","onClick"])):f("",!0),h(["menuManage:del"])?(r(),_(s,{key:1,type:"danger",text:"",icon:M(Q),title:"删除",onClick:x(B=>q(t,k),["stop"])},null,8,["icon","onClick"])):f("",!0),h(["menuManage:edit"])?(r(),_(s,{key:2,type:"primary",text:"",icon:M(W),title:"编辑",onClick:x(B=>A(k),["stop"])},null,8,["icon","onClick"])):f("",!0)])])]),_:1},8,["data"]),v.value?(r(),_(s,{key:0,text:"",style:{"margin-top":"10px","margin-left":"20px"},onClick:l[0]||(l[0]=t=>E(""))},{default:o(()=>[b("添加顶级菜单")]),_:1})):f("",!0),n(K,{title:e.value.menu_name?"编辑菜单":"添加菜单",modelValue:m.value,"onUpdate:modelValue":l[6]||(l[6]=t=>m.value=t),width:"500px","close-on-click-modal":!1,"close-on-press-escape":!1,onClose:U},{footer:o(()=>[y("span",se,[n(s,{onClick:U},{default:o(()=>[b("取 消")]),_:1}),n(s,{type:"primary",onClick:l[5]||(l[5]=t=>D("menuFormRef"))},{default:o(()=>[b("确 定")]),_:1})])]),default:o(()=>[n(G,{model:e.value,rules:S,ref_key:"menuFormRef",ref:N,"label-width":"100px"},{default:o(()=>[n(p,{label:"菜单标题",prop:"title"},{default:o(()=>[n(u,{modelValue:e.value.title,"onUpdate:modelValue":l[1]||(l[1]=t=>e.value.title=t)},null,8,["modelValue"])]),_:1}),n(p,{label:"菜单标识",prop:"identifier"},{default:o(()=>[n(u,{modelValue:e.value.identifier,"onUpdate:modelValue":l[2]||(l[2]=t=>e.value.identifier=t)},null,8,["modelValue"])]),_:1}),n(p,{label:"菜单权限",prop:"auth_regular"},{default:o(()=>[n(u,{modelValue:e.value.auth_regular,"onUpdate:modelValue":l[3]||(l[3]=t=>e.value.auth_regular=t),type:"textarea"},null,8,["modelValue"])]),_:1}),g.value!=="0"?(r(),_(p,{key:0,label:"菜单图标",prop:"icon"},{default:o(()=>[n(J,{class:"site-logo",action:R.value,"show-file-list":!1,"on-success":t=>{e.value.icon=t.url},multiple:!1},{default:o(()=>[e.value.icon?(r(),$("img",{key:0,src:e.value.icon,class:"site-logo-img"},null,8,oe)):(r(),_(I,{key:1},{default:o(()=>[n(M(O))]),_:1}))]),_:1},8,["action","on-success"])]),_:1})):f("",!0),g.value!=="0"&&h(["UserMenu:get"])?(r(),_(p,{key:1,label:"首页显示",prop:"show_home"},{default:o(()=>[n(T,{modelValue:e.value.show_home,"onUpdate:modelValue":l[4]||(l[4]=t=>e.value.show_home=t),"active-value":1,"inactive-value":2,onChange:j},null,8,["modelValue"])]),_:1})):f("",!0)]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])])}}}),ce=Y(ue,[["__scopeId","data-v-82293124"]]);export{ce as default};
