import{c as e,r as a,q as o,v as r,N as l,B as t,e as s,y as d,ab as p,T as m,a9 as i}from"./base-lib.js?v=1761009159";import{X as u,P as c,ax as _,k as n,$ as f}from"./utils-lib.js?v=1761009159";import{a$ as b,E as v}from"./firewall.js?v=1761009159";import{g as P,a as D}from"./useMethod6.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./useStore5.js?v=1761009159";import"./validator.js?v=1761009159";const w=e({__name:"add-port-transmit",props:{compData:{default:()=>{}}},setup(e,{expose:w}){const V=e,T=a(),g=a({protocol:V.compData.Protocol?V.compData.Protocol.toLowerCase():"tcp",s_ports:V.compData.S_Port?V.compData.S_Port:"",d_ports:V.compData.T_Port?V.compData.T_Port:"",d_address:V.compData.T_Address?V.compData.T_Address:"",id:V.compData.id?V.compData.id:"",brief:V.compData.brief?V.compData.brief:""}),h=[{content:"如果是本机端口转发，目标IP为：127.0.0.1"},{content:"如果目标IP不填写，默认则为本机端口转发!"}],j=[{label:"TCP",value:"tcp"},{label:"UDP",value:"udp"}],S=a(!!V.compData.id),y={s_ports:[{validator:(e,a,o)=>{a.length>0&&(u(a)||o(new Error("端口格式错误，可用范围：1-65535")),o()),o(new Error("请输入源端口"))},trigger:["blur","change"],required:!0}],d_ports:[{validator:(e,a,o)=>{a.length>0&&(u(a)||o(new Error("端口格式错误，可用范围：1-65535")),o()),o(new Error("请输入目标端口"))},trigger:["blur","change"],required:!0}]};return o(()=>{const e=V.compData;S.value=void 0!==e.id,g.value.protocol=e.Protocol?e.Protocol.toLowerCase():"tcp",g.value.s_ports=e.S_Port?e.S_Port:"",g.value.d_ports=e.T_Port?e.T_Port:"",g.value.d_address=e.T_Address?e.T_Address:"",g.value.id=e.id?e.id:""}),w({onConfirm:async e=>{await T.value.validate();const a={operation:"add",protocol:g.value.protocol,S_Port:g.value.s_ports,T_Port:g.value.d_ports,T_Address:g.value.d_address,brief:g.value.brief,id:g.value.id};S.value||delete a.id,""==a.T_Address&&(a.T_Address="127.0.0.1"),await c({loading:"正在设置端口转发，请稍后...",request:S.value?b({new_data:JSON.stringify(a),old_data:JSON.stringify(V.compData)}):v(a),message:!0}),V.compData.refreshFn(),e(),P(),D()}}),(e,a)=>{const o=_,u=p,c=n,b=m,v=f,P=i;return r(),l(P,{ref_key:"editIpRulesRef",ref:T,rules:y,model:d(g),class:"p-[2rem] addfrom"},{default:t(()=>[s(u,{label:"协议"},{default:t(()=>[s(o,{modelValue:d(g).protocol,"onUpdate:modelValue":a[0]||(a[0]=e=>d(g).protocol=e),options:j,class:"!w-[24rem]"},null,8,["modelValue"])]),_:1}),s(u,{label:"源端口",prop:"s_ports"},{default:t(()=>[s(c,{modelValue:d(g).s_ports,"onUpdate:modelValue":a[1]||(a[1]=e=>d(g).s_ports=e),type:"number",min:"1",max:"65535",width:"24rem",placeholder:"请输入源端口"},null,8,["modelValue"])]),_:1}),s(u,{label:"目标IP"},{default:t(()=>[s(c,{modelValue:d(g).d_address,"onUpdate:modelValue":a[2]||(a[2]=e=>d(g).d_address=e),width:"24rem",placeholder:"请输入目标IP地址",clearable:""},null,8,["modelValue"])]),_:1}),s(u,{label:"目标端口",prop:"d_ports"},{default:t(()=>[s(c,{modelValue:d(g).d_ports,"onUpdate:modelValue":a[3]||(a[3]=e=>d(g).d_ports=e),width:"24rem",placeholder:"请输入目标端口",clearable:""},null,8,["modelValue"])]),_:1}),s(u,{label:"备注"},{default:t(()=>[s(b,{modelValue:d(g).brief,"onUpdate:modelValue":a[4]||(a[4]=e=>d(g).brief=e),class:"!w-[24rem] special-input",placeholder:"可为空",clearable:""},null,8,["modelValue"])]),_:1}),s(v,{options:h,listStyle:"disc",class:"pl-[3.6rem] pt-[2rem]"})]),_:1},8,["model"])}}});export{w as default};
