import{c as a,r as e,V as s,g as l,q as r,v as t,x as d,e as o,B as u,y as i,F as m,b0 as n,N as p,C as _,R as c,T as v,ab as b,ak as f,al as g,a9 as j}from"./base-lib.js?v=1761009159";import{y as h,P as y,M as w,aK as x,e as V,_ as k}from"./utils-lib.js?v=1761009159";import{addModulesDatabase as C}from"./database.js?v=1761009159";import{g as q}from"./useStore2.js?v=1761009159";import{a as D,m as M}from"./useMethod4.js?v=1761009159";import{_ as A}from"./index.vue_vue_type_script_setup_true_lang9.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./column.js?v=1761009159";import"./index106.js?v=1761009159";import"./validator.js?v=1761009159";const F={class:"p-[24px]"},I=k(a({__name:"index",props:{compData:{default:()=>({options:[]})}},setup(a,{expose:k}){const I=a,{refs:{tabActive:R},refreshTableList:S}=q(),T=e(),U=s(!1),B=e({name:"",db_user:"",password:h(16),dataAccess:"127.0.0.1",address:"",codeing:"utf8mb4",dtype:"MongoDb",ps:"",sid:0,listen_ip:"0.0.0.0/0",host:""}),H=e([]),K={name:[{required:!0,message:"请输入数据库名",trigger:["blur","change"]}]},L=l(()=>{var a;return(null==(a=H.value.find(a=>a.id===B.value.sid))?void 0:a.db_host)||""}),N=a=>{B.value.db_user=a,B.value.ps=a},P=async()=>{try{U.value=!0;const{db_status:a,msg:e,err_msg:s}=await M(B.value.sid);return a?(U.value=!1,!0):(w.error(s||e),!1)}catch(a){x(a)}};return r(async()=>{var a,e;H.value=await(null==(a=I.compData)?void 0:a.refresh())||[],B.value.sid=null==(e=H.value[0])?void 0:e.id}),k({onConfirm:async a=>{await T.value.validate();if(!(await P()))return!1;await y({loading:"正在添加数据库, 请稍后...",request:C(B.value,R.value),message:!0,success:e=>{e.status&&(a(),S())}})}}),(a,e)=>{const s=v,l=b,r=f,h=g,y=V,w=j;return t(),d("div",F,[o(w,{disabled:i(U),model:i(B),ref_key:"addFormRef",ref:T,rules:K,onSubmit:e[2]||(e[2]=c(()=>{},["prevent"]))},{default:u(()=>[o(l,{label:"数据库名",prop:"name"},{default:u(()=>[o(s,{class:"w-[38rem]",ref:"data_name",placeholder:"新的数据库名称",modelValue:i(B).name,"onUpdate:modelValue":e[0]||(e[0]=a=>i(B).name=a),onInput:N},null,8,["modelValue"])]),_:1}),o(l,{label:"添加至",prop:"sid",class:"!mb-0"},{default:u(()=>[o(h,{class:"!w-[24rem]",modelValue:i(B).sid,"onUpdate:modelValue":e[1]||(e[1]=a=>i(B).sid=a)},{default:u(()=>[(t(!0),d(m,null,n(i(H),(a,e)=>(t(),p(r,{key:e,label:a.ps+(a.db_host?"（"+a.db_host+"）":""),value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),o(y,{class:"ml-[8px]",onClick:i(D)},{default:u(()=>e[3]||(e[3]=[_("管理远程数据库",-1)])),_:1,__:[3]},8,["onClick"])]),_:1}),o(l,{label:" ",class:"!mb-0"},{default:u(()=>[o(A,{server:{sid:i(B).sid,ip:i(L)}},null,8,["server"])]),_:1})]),_:1},8,["disabled","model"])])}}}),[["__scopeId","data-v-d25589f5"]]);export{I as default};
