You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
4.4KB

  1. import{a as M,e as k,s as $}from"./menuManage-d68f1902.js";import{r as _,B,b as p,c as S,L as O,h as o,f as a,i as s,j,k as D,s as F}from"./index-dd5fae99.js";const I=D({name:"menuDialog"}),q=Object.assign(I,{props:{visible:{type:Boolean,default:!1,required:!0},data:Object},emits:["close"],setup(m,{emit:y}){const{proxy:V}=F(),r=m,f=y,v=_([]),c=_(),l=_({path:void 0,title:void 0,name:void 0,menuType:void 0,component:void 0,icon:void 0,sort:void 0,activeMenu:void 0,id:void 0,pid:void 0,hidden:void 0,isShowTag:void 0}),h=async i=>{i&&await i.validate(async e=>{var n,d;if(e){const u=l.value&&l.value.pid?b(l.value.pid,g(v.value)):l.value.path;r.data&&r.data.id?(await k({...l.value,pid:l.value.pid||void 0,sort:l.value.sort*1,topMenu:u,name:((n=l.value.path)==null?void 0:n.replace("/",""))||""}),V.$message.success("编辑成功!")):(await $({...l.value,name:((d=l.value.path)==null?void 0:d.replace("/",""))||"",pid:l.value.pid||void 0,sort:l.value.sort*1,topMenu:u,id:void 0}),V.$message.success("新增成功!")),f("close",!0)}})},b=(i,e)=>{var d;const n=(d=e.find(u=>u.id===i))==null?void 0:d.pid;if(n===void 0)return e.find(u=>u.id===i).path;b(n,e)},g=i=>{const e=[];return i.forEach(n=>{const d=JSON.parse(JSON.stringify(n));d.children&&delete d.children,e.push(d),n.children&&n.children.length&&e.push(...g(n.children))}),e};return B(()=>r.visible,async i=>{if(i){const e=await M();v.value=e.data,r.data&&r.data.id&&(l.value={...r.data,pid:r.data.pid===void 0?void 0:r.data.pid,children:void 0,isSelect:void 0})}else c.value.resetFields()}),(i,e)=>{const n=p("el-input"),d=p("el-form-item"),u=p("el-radio"),w=p("el-radio-group"),T=p("el-input-number"),N=p("el-tree-select"),C=p("el-form"),x=p("el-button"),U=p("el-dialog");return S(),O(U,{"model-value":m.visible,title:`${m.data&&m.data.id?"编辑":"新增"}菜单`,width:"600px","destroy-on-close":"",onClose:e[12]||(e[12]=t=>f("close"))},{footer:o(()=>[a(x,{type:"primary",onClick:e[10]||(e[10]=t=>h(c.value))},{default:o(()=>e[19]||(e[19]=[s(" 提交 ")])),_:1}),a(x,{onClick:e[11]||(e[11]=t=>f("close"))},{default:o(()=>e[20]||(e[20]=[s(" 关闭 ")])),_:1})]),default:o(()=>[a(C,{ref_key:"formRef",ref:c,model:l.value,"label-width":"100px","label-suffix":":"},{default:o(()=>[a(d,{label:"菜单名称",prop:"title"},{default:o(()=>[a(n,{modelValue:l.value.title,"onUpdate:modelValue":e[0]||(e[0]=t=>l.value.title=t),placeholder:"请输入",maxlength:50},null,8,["modelValue"])]),_:1}),a(d,{label:"菜单类型",prop:"menuType"},{default:o(()=>[a(w,{modelValue:l.value.menuType,"onUpdate:modelValue":e[1]||(e[1]=t=>l.value.menuType=t)},{default:o(()=>[a(u,{label:"MENU"},{default:o(()=>e[13]||(e[13]=[s("菜单")])),_:1}),a(u,{label:"BUTTON"},{default:o(()=>e[14]||(e[14]=[s("按钮")])),_:1})]),_:1},8,["modelValue"])]),_:1}),a(d,{label:"页面路径",prop:"path"},{default:o(()=>[a(n,{modelValue:l.value.path,"onUpdate:modelValue":e[2]||(e[2]=t=>l.value.path=t),placeholder:"请输入",maxlength:100},null,8,["modelValue"])]),_:1}),a(d,{label:"component",prop:"component"},{default:o(()=>[a(n,{modelValue:l.value.component,"onUpdate:modelValue":e[3]||(e[3]=t=>l.value.component=t),placeholder:"请输入"},null,8,["modelValue"])]),_:1}),a(d,{label:"图标",prop:"icon"},{default:o(()=>[a(n,{modelValue:l.value.icon,"onUpdate:modelValue":e[4]||(e[4]=t=>l.value.icon=t),placeholder:"请输入"},null,8,["modelValue"])]),_:1}),a(d,{label:"activeMenu",prop:"activeMenu"},{default:o(()=>[a(n,{modelValue:l.value.activeMenu,"onUpdate:modelValue":e[5]||(e[5]=t=>l.value.activeMenu=t),placeholder:"请输入"},null,8,["modelValue"])]),_:1}),a(d,{label:"菜单排序",prop:"sort"},{default:o(()=>[a(T,{modelValue:l.value.sort,"onUpdate:modelValue":e[6]||(e[6]=t=>l.value.sort=t),placeholder:"请输入",min:1},null,8,["modelValue"])]),_:1}),a(d,{label:"上级菜单",prop:"pid"},{default:o(()=>[a(N,{modelValue:l.value.pid,"onUpdate:modelValue":e[7]||(e[7]=t=>l.value.pid=t),data:v.value,props:{label:"title",value:"id"},"check-strictly":"","render-after-expand":!1,class:"w-full"},null,8,["modelValue","data"])]),_:1}),a(d,{label:"是否隐藏",prop:"hidden"},{default:o(()=>[a(w,{modelValue:l.value.hidden,"onUpdate:modelValue":e[8]||(e[8]=t=>l.value.hidden=t)},{default:o(()=>[a(u,{label:1},{default:o(()=>e[15]||(e[15]=[s("是")])),_:1}),a(u,{label:2},{default:o(()=>e[16]||(e[16]=[s("否")])),_:1})]),_:1},8,["modelValue"])]),_:1}),j("",!0)]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}});export{q as default};