import{B as P}from"./BasicSelect-C_uwzMkE.js";import{ad as d,d as R,bk as D,r as c,a4 as A,aw as O,c as p,o as i,t as h,l as n,w as t,j as u,D as S,c8 as j,p as f,aA as F,k as W,B as Z,U as z,cZ as H}from"./index-9PRMimni.js";import{_ as J}from"./FormItemGridItem-CDUF0EA0.js";import{_ as K}from"./RadioButton-oqN0Zkh5.js";function ue(){return d.Get("/app/menu/cascade")}function Q(){return d.Get("/app/menu/list")}function le(o){return d.Get(`/app/menu/${o}`)}function X(o){return d.Post("/app/menu",o)}function Y(o){return d.Put("/app/menu",o)}function oe(o){return d.Delete(`/app/menu/${o}`)}const se=R({__name:"MenuForm",props:{isShowSubmit:{type:Boolean,default:!1}},emits:["change"],setup(o,{expose:T,emit:U}){const N=U,w=D(),b=H(),_=c(null),m=c(!1),r=A(()=>+a.value?.menuType==1?"菜单":"按钮"),L=c([]),M=()=>({id:null,parentId:null,menuType:1,menuName:"",menuCode:"",menuNameEn:"",menuLink:null,status:1}),a=c(M()),x={menuName:{required:!0,message:`${r.value}中文名称不能为空`,trigger:"blur"},menuNameEn:{required:!0,message:`${r.value}英文名称不能为空`,trigger:"blur"},menuCode:{required:!0,message:`${r.value}编码不能为空`,trigger:"blur"},parentId:{required:!0,message:"上级菜单不能为空",trigger:"change",type:"number"},menuLink:{required:!0,message:"跳转链接不能为空",trigger:"change"}};function B(v){a.value=v,_.value?.restoreValidation()}function $(){m.value=!0,_.value.validate(v=>{v?(m.value=!1,b.error("请填写完整信息")):a.value.id?Y(a.value).then(()=>{m.value=!1,b.success("修改成功"),k(),N("change")}).catch(()=>{m.value=!1}):X(a.value).then(()=>{m.value=!1,b.success("添加成功"),k(),N("change")}).catch(()=>{m.value=!1})})}function k(){_.value.restoreValidation(),a.value=M()}async function q(){L.value=await Q()}return O(()=>{q()}),T({formSubmit:$,handleReset:k,setData:B}),(v,e)=>{const g=K,C=j,s=J,E=F,y=W,V=Z,I=z,G=h;return i(),p(G,{model:n(a),rules:x,"label-width":140,"require-mark-placement":"left",ref_key:"formRef",ref:_,"label-placement":"left"},{default:t(()=>[u(I,{cols:1,"x-gap":12},{default:t(()=>[u(s,{span:1,label:"类型",path:"menuType"},{default:t(()=>[u(C,{value:n(a).menuType,"onUpdate:value":e[0]||(e[0]=l=>n(a).menuType=l)},{default:t(()=>[(i(),p(g,{key:1,value:1},{default:t(()=>e[7]||(e[7]=[f("菜单")])),_:1})),(i(),p(g,{key:2,value:2},{default:t(()=>e[8]||(e[8]=[f("按钮")])),_:1}))]),_:1},8,["value"])]),_:1}),n(a).menuType===2?(i(),p(s,{key:0,label:"上级菜单",path:"parentId"},{default:t(()=>[u(E,{options:n(L),"label-field":n(w).getLocale==="en"?"menuNameEn":"menuName","value-field":"id",clearable:"",value:n(a).parentId,"onUpdate:value":e[1]||(e[1]=l=>n(a).parentId=l)},null,8,["options","label-field","value"])]),_:1})):S("",!0),u(s,{label:`${n(r)}中文名称`,path:"menuName"},{default:t(()=>[u(y,{value:n(a).menuName,"onUpdate:value":e[2]||(e[2]=l=>n(a).menuName=l)},null,8,["value"])]),_:1},8,["label"]),u(s,{label:`${n(r)}英文名称`,path:"menuNameEn"},{default:t(()=>[u(y,{value:n(a).menuNameEn,"onUpdate:value":e[3]||(e[3]=l=>n(a).menuNameEn=l)},null,8,["value"])]),_:1},8,["label"]),u(s,{label:`${n(r)}编码`,path:"menuCode"},{default:t(()=>[u(y,{value:n(a).menuCode,"onUpdate:value":e[4]||(e[4]=l=>n(a).menuCode=l)},null,8,["value"])]),_:1},8,["label"]),u(s,{label:"跳转链接",path:"menuLink"},{default:t(()=>[u(n(P),{value:n(a).menuLink,"onUpdate:value":e[5]||(e[5]=l=>n(a).menuLink=l),"cache-key":"app_module",block:""},null,8,["value"])]),_:1}),u(s,{label:`${n(r)}状态`,path:"status"},{default:t(()=>[u(C,{value:n(a).status,"onUpdate:value":e[6]||(e[6]=l=>n(a).status=l)},{default:t(()=>[(i(),p(g,{key:1,value:1},{default:t(()=>e[9]||(e[9]=[f("正常")])),_:1})),(i(),p(g,{key:0,value:0},{default:t(()=>e[10]||(e[10]=[f("停用")])),_:1}))]),_:1},8,["value"])]),_:1},8,["label"]),o.isShowSubmit?(i(),p(s,{key:1,class:"ml-[100px]"},{default:t(()=>[u(V,{type:"primary",loading:n(m),onClick:$},{default:t(()=>e[11]||(e[11]=[f("保存修改")])),_:1},8,["loading"])]),_:1})):S("",!0)]),_:1})]),_:1},8,["model"])}}});export{se as _,ue as a,oe as d,le as g};
