← Back
Editing: index191.js
import{c as e,r as a,g as s,p as l,q as r,v as d,e as o,A as t,x as i,F as u,a_ as m,M as n,B as p,Q as c,S as _,a9 as v,ai as f,aj as b,a7 as g}from"./base-lib.js?v=VERSION_NUMBER";import{x as w,K as h,M as j,k as V,c as x,e as y}from"./utils-lib.js?v=VERSION_NUMBER";import{_ as k}from"./index101.js?v=VERSION_NUMBER";import{g as q}from"./useStore2.js?v=VERSION_NUMBER";import{a as M,m as S}from"./useMethod4.js?v=VERSION_NUMBER";import{addModulesDatabase as A}from"./database.js?v=VERSION_NUMBER";import{_ as C}from"./index.vue_vue_type_script_setup_true_lang9.js?v=VERSION_NUMBER";import"./__commonjsHelpers__.js?v=VERSION_NUMBER";import"./column.js?v=VERSION_NUMBER";import"./index104.js?v=VERSION_NUMBER";import"./validator.js?v=VERSION_NUMBER";const U={class:"p-[24px]"},I=y(e({__name:"index",props:{compData:{default:()=>({options:[]})}},setup(e,{expose:y}){const I=e,{refs:{tabActive:D},refreshTableList:E}=q(),F=a(),L=a(!1),Q=a([]),B=s((()=>{var e,a;return(null==(a=null==(e=Q.value)?void 0:e.find((e=>e.id===H.value.sid)))?void 0:a.db_host)||""})),H=a({name:"",db_user:"",password:w(16),dataAccess:"127.0.0.1",address:"",codeing:"utf8mb4",dtype:"MySQL",ps:"",sid:0,listen_ip:"0.0.0.0/0",host:""}),K={name:[{required:!0,message:"请输入数据库名",trigger:["blur","change"]},{validator:(e,a,s)=>{/^\d/.test(a)&&s(new Error("数据库名不能以数字开头")),s()}}],db_user:[{required:!0,message:"请输入用户名",trigger:["blur","change"]}],password:[{required:!0,message:"请输入密码",trigger:["blur","change"]}]},R=e=>{H.value.db_user=e,H.value.ps=e},T=async()=>{try{L.value=!0;const{status:e,msg:a,err_msg:s}=await S(H.value.sid);if(!e)throw j.error(s),new Error("服务器连接失败");L.value=!1}catch(e){}};return l((async()=>{var e,a;Q.value=await(null==(e=I.compData)?void 0:e.refresh())||[],H.value.sid=null==(a=Q.value[0])?void 0:a.id})),y({onConfirm:async e=>{await F.value.validate(),await T();let a={...H.value,sid:String(H.value.sid)};await h({loading:"正在添加数据库, 请稍后...",request:A(a,D.value),message:!0}),E(),e()}}),(e,a)=>{const s=_,l=v,h=V,j=k,y=f,q=b,S=x,A=g;return r(),d("div",U,[o(A,{disabled:i(L),model:i(H),ref_key:"addFormRef",ref:F,rules:K,onSubmit:a[5]||(a[5]=c((()=>{}),["prevent"]))},{default:t((()=>[o(l,{label:"数据库名",prop:"name"},{default:t((()=>[o(s,{class:"w-[38rem]",ref:"data_name",placeholder:"新的数据库名称",modelValue:i(H).name,"onUpdate:modelValue":a[0]||(a[0]=e=>i(H).name=e),onInput:R},null,8,["modelValue"])])),_:1}),o(l,{label:"用户名",prop:"db_user"},{default:t((()=>[o(h,{width:"38rem",placeholder:"数据库用户",modelValue:i(H).db_user,"onUpdate:modelValue":a[1]||(a[1]=e=>i(H).db_user=e)},null,8,["modelValue"])])),_:1}),o(l,{label:"密码",prop:"password"},{default:t((()=>[o(j,{width:"38rem",icon:"el-refresh",modelValue:i(H).password,"onUpdate:modelValue":a[2]||(a[2]=e=>i(H).password=e),modelModifiers:{sync:!0},onIconClick:a[3]||(a[3]=()=>i(H).password=i(w)(16)),isActive:!0},null,8,["modelValue"])])),_:1}),o(l,{label:"添加至",prop:"sid",class:"!mb-0"},{default:t((()=>[o(q,{class:"!w-[24rem]",modelValue:i(H).sid,"onUpdate:modelValue":a[4]||(a[4]=e=>i(H).sid=e)},{default:t((()=>[(r(!0),d(u,null,m(i(Q),((e,a)=>(r(),n(y,{key:a,label:e.ps+(e.db_host?"("+e.db_host+")":""),value:e.id},null,8,["label","value"])))),128))])),_:1},8,["modelValue"]),o(S,{class:"ml-[8px]",onClick:i(M)},{default:t((()=>a[6]||(a[6]=[p("管理远程数据库")]))),_:1},8,["onClick"])])),_:1}),o(l,{label:" ",class:"!mb-0"},{default:t((()=>[o(C,{server:{sid:i(H).sid,ip:i(B)}},null,8,["server"])])),_:1})])),_:1},8,["disabled","model"])])}}}),[["__scopeId","data-v-293d7cff"]]);export{I as default};
Save File
Cancel