import{b as S,r as u,ah as w,cD as P,o as U,y as x,q as o,v as B,p as s,P as v,x as b,n as t,s as R,j as M,k as q,m as j,l as z,bv as A,D as G}from"./index.8d733f79.js";import{g as H,l as J,m as K}from"./faultType.8bb3732b.js";const L={class:"dialog-footer"},X={__name:"addFaultType",emits:["refresh"],setup(O,{expose:y,emit:h}){const{t:d}=S(),{proxy:p}=G(),i=u(""),c=u(""),n=u(!1),V=w({name:[{required:!0,message:d("faultTypeNameP"),trigger:"blur"}]}),I={checkStrictly:!0,emitPath:!1,value:"id",label:"label"},l=u({name:"",parentId:null}),f=u();function T(e,a){n.value=!0,c.value=e,i.value=d(e==="edit"?"edit":"add"),e==="edit"&&(l.value={id:a.id,name:a.label,parentId:a.parentId}),$()}const $=()=>{H().then(e=>{f.value=e.data})},F=()=>{console.log(222,l.value),p.$refs.formRef.validate(e=>{e&&(c.value==="add"?J:K)(l.value).then(m=>{p.$modal.msgSuccess(m.msg),h("refresh"),n.value=!1})})},k=()=>{n.value=!1},C=()=>{l.value={name:"",parentId:null},p.$refs.formRef.resetFields()};return y({showModal:T}),(e,a)=>{const m=M,_=q,D=P,E=j,g=z,N=A;return U(),x(N,{title:t(i),modelValue:t(n),"onUpdate:modelValue":a[2]||(a[2]=r=>R(n)?n.value=r:null),width:"400px","align-center":!0,onClosed:C},{footer:o(()=>[B("div",L,[s(g,{onClick:k},{default:o(()=>[v(b(e.$t("cancel")),1)]),_:1}),s(g,{type:"primary",onClick:F},{default:o(()=>[v(b(e.$t("confirm")),1)]),_:1})])]),default:o(()=>[s(E,{ref:"formRef",model:t(l),rules:t(V)},{default:o(()=>[s(_,{label:e.$t("faultTypeName"),prop:"name",style:{"margin-bottom":"24px"}},{default:o(()=>[s(m,{modelValue:t(l).name,"onUpdate:modelValue":a[0]||(a[0]=r=>t(l).name=r),placeholder:e.$t("faultTypeNameP"),maxlength:"20"},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(_,{label:e.$t("belongSuper"),prop:"parentId"},{default:o(()=>[s(D,{modelValue:t(l).parentId,"onUpdate:modelValue":a[1]||(a[1]=r=>t(l).parentId=r),options:t(f),props:I,separator:"-",clearable:"",filterable:"",placeholder:e.$t("belongSuperP"),style:{width:"242px"}},null,8,["modelValue","options","placeholder"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])}}};export{X as default};
