import{d as y,h as f,Y as L,r as a,o as m,f as p,w as o,b as t,H as N,a2 as x,l as V,E as U}from"./index.e3896b23.js";import{u as P,a as q}from"./metamodel.a560a346.js";const w=V("\u53D6\u6D88"),I=V("\u786E\u5B9A"),h=y({__name:"add-or-update",emits:["refreshDataList"],setup(M,{expose:c,emit:E}){const s=f(!1),i=f(),e=L({parentId:"",parentPath:"",path:"",name:"",code:"",ifLeaf:1,orderNo:0,description:""}),g=(r,l,d)=>{s.value=!0,e.id="",i.value&&i.value.resetFields(),e.parentId=l,e.parentPath=d,r&&v(r)},v=r=>{P(r).then(l=>{Object.assign(e,l.data)})},A=f({name:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],code:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],ifLeaf:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}],orderNo:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),_=()=>{i.value.validate(r=>{if(!r)return!1;e.ifLeaf=e.parentId==0?1:e.ifLeaf,q(e).then(()=>{U.success({message:"\u64CD\u4F5C\u6210\u529F",duration:500,onClose:()=>{s.value=!1,E("refreshDataList")}})})})};return c({init:g}),(r,l)=>{const d=a("el-input"),n=a("el-form-item"),F=a("el-option"),C=a("el-select"),D=a("el-input-number"),B=a("el-form"),b=a("el-button"),k=a("el-dialog");return m(),p(k,{modelValue:s.value,"onUpdate:modelValue":l[9]||(l[9]=u=>s.value=u),title:e.id?"\u4FEE\u6539":"\u65B0\u589E","close-on-click-modal":!1},{footer:o(()=>[t(b,{onClick:l[7]||(l[7]=u=>s.value=!1)},{default:o(()=>[w]),_:1}),t(b,{type:"primary",onClick:l[8]||(l[8]=u=>_())},{default:o(()=>[I]),_:1})]),default:o(()=>[t(B,{ref_key:"dataFormRef",ref:i,model:e,rules:A.value,"label-width":"100px",onKeyup:l[6]||(l[6]=x(u=>_(),["enter"]))},{default:o(()=>[t(n,{label:"\u7236\u7EA7\u76EE\u5F55",prop:"parentPath"},{default:o(()=>[t(d,{disabled:"",modelValue:e.parentPath,"onUpdate:modelValue":l[0]||(l[0]=u=>e.parentPath=u),placeholder:""},null,8,["modelValue"])]),_:1}),t(n,{label:"\u540D\u79F0",prop:"name"},{default:o(()=>[t(d,{modelValue:e.name,"onUpdate:modelValue":l[1]||(l[1]=u=>e.name=u),placeholder:"\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u7F16\u7801",prop:"code"},{default:o(()=>[t(d,{modelValue:e.code,"onUpdate:modelValue":l[2]||(l[2]=u=>e.code=u),placeholder:"\u7F16\u7801"},null,8,["modelValue"])]),_:1}),e.parentId!=0?(m(),p(n,{key:0,label:"\u7C7B\u578B",prop:"ifLeaf"},{default:o(()=>[t(C,{modelValue:e.ifLeaf,"onUpdate:modelValue":l[3]||(l[3]=u=>e.ifLeaf=u),placeholder:"\u7C7B\u578B",disabled:!!e.id},{default:o(()=>[(m(),p(F,{key:1,label:"\u76EE\u5F55",value:1})),(m(),p(F,{key:0,label:"\u5143\u6A21\u578B",value:0}))]),_:1},8,["modelValue","disabled"])]),_:1})):N("",!0),t(n,{label:"\u5E8F\u53F7",prop:"orderNo"},{default:o(()=>[t(D,{modelValue:e.orderNo,"onUpdate:modelValue":l[4]||(l[4]=u=>e.orderNo=u),max:9999,placeholder:"\u5E8F\u53F7"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u63CF\u8FF0",prop:"description"},{default:o(()=>[t(d,{type:"textarea",modelValue:e.description,"onUpdate:modelValue":l[5]||(l[5]=u=>e.description=u)},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});export{h as _};
