← Back
Editing: add-slave-node.js
import{G as e,M as s,ja as a,f3 as o}from"./utils-lib.js?v=1765440387";import{c as l,aE as t,r as i,g as r,e as n,ak as d,aj as p,B as u,q as m,v as _,x as c}from"./base-lib.js?v=1765440387";import{h as v,f}from"./form-item.js?v=1765440387";import{u as j}from"./index63.js?v=1765440387";import"./__commonjsHelpers__.js?v=1765440387";import"./index94.js?v=1765440387";import"./index93.js?v=1765440387";import"./column.js?v=1765440387";import"./useController6.js?v=1765440387";import"./site.js?v=1765440387";import"./validator.js?v=1765440387";import"./useStore3.js?v=1765440387";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};
Save File
Cancel