import{c as e,r as a,q as l,H as s,v as r,x as o,e as t,B as d,I as u,y as p,N as m,D as n,R as i,z as b,A as _,F as c,b0 as v,T as g,ab as f,a9 as w}from"./base-lib.js?v=1761009159";import{c8 as h,jA as y,k as V,P as q}from"./utils-lib.js?v=1761009159";import{addServer as j,addModulesServer as x,modifyServer as D,modifyModulesServer as k}from"./database.js?v=1761009159";import{g as U}from"./useStore2.js?v=1761009159";import{q as S}from"./useMethod4.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./validator.js?v=1761009159";const A={class:"p-[24px]"},E={class:"ml-20px mt-12px leading-8 text-small list-disc"},N={key:0},F={key:1},H=e({__name:"add-cloud-server",props:{compData:{default:()=>({row:{},refreshEvent:()=>{}})}},setup(e,{expose:H}){const{refs:{tabActive:I}}=U(),J=e,O=a(),z=a(!0),B={mysql:{port:3306,db_user:"root"},mongodb:{port:27017,db_user:"root"},sqlserver:{port:1433,db_user:"sa"},pgsql:{port:5432,db_user:"postgres"},redis:{port:6379,db_user:""}},C=a({db_host:"",db_port:B[I.value].port,db_user:B[I.value].db_user,db_password:"",ps:"",type:I.value}),M=[{content:"支持阿里云、腾讯云等云厂商的云数据库"},{content:"注意1：请确保本服务器有访问数据库的权限"},{content:"注意2：请确保填写的管理员帐号具备足够的权限"}],P={db_host:[{required:!0,message:"请输入服务器地址",trigger:["blur","change"]},{validator:(e,a,l)=>{(h(a)||y(a))&&""!==a||l(new Error("请输入正确的服务器地址")),l()},trigger:["blur","change"]}],db_password:[{required:!0,message:"请输入服务器密码",trigger:["blur","change"]}],db_user:[{required:!0,message:"请输入管理员名称",trigger:["blur","change"]}],db_port:[{required:!0,message:"请输入服务器端口",trigger:["blur","change"]}]},R=e=>{if(z.value&&J.compData.row)return z.value=!1;z.value=!1,C.value.ps=e};return l(()=>{var e;(null==(e=J.compData.row)?void 0:e.db_host)&&(C.value={...J.compData.row,type:I.value})}),H({onConfirm:async e=>{var a;(null==(a=J.compData.row)?void 0:a.db_host)?await(async()=>{await O.value.validate();let e={...C.value,db_ps:C.value.ps};"mysql"!==I.value&&(e.type=I.value),await q({loading:"正在修改远程服务器信息，请稍候...",request:"mysql"===I.value?D(e):k({data:JSON.stringify(e)},I.value),message:!0})})():await(async()=>{await O.value.validate();let e={...C.value,db_ps:C.value.ps};await q({loading:"正在添加远程服务器信息，请稍候...",request:"mysql"===I.value?j(e):x({data:JSON.stringify(e)},I.value),message:!0})})(),J.compData.refreshEvent(),e()}}),(e,a)=>{var l,h;const y=g,q=f,j=V,x=w,D=s("focus");return r(),o("div",A,[t(x,{model:p(C),rules:P,ref_key:"cloudForm",ref:O,onSubmit:a[5]||(a[5]=i(()=>{},["prevent"]))},{default:d(()=>[t(q,{label:"服务器地址",prop:"db_host"},{default:d(()=>[u(t(y,{class:"!w-[24rem]",placeholder:"请输入服务器地址",modelValue:p(C).db_host,"onUpdate:modelValue":a[0]||(a[0]=e=>p(C).db_host=e),onInput:R},null,8,["modelValue"]),[[D]])]),_:1}),t(q,{label:"数据库端口",prop:"db_port"},{default:d(()=>[t(j,{type:"number",class:"!w-[24rem]",modelValue:p(C).db_port,"onUpdate:modelValue":a[1]||(a[1]=e=>p(C).db_port=e)},null,8,["modelValue"])]),_:1}),"redis"!=p(I)?(r(),m(q,{key:0,label:"管理员名称",prop:"db_user"},{default:d(()=>[t(j,{modelValue:p(C).db_user,"onUpdate:modelValue":a[2]||(a[2]=e=>p(C).db_user=e),placeholder:"请输入管理员名称",class:"!w-[24rem]"},null,8,["modelValue"])]),_:1})):n("",!0),t(q,{label:"管理员密码",prop:"db_password"},{default:d(()=>[t(j,{modelValue:p(C).db_password,"onUpdate:modelValue":a[3]||(a[3]=e=>p(C).db_password=e),placeholder:"请输入管理员密码",class:"!w-[24rem]"},null,8,["modelValue"])]),_:1}),t(q,{label:"备注"},{default:d(()=>[t(j,{modelValue:p(C).ps,"onUpdate:modelValue":a[4]||(a[4]=e=>p(C).ps=e),placeholder:"服务器备注",class:"!w-[24rem]"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"]),b("ul",E,[(null==(l=p(S))?void 0:l.length)&&p(S)[0]?(r(),o("li",N,_(p(S)[0]),1)):n("",!0),(r(),o(c,null,v(M,(e,a)=>b("li",{key:a},_(e.content),1)),64)),(null==(h=p(S))?void 0:h.length)&&p(S)[1]?(r(),o("li",F,_(p(S)[1]),1)):n("",!0)])])}}});export{H as default};
