import{_ as a}from"./public.js?v=1764830988434";import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764830988434";import{k as s,P as t,a0 as o,r as l,e as r,R as d,V as p,W as n,a3 as u,a2 as _,an as b,S as i,U as c,a4 as m,N as v}from"./vue.js?v=1764830988434";import{aL as h,fB as x,fC as f,fD as w,di as D}from"./page_layout.js?v=1764830988434";import{v as g}from"./index264.js?v=1764830988434";import{dR as $,au as y,df as j}from"./naive.js?v=1764830988434";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"},N={key:0},B=s({__name:"form",props:{data:{}},setup(s,{expose:B}){const{t:L}=t(),M=s,{row:P,isEdit:S}=M.data,V=h(),{type:W}=o(V),z=l(null),A=r({db_host:"",db_port:null,db_user:"root",db_password:"",db_ps:""}),F={db_host:{trigger:["blur","change"],validator:(a,e)=>""===e?new Error(L("Database.tools.index_53")):!(!w(e)&&!D(e))||new Error(L("Database.tools.index_54"))},db_port:g(),db_user:{required:!0,message:L("Database.tools.index_55"),trigger:["blur","change"]},db_password:{required:!0,message:L("Database.tools.index_56"),trigger:["blur","change"]}},G=a=>{A.db_ps=a},H=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(S&&P)A.db_host="".concat(P.db_host),A.db_port=P.db_port,A.db_user="".concat(P.db_user),A.db_password="".concat(P.db_password),A.db_ps="".concat(P.ps);else{const a=H.get(W.value);a&&(A.db_port=a.port,A.db_user=a.username)}})(),B({onConfirm:async({hide:a})=>{var e;await(null==(e=z.value)?void 0:e.validate());const s=(()=>{const{db_port:a}=A;if(null===a)throw new Error(L("Database.tools.index_57"));return{...v(A),db_port:a,type:W.value}})();S&&P&&await x(W.value,{id:P.id,...s}),S||await f(W.value,s),V.getRemote(),a()}}),(s,t)=>{const o=y,l=$,r=j,v=e,h=a;return p(),d("div",k,[n(v,{ref_key:"formRef",ref:z,model:c(A),rules:F},{default:u(()=>[n(l,{label:s.$t("Database.tools.index_42"),path:"db_host"},{default:u(()=>[i("div",q,[n(o,{value:c(A).db_host,"onUpdate:value":[t[0]||(t[0]=a=>c(A).db_host=a),G],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(()=>[i("div",U,[n(r,{value:c(A).db_port,"onUpdate:value":t[1]||(t[1]=a=>c(A).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"!==c(W)?(p(),_(l,{key:0,label:s.$t("Database.index_13"),path:"db_user"},{default:u(()=>[i("div",E,[n(o,{value:c(A).db_user,"onUpdate:value":t[2]||(t[2]=a=>c(A).db_user=a),placeholder:s.$t("Database.tools.index_45"),"input-props":{name:"username"}},null,8,["value","placeholder"])])]),_:1},8,["label"])):b("",!0),n(l,{label:s.$t("Database.index_14"),path:"db_password"},{default:u(()=>[i("div",R,[n(o,{value:c(A).db_password,"onUpdate:value":t[3]||(t[3]=a=>c(A).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(()=>[i("div",C,[n(o,{value:c(A).db_ps,"onUpdate:value":t[4]||(t[4]=a=>c(A).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"===c(W)?(p(),d("li",N,m(s.$t("Database.tools.index_49")),1)):b("",!0),i("li",null,m(s.$t("Database.tools.index_50")),1),i("li",null,m(s.$t("Database.tools.index_51")),1),i("li",null,m(s.$t("Database.tools.index_52")),1)]),_:1})])}}});export{B as _};
