import{P as a,M as e,l,k as s,j as t}from"./utils-lib.js?v=1761009159";import{c as n,r as d,e as o,C as u,q as i,H as r,v as p,x as m,I as f,y as c,B as b,z as v,Q as y,F as _,b0 as V,ab as q,al as k,a9 as j,N as w,ak as g}from"./base-lib.js?v=1761009159";import{getFtpInfo as x,getMysqlInfo as C,getSiteInfo as F,modifyFtpLink as U,modifyMysqlLink as h}from"./site.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";const P={class:"p-[20px]"},A=n({__name:"associated-database",setup(n){const A=d(!1),H=d(!1),T=d([]),z=d([]),B=d({pid:"",site:"",id:"",type:"mysql"}),I=d([{prop:"rname",label:"站点名称"},{label:"FTP用户",render:function(a){return o("div",null,[a.ftp.name?a.ftp.name:"--"," ",o("span",{class:"cursor-pointer bt-link",onClick:()=>{M(a,"ftp")}},[u("切换")])])}},{label:"数据库",render:function(a){return o("div",null,[a.mysql.name?a.mysql.name:"--"," ",o("span",{class:"cursor-pointer bt-link",onClick:()=>{M(a,"mysql")}},[u("切换")])])}}]),M=async(e,l)=>{B.value.type=l,await a({request:"ftp"===l?x():C(),data:[Array,T]}),B.value.pid=e[l].id,B.value.site=e.rname,A.value=!0,B.value.id=e.id},N=async()=>{a({loading:H,request:F(),data:[Array,z]})},Q=async()=>{const{type:l,pid:s,id:t}=B.value;if(!s)return void e.error("请选择用户");const n={["ftp"===l?"ftp_id":"sql_id"]:s,pid:t},d="ftp"===l?U:h;(await a({loading:"正在切换，请稍后...",request:d(n),message:!0})).status&&(A.value=!1,N())};return i(N),(a,e)=>{const n=l,d=s,u=q,i=g,x=k,C=j,F=t,U=r("bt-loading");return p(),m("div",null,[f(o(n,{"max-height":"560",column:c(I),data:c(z)},null,8,["column","data"]),[[U,c(H)]]),o(F,{title:"ftp"===c(B).type?"切换FTP用户":"切换数据库用户",modelValue:c(A),"onUpdate:modelValue":e[3]||(e[3]=a=>y(A)?A.value=a:null),area:42,"show-footer":"",onConfirm:Q},{default:b(()=>[v("div",P,[o(C,{modelValue:c(B),"onUpdate:modelValue":e[2]||(e[2]=a=>y(B)?B.value=a:null),ref:"websiteFormRef"},{default:b(()=>[o(u,{label:"站点名称"},{default:b(()=>[o(d,{class:"!w-[24rem]",disabled:"",modelValue:c(B).site,"onUpdate:modelValue":e[0]||(e[0]=a=>c(B).site=a)},null,8,["modelValue"])]),_:1}),o(u,{label:"ftp"===c(B).type?"ftp用户":"数据库用户",prop:"pid"},{default:b(()=>[o(x,{modelValue:c(B).pid,"onUpdate:modelValue":e[1]||(e[1]=a=>c(B).pid=a),class:"!w-[24rem]"},{default:b(()=>[(p(!0),m(_,null,V(c(T),(a,e)=>(p(),w(i,{key:e,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["modelValue"])])]),_:1},8,["title","modelValue"])])}}});export{A as default};
