import{_ as a}from"./public.js?v=1763625242172";import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1763625242172";import{k as s,P as t,a0 as o,r as l,e as r,R as d,S as p,X as n,a3 as u,U as _,V as b,a2 as i,an as c,a4 as m,N as v}from"./vue.js?v=1763625242172";import{bn as h,fI as x,dM as f,fJ as w,fK as g}from"./page_layout.js?v=1763625242172";import{v as D}from"./index263.js?v=1763625242172";import{au as $,dP as y,df as j}from"./naive.js?v=1763625242172";const k={class:"p-20px"},q={class:"w-260px"},U={class:"w-260px"},E={class:"w-260px"},R={class:"w-260px"},C={class:"w-260px"},M={key:0},N=s({__name:"form",props:{data:{}},setup(s,{expose:N}){const{t:P}=t(),I=s,{row:J,isEdit:K}=I.data,S=h(),{type:V}=o(S),X=l(null),z=r({db_host:"",db_port:null,db_user:"root",db_password:"",db_ps:""}),A={db_host:{trigger:["blur","change"],validator:(a,e)=>""===e?new Error(P("Database.tools.index_53")):!(!x(e)&&!f(e))||new Error(P("Database.tools.index_54"))},db_port:D(),db_user:{required:!0,message:P("Database.tools.index_55"),trigger:["blur","change"]},db_password:{required:!0,message:P("Database.tools.index_56"),trigger:["blur","change"]}},B=a=>{z.db_ps=a},F=new Map([["mysql",{port:3306,username:"root"}],["sqlserver",{port:1433,username:"sa"}],["redis",{port:6379,username:"root"}],["mongodb",{port:27017,username:"root"}],["pgsql",{port:5432,username:"postgres"}]]);return(()=>{if(K&&J)z.db_host="".concat(J.db_host),z.db_port=J.db_port,z.db_user="".concat(J.db_user),z.db_password="".concat(J.db_password),z.db_ps="".concat(J.ps);else{const a=F.get(V.value);a&&(z.db_port=a.port,z.db_user=a.username)}})(),N({onConfirm:async({hide:a})=>{var e;await(null==(e=X.value)?void 0:e.validate());const s=(()=>{const{db_port:a}=z;if(null===a)throw new Error(P("Database.tools.index_57"));return{...v(z),db_port:a,type:V.value}})();K&&J&&await w(V.value,{id:J.id,...s}),K||await g(V.value,s),S.getRemote(),a()}}),(s,t)=>{const o=$,l=y,r=j,v=e,h=a;return d(),p("div",k,[n(v,{ref_key:"formRef",ref:X,model:b(z),rules:A},{default:u((()=>[n(l,{label:s.$t("Database.tools.index_42"),path:"db_host"},{default:u((()=>[_("div",q,[n(o,{value:b(z).db_host,"onUpdate:value":[t[0]||(t[0]=a=>b(z).db_host=a),B],placeholder:s.$t("Database.tools.index_43"),"input-props":{name:"host"}},null,8,["value","placeholder"])])])),_:1},8,["label"]),n(l,{label:s.$t("Docker.Container.create.index_7"),path:"db_port"},{default:u((()=>[_("div",U,[n(r,{value:b(z).db_port,"onUpdate:value":t[1]||(t[1]=a=>b(z).db_port=a),min:1,max:65535,"show-button":!1,"input-props":{name:"port"},placeholder:s.$t("Database.tools.index_44")},null,8,["value","placeholder"])])])),_:1},8,["label"]),"redis"!==b(V)?(d(),i(l,{key:0,label:s.$t("Database.index_13"),path:"db_user"},{default:u((()=>[_("div",E,[n(o,{value:b(z).db_user,"onUpdate:value":t[2]||(t[2]=a=>b(z).db_user=a),placeholder:s.$t("Database.tools.index_45"),"input-props":{name:"username"}},null,8,["value","placeholder"])])])),_:1},8,["label"])):c("",!0),n(l,{label:s.$t("Database.index_14"),path:"db_password"},{default:u((()=>[_("div",R,[n(o,{value:b(z).db_password,"onUpdate:value":t[3]||(t[3]=a=>b(z).db_password=a),placeholder:s.$t("Database.tools.index_46"),"input-props":{name:"password"}},null,8,["value","placeholder"])])])),_:1},8,["label"]),n(l,{label:"Notes",path:"db_ps","show-feedback":!1},{default:u((()=>[_("div",C,[n(o,{value:b(z).db_ps,"onUpdate:value":t[4]||(t[4]=a=>b(z).db_ps=a),placeholder:s.$t("Database.tools.index_48"),"input-props":{name:"ps"}},null,8,["value","placeholder"])])])),_:1})])),_:1},8,["model"]),n(h,{class:"mt-24px"},{default:u((()=>["mysql"===b(V)?(d(),p("li",M,m(s.$t("Database.tools.index_49")),1)):c("",!0),_("li",null,m(s.$t("Database.tools.index_50")),1),_("li",null,m(s.$t("Database.tools.index_51")),1),_("li",null,m(s.$t("Database.tools.index_52")),1)])),_:1})])}}});export{N as _};
