import{K as a,c5 as e,ar as l,as as t}from"./utils-lib.js?v=1761009159";import{c as o,g as s,e as p,G as r,C as u,ay as d,aw as n,al as i,ak as m,q as c,a6 as _,v as b,x as v,y as f}from"./base-lib.js?v=1761009159";import{b as x,d as y,f as w}from"./index62.js?v=1761009159";import{b as h,i as j,F as g}from"./form-item.js?v=1761009159";import{c as C}from"./useController10.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index105.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./index219.js?v=1761009159";const k={class:"p-[2rem]"},N=o({__name:"index",setup(o,{expose:N}){const{isTcpudpClbEdit:T,addTcpudpNodeData:D,nodeClbTcpudpRefresh:F}=x(),{BtForm:P,submit:U}=a({data:y,options:a=>s(()=>[h("名称","ps",{attrs:{disabled:T.value,class:"!w-[320px]",placeholder:"请输入负载均衡名称"},rules:[e({message:"请输入负载均衡名称",trigger:["blur","change"]})]}),j("协议","type",[{label:"TCP",value:"tcp"},{label:"UDP",value:"udp"}]),j("监听地址","host",[{label:"127.0.0.1",value:"127.0.0.1"},{label:"0.0.0.0",value:"0.0.0.0"}]),h("监听端口","port",{attrs:{class:"!w-[320px]",placeholder:"请输入监听端口"},rules:[l({message:"请输入监听端口"})]}),h("超时时间（秒） ","proxy_timeout",{attrs:{class:"!w-[320px]",placeholder:"连接节点时的最大超时时间，默认8秒"}}),h("保持时间（秒）","proxy_connect_timeout",{attrs:{class:"!w-[320px]",placeholder:"连接成功后最长无操作时间，默认86400秒"}}),g(()=>p("div",null,[p("div",{class:"flex justify-between items-center mb-5"},[p(r,{type:"primary",onClick:w},{default:()=>[u("添加负载均衡节点")]})]),p(d,{data:D.value,"table-layout":"auto"},{default:()=>[p(n,{prop:"node_id",label:"负载均衡节点"},{default:({row:a})=>p("span",null,[a.host])}),p(n,{prop:"port",label:"端口"},null),p(n,{prop:"node_status",label:"节点状态"},{default:({row:a})=>p(i,{modelValue:a.node_status,"onUpdate:modelValue":e=>a.node_status=e,style:"width: 70px"},{default:()=>[p(m,{label:"参与",value:"online"},null),p(m,{label:"备份",value:"backup"},null),p(m,{label:"停用",value:"down"},null)]})}),p(n,{prop:"weight",label:"权重"},null),p(n,{prop:"max_fail",label:"阈值"},null),p(n,{prop:"fail_timeout",label:"恢复时间（秒）"},null),p(n,{prop:"ps",label:"备注","show-overflow-tooltip":!0,width:"120"},null),p(n,{label:"操作",width:"60"},{default:a=>p("span",{class:"bt-link",onClick:()=>{return e=a.$index,void D.value.splice(e,1);var e}},[u("删除")])})]})]))]),submit:async(a,e,l)=>{try{await e();const{name:l,proxy_connect_timeout:t,proxy_timeout:o,host:s,port:p,type:r,ps:u}=a.value,d=D.value||[];let n={name:l,ps:u,tcp_config:{type:r,host:s,port:Number(p),proxy_connect_timeout:Number(t),proxy_timeout:Number(o)},nodes:d};return T.value&&(n.load_id=a.value.load_id),await C({mod_name:"node",sub_mod_name:"load",def_name:T.value?"modify_tcp_load":"create_tcp_load",ws_callback:T.value?"modify_tcp_load":"create_tcp_load",data:{...n}}),F.value=!0,!0}catch(t){return!1}}});return N({onConfirm:U}),c(()=>{var a;D.value=t(null!=(a=y().nodes)?a:[])}),_(()=>{D.value=[]}),(a,e)=>(b(),v("div",k,[p(f(P))]))}});export{N as default};
