import{aU as w,Y as A,K as D,W as E}from"./index.17037962789732.js";import"./index.170379627897337.js";import"./index.170379627897315.js";import"./index.170379627897330.js";import{u as O}from"./instance.1703796278973.js";import{e as T}from"./eventsource.1703796278973.js";import{d as V,k as l,l as I,m as L,r as P,o as r,c as k,a as m,u as i,t as b,B as C,z as y,x,A as v,b as g}from"./vue.1703796278973.js";const z={style:{margin:"10px 0px 20px 0px","padding-right":"10px"}},F={key:0},K={key:1},M={key:0},R=V({__name:"index",props:{api:{type:String,default:""},type:{type:String,default:""},data:{type:Object,default:()=>[]}},emits:["close","save"],setup(a,{emit:h}){const f=a,s=l(0),u=l(0),n=l(!0),p=l(0),B=l({}),N=()=>{h("close"),h("save")},j=I(()=>u.value?((p.value+s.value)/u.value*100).toFixed(2):0),J=c=>{n.value=!0;let e=0,d=0;const t=new T.EventSourcePolyfill(c);B.value=t,t.onmessage=_=>{const o=JSON.parse(_.data);switch(f.type){case"active":o.success?(e+=o.total,s.value=e):(d+=o.total,p.value=d);break;case"sync":e+=o,s.value=e;break}s.value+p.value>=u.value&&setTimeout(()=>{t.close(),n.value=!1},500)},t.onerror=()=>{t.close(),n.value=!1},t.onopen=()=>{}};return L(()=>f.api,c=>{c&&O(f.data).then(e=>{e.status===200&&(u.value=e.result,J(c))})},{deep:!0,immediate:!0}),(c,e)=>{const d=w,t=P("AIcon"),_=A,o=D,S=E;return r(),k(S,{maskClosable:!1,width:"800px",visible:!0,title:a.type==="active"?"启用":"同步",closable:!1},{footer:m(()=>[i(n)?C("",!0):(r(),k(o,{key:0,type:"primary",onClick:N},{default:m(()=>[b("完成")]),_:1}))]),default:m(()=>[y("div",z,[i(n)?(r(),x("div",F,[y("div",null,v(a.type==="active"?"正在启用全部设备":"正在同步设备状态"),1),g(d,{percent:i(j)},null,8,["percent"])])):(r(),x("div",K,[y("p",null,v(a.type==="active"?"启用":"同步")+"成功："+v(i(s))+"条",1),a.type==="active"?(r(),x("p",M,[b("启用失败："+v(i(p))+"条",1),g(_,{title:"实例信息页面中的配置项未完善"},{default:m(()=>[g(t,{style:{"margin-left":"5px"},type:"QuestionCircleOutlined"})]),_:1})])):C("",!0)]))])]),_:1},8,["title"])}}});export{R as _};
