import{ab as e,I as a,al as t,M as o,j as s,k as l,h as n,e as r}from"./utils-lib.js?v=1761009159";import{c as i,h as c,r as m,o as p,B as d,k as u,l as g,e as f,x as v,p as h,y as b,C as _,D as y,F as L,q as w,N as D,v as x,az as j,n as V,ar as k,a7 as C,A as E,a4 as S}from"./base-lib.js?v=1761009159";import{b$ as q,c0 as T,c1 as I}from"./useStore4.js?v=1761009159";import{b as F,g as N}from"./column.js?v=1761009159";import"./__commonjsHelpers__.js?v=1761009159";import"./index104.js?v=1761009159";const U={class:"p-[1.6rem]"},R={class:"list-disc mt-[1.5rem] pl-[2rem]"},$={class:"p-[1.6rem]"},z={class:"pl-[2rem] list-disc text-[#ff0000] mt-[1.5rem]"},A=r(i({__name:"edit-group-popup",props:{compData:{default:()=>({})}},setup(r,{expose:i}){const A=r,{isEdit:B}=A.compData,H=c({name:"",interval:"",conList:[]}),M=c({show:!1}),G=c({loading:!1,list:[]}),J=e=>{let a=[{label:"容器名",prop:"name"},F({prop:"status",event:()=>{},data:["已停止","运行中"]})];return"sort"===e.type?[...a,N([{onClick:e.deleteConEvent,title:"移除"},{render:()=>j("i",{class:"svgtofont-icon-drag cursor-move mover align-middle",props:{title:"拖拽排序"}})}],{fixed:!1})]:[{type:"selection",selectable:a=>""===a.group||a.group===e.groupName,width:36},...a,{label:"分组",prop:"group",render:e=>j("span",{},e.group?"已在分组【".concat(e.group,"】内"):"--")}]},K=()=>{M.show=!0,Y(H.conList,!0)},O=J({type:"sort",deleteConEvent:e=>{H.conList=H.conList.filter((a=>a.name!==e.name)),Y(H.conList)}}),P=m(),Q=m(),W={name:[{trigger:["blur","change"],required:!0,message:"请输入组名"}],interval:[{validator:(e,a,t)=>{/^[1-9]\d*$/.test(a)||""===a?t():t(new Error("请输入正整数"))},trigger:"blur"}]},X=c({selectList:[]}),Y=(e,a)=>{X.selectList=e,!0===a&&V((()=>{X.selectList.map((e=>{const a=G.list.find((a=>a.name===e.name));if(a){const e=P.value.getTable();null==e||e.toggleRowSelection(a,!0)}}))}))},Z=()=>{const a=document.querySelector(".groupSortTable .el-table__body-wrapper tbody");e.create(a,{animation:500,onEnd:async e=>{const a=H.conList.splice(e.oldIndex,1)[0];H.conList.splice(e.newIndex,0,a)}})},ee=()=>{H.conList=X.selectList,M.show=!1,Z()},ae=J({type:"select",groupName:A.compData.group_name||""});return p((async()=>{await(async()=>{G.loading=!0,await a({request:q(),loading:k(G,"loading"),success:e=>{const a=t(e.data.data,"array",[]);G.list=a.sort(((e,a)=>""===e.group&&""!==a.group?-1:""!==e.group&&""===a.group?1:0))},error:e=>{o.error(e)}})})(),A.compData.isEdit&&(H.interval=A.compData.interval,H.name=A.compData.group_name,X.selectList=A.compData.order.map((e=>({name:e,group:A.compData.group_name}))),H.conList=A.compData.order.map((e=>G.list.find((a=>a.name===e))))),Z()})),i({onConfirm:async e=>{try{await Q.value.validate();let t={group_name:H.name,interval:H.interval,container_info:H.conList.map((e=>e.name)).join(",")};B&&(t.id=A.compData.id),await a({loading:"正在设置，请稍后...",message:!0,request:B?T(t):I(t),success:async({status:a})=>{a&&(e(),A.compData.refreshEvent&&A.compData.refreshEvent())}})}catch(t){}}}),(e,a)=>{const t=s,o=C,r=l,i=E,c=S,m=n,p=d("bt-loading");return u(),g("div",U,[f(c,{ref_key:"cmdFormRef",ref:Q,model:h(H),rules:W,onSubmit:a[2]||(a[2]=D((()=>{}),["prevent"]))},{default:v((()=>[f(o,{prop:"name",label:"组名",class:"min-w-[3rem]"},{default:v((()=>[f(t,{modelValue:h(H).name,"onUpdate:modelValue":a[0]||(a[0]=e=>h(H).name=e),width:"26rem",placeholder:"请输入组名"},null,8,["modelValue"])])),_:1}),f(o,{prop:"interval",label:"启动间隔"},{default:v((()=>[f(t,{modelValue:h(H).interval,"onUpdate:modelValue":a[1]||(a[1]=e=>h(H).interval=e),width:"26rem",type:"number",min:0,placeholder:"请输入启动间隔",textType:"秒"},{append:v((()=>a[4]||(a[4]=[b(" 秒 ")]))),_:1},8,["modelValue"])])),_:1}),f(o,{prop:"conList",label:"容器"},{default:v((()=>[_(f(r,{class:"groupSortTable","row-key":"name",column:h(O),"max-height":330,data:h(H).conList,description:"容器列表为空"},null,8,["column","data"]),[[y,h(H).conList.length],[p,h(G).loading],[p,"正在加载容器列表，请稍后...","title"]]),f(i,{class:L(h(H).conList.length?"!mt-[1rem]":""),type:"default",onClick:K},{default:v((()=>a[5]||(a[5]=[b(" 添加容器 ")]))),_:1},8,["class"])])),_:1}),w("ul",R,[w("li",null,[a[6]||(a[6]=b(" 启动顺序：从上到下。可拖拽排序。 ")),_(w("span",null,"【当前组容器为空】",512),[[y,!h(H).conList.length]])])])])),_:1},8,["model"]),f(m,{ref:"popup",title:"新增容器",area:62,modelValue:h(M).show,"onUpdate:modelValue":a[3]||(a[3]=e=>h(M).show=e),showFooter:"",onConfirm:ee},{default:v((()=>[w("div",$,[_(f(r,{column:h(ae),"max-height":330,ref_key:"sortTable",ref:P,"row-key":"name","reserve-selection":"",data:h(G).list,description:"容器列表为空",onSelectionChange:Y},null,8,["column","data"]),[[p,h(G).loading],[p,"正在加载容器列表，请稍后...","title"]]),w("ul",z,[w("li",null,"已选中："+x(h(X).selectList.length)+"个",1)])])])),_:1},8,["modelValue"])])}}}),[["__scopeId","data-v-e6dac9b4"]]);export{A as default};
