import{_ as z}from"./index-49332ae1.js";import{Q as B}from"./index-626b746e.js";import{h as E}from"./index-33689e3e.js";import{d as N,y as V,b6 as O,a as u,f as L,e as o,b as i,m as f,ac as y,c as m,h as r,J as s,t as _,C as I,K as U,aq as A,O as S,_ as F,aF as G,aG as H,aH as J,av as K,aC as R}from"./index-3ac32eb9.js";import{_ as j}from"./_plugin-vue_export-helper-c27b6911.js";const W=N({__name:"MQOnlineMonitor",setup(X){const a=U({loading:!1,isSyncingStatus:!1,listData:[],paginationData:{total:0},queryParams:{currentPage:1,pageSize:10}}),{loading:w,isSyncingStatus:b,listData:v,paginationData:g}=A(a),p=a.queryParams;function h(e){return e?e==="connected"?"已连接":e==="disconnected"?"未连接":e:"--"}function x(e){const t=Number(e);return t===3?"MQTT 3.1":t===4?"MQTT 3.1.1":t===5?"MQTT 5.0":e??"--"}async function d(){a.loading=!0;try{const e={currentPage:a.queryParams.currentPage,pageSize:a.queryParams.pageSize},t=await B(e),c=t&&t.data||{};a.listData=c.list||[],a.paginationData.total=c.total||0}finally{a.loading=!1}}function P(e){a.queryParams.pageSize=e}async function T(){if(!a.isSyncingStatus){a.isSyncingStatus=!0;try{await E(),S.alert("设备状态已完成同步。","状态同步",{confirmButtonText:"确定"}),d()}catch{S.alert("设备状态同步失败，请稍后重试。","状态同步",{confirmButtonText:"确定"})}finally{a.isSyncingStatus=!1}}}return V(()=>{d()}),(e,t)=>{const c=F,l=G,M=H,C=J,D=z,Q=K,k=O("hasPerm"),q=R;return u(),L("div",null,[o(Q,{shadow:"always","body-style":{padding:"12px"}},{header:i(()=>[f("div",null,[t[4]||(t[4]=f("span",null,"MQTT 客户端在线列表",-1)),y((u(),m(c,{size:"small",type:"primary",text:"",loading:r(b),onClick:T,style:{"margin-left":"12px"}},{default:i(()=>[...t[2]||(t[2]=[s(" 状态同步 ",-1)])]),_:1},8,["loading"])),[[k,["sys:log:edit"]]]),o(c,{size:"small",type:"primary",text:"",onClick:d},{default:i(()=>[...t[3]||(t[3]=[s(" 刷新 ",-1)])]),_:1})])]),default:i(()=>[y((u(),m(C,{data:r(v),"show-overflow-tooltip":!0,border:"",stripe:"",style:{width:"100%","margin-top":"12px"}},{default:i(()=>[o(l,{label:"序号",type:"index",width:"60",align:"center"}),o(l,{prop:"client_id",label:"客户端Id","min-width":"220","show-overflow-tooltip":""}),o(l,{prop:"username",label:"用户名","min-width":"220","show-overflow-tooltip":""}),o(l,{prop:"keepalive",label:"保活时间",width:"100",align:"center"},{default:i(({row:n})=>[s(_(n.keepalive??"--"),1)]),_:1}),o(l,{prop:"conn_state",label:"连接状态",width:"120",align:"center"},{default:i(({row:n})=>[o(M,{type:n.conn_state==="connected"?"success":"info"},{default:i(()=>[s(_(h(n.conn_state)),1)]),_:2},1032,["type"])]),_:1}),o(l,{prop:"clean_start",label:"是否清除",width:"100",align:"center"},{default:i(({row:n})=>[s(_(n.clean_start?"是":"否"),1)]),_:1}),o(l,{prop:"proto_name",label:"协议名称",width:"120",align:"center"}),o(l,{prop:"proto_ver",label:"协议版本",width:"160",align:"center"},{default:i(({row:n})=>[s(_(x(n.proto_ver)),1)]),_:1})]),_:1},8,["data"])),[[q,r(w)]]),r(g).total>0?(u(),m(D,{key:0,total:r(g).total,page:r(p).currentPage,"onUpdate:page":t[0]||(t[0]=n=>r(p).currentPage=n),limit:r(p).pageSize,"onUpdate:limit":[t[1]||(t[1]=n=>r(p).pageSize=n),P],onPagination:d},null,8,["total","page","limit"])):I("",!0)]),_:1})])}}});const at=j(W,[["__scopeId","data-v-da80d454"]]);export{at as default};
