import{c as e,r as a,h as l,k as r,l as t,e as s,x as o,p as d,q as u,F as m,v as i,C as n,D as p,M as v,N as b,a7 as c,aj as g,a4 as f}from"./base-lib.js?v=1761009159";import{dq as V,M as _,I as w,j as h,a6 as y,e as x}from"./utils-lib.js?v=1761009159";import{g as U,bo as j}from"./useStore4.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const k={class:"p-[1.6rem]"},q={class:"ml-[1rem] text-[#20a53a] w-[16rem] select-none"},I={class:"flex items-center mb-[1.5rem]"},P={class:"flex items-center mb-[1.5rem]"},C=x(e({__name:"add-net-dialog",props:{compData:{default:()=>({})}},emits:["close"],setup(e,{expose:x,emit:C}){const N=C,S=a(!1),{refs:{isRefreshNetworkList:D}}=U(),F=l({name:"",driver:"bridge",options:"",subnet:"",gateway:"",iprange:"",labels:"",remark:"",subnet_v6:"",gateway_v6:""});a(!1);const M=a(),R=a(!1),E={name:[{required:!0,message:"请输入网络名",trigger:["blur"]}],subnet:[{required:!1,validator:(e,a,l)=>H(a,l,"请输入正确的ipv4子网"),trigger:["blur"]}],gateway:[{required:!1,validator:(e,a,l)=>H(a,l,"请输入正确的ipv4网关"),trigger:["blur"]}],iprange:[{required:!1,validator:(e,a,l)=>H(a,l,"请输入正确的IP范围"),trigger:["blur"]}]},H=(e,a,l)=>{""===e||V(e)?a():a(new Error(l))},J=[{label:"bridge",value:"bridge"},{label:"ipvlan",value:"ipvlan"},{label:"macvlan",value:"macvlan"},{label:"overlay",value:"overlay"}];return x({onConfirm:async e=>{try{if(R.value&&S){if(""===F.subnet_v6)return void _.error("请输入正确的ipv6子网");if(""===F.gateway_v6)return void _.error("请输入正确的ipv6网关")}else F.subnet_v6="",F.gateway_v6="";await M.value.validate(),w({request:j({data:JSON.stringify({...F,status:R.value?1:0})}),message:!0,loading:"正在设置网络...",success:({status:e})=>{e&&(D.value=!0,N("close"))}})}catch(a){console.log(a)}}}),(e,a)=>{const l=h,V=c,_=y,w=g,x=f;return r(),t("div",k,[s(x,{ref_key:"cmdFormRef",ref:M,model:d(F),rules:E,onSubmit:a[10]||(a[10]=b((()=>{}),["prevent"]))},{default:o((()=>[s(V,{prop:"name",label:"网络名"},{default:o((()=>[s(l,{modelValue:d(F).name,"onUpdate:modelValue":a[0]||(a[0]=e=>d(F).name=e),width:"40rem",placeholder:"请输入网络名"},null,8,["modelValue"])])),_:1}),u("div",{class:"flex items-center cursor-pointer pl-[10rem] my-[2rem] px-[2rem]",onClick:a[1]||(a[1]=e=>S.value=!d(S))},[u("i",{class:m(d(S)?"svgtofont-el-arrow-down":"svgtofont-el-arrow-right")},null,2),u("div",q,i("更多设置，".concat(d(S)?"点击收回":"点击查看")),1)]),n(s(V,{prop:"path",label:"设备"},{default:o((()=>[s(_,{modelValue:d(F).driver,"onUpdate:modelValue":a[2]||(a[2]=e=>d(F).driver=e),options:J,class:"!w-[40rem]"},null,8,["modelValue"])])),_:1},512),[[p,d(S)]]),n(u("div",I,[s(V,{prop:"subnet",class:"!mb-0",label:"ipv4子网"},{default:o((()=>[s(l,{modelValue:d(F).subnet,"onUpdate:modelValue":a[3]||(a[3]=e=>d(F).subnet=e),width:"15rem",placeholder:"例：124.42.0.0/16"},null,8,["modelValue"])])),_:1}),s(V,{id:"two",prop:"gateway",label:"ipv4网关",class:"!mb-[0rem]"},{default:o((()=>[s(l,{modelValue:d(F).gateway,"onUpdate:modelValue":a[4]||(a[4]=e=>d(F).gateway=e),width:"15rem",placeholder:"例：124.42.0.254"},null,8,["modelValue"])])),_:1})],512),[[p,d(S)]]),n(s(V,{prop:"iprange",label:"ipv4范围",class:"!mb-[1rem]"},{default:o((()=>[s(l,{modelValue:d(F).iprange,"onUpdate:modelValue":a[5]||(a[5]=e=>d(F).iprange=e),width:"40rem",placeholder:"例：124.42.0.0/24"},null,8,["modelValue"])])),_:1},512),[[p,d(S)]]),n(s(V,{label:"开启IPV6","label-width":"8rem"},{default:o((()=>[s(w,{modelValue:d(R),"onUpdate:modelValue":a[6]||(a[6]=e=>v(R)?R.value=e:null)},null,8,["modelValue"])])),_:1},512),[[p,d(S)]]),n(u("div",P,[s(V,{class:"!mb-0",label:"IPV6子网"},{default:o((()=>[s(l,{modelValue:d(F).subnet_v6,"onUpdate:modelValue":a[7]||(a[7]=e=>d(F).subnet_v6=e),width:"15rem",placeholder:"例：2001:db8::/48"},null,8,["modelValue"])])),_:1}),s(V,{label:"IPV6网关","label-width":"8rem",class:"!mb-[0rem]"},{default:o((()=>[s(l,{modelValue:d(F).gateway_v6,"onUpdate:modelValue":a[8]||(a[8]=e=>d(F).gateway_v6=e),width:"15rem",placeholder:"例：2001:db8::1"},null,8,["modelValue"])])),_:1})],512),[[p,d(R)&&d(S)]]),n(s(V,{prop:"path",label:"备注"},{default:o((()=>[s(l,{modelValue:d(F).remark,"onUpdate:modelValue":a[9]||(a[9]=e=>d(F).remark=e),type:"textarea",width:"40rem",placeholder:"备注"},null,8,["modelValue"])])),_:1},512),[[p,d(S)]])])),_:1},8,["model"])])}}}),[["__scopeId","data-v-98468a83"]]);export{C as default};
