import{K as e,M as s,k4 as a,fq as o}from"./utils-lib.js?v=1761009159";import{c as l,aG as t,r as i,g as r,e as n,al as d,ak as p,C as u,v as m,x as _,y as c}from"./base-lib.js?v=1761009159";import{h as v,f}from"./form-item.js?v=1761009159";import{u as j}from"./index63.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index106.js?v=1761009159";import"./index105.js?v=1761009159";import"./column.js?v=1761009159";import"./useController6.js?v=1761009159";import"./site.js?v=1761009159";import"./validator.js?v=1761009159";import"./useStore4.js?v=1761009159";const g={class:"p-[2rem]"},w=l({__name:"add-slave-node",props:{compData:{default:()=>({group_id:"",nodes:[]})}},setup(l,{expose:w}){const{redisGroupDetail:b,isRedisRefreshList:h}=j(),x=t(),y=l,D=i(y.compData.nodes.map(e=>({label:"".concat(e.server_ip," - Redis ").concat(e.redis_version),value:e.id}))),{BtForm:R,submit:k}=e({data:{new_slave_node_id:[]},options:e=>r(()=>[v("选择节点",()=>n("div",{class:"w-full"},[n(d,{modelValue:e.value.new_slave_node_id,"onUpdate:modelValue":s=>e.value.new_slave_node_id=s,"popper-class":"slave-select-popper",placeholder:"请选择要添加的从节点"},{default:()=>n("div",null,[D.value.map(e=>n(p,{label:e.label,value:e.value},null))]),empty:()=>n("div",{style:"text-align: center;"},[u("暂无可用的Redis节点，"),n("span",{class:"bt-link",onClick:()=>{x&&"function"==typeof x.push?x.push({name:"node-mgt"}):window.location.href="/node/node-mgt"}},[u("去添加")])])})]),"new_slave_node_id",{rules:[{required:!0,message:"请选择要添加的从节点"}]}),f(" ",[{content:"只显示可用的Redis节点，已在复制组中的节点不会显示"}])]),submit:async(e,l,t)=>{let i=null;try{await l(),i=s.load("正在配置从节点信息，请稍后...");const{new_slave_node_id:t}=e.value,r=await a({group_id:y.compData.group_id,new_slave_node_id:t});if(r.status){const{data:e}=await o({group_id:y.compData.group_id});b.value.slave_details=e.data.slave_details,h.value=!0,s.success(r.msg||"添加从节点成功")}else s.error(r.msg||"添加从节点失败");return r.status}catch(r){return!1}finally{null==i||i.close()}}});return w({onConfirm:k}),(e,s)=>(m(),_("div",g,[n(c(R))]))}});export{w as default};
