import{b as B,r as m,ah as N,$ as L,n as l,o as p,c as f,v as s,x as d,p as C,q as W,O as D,y as x,t as b,aH as q,aI as F,F as j,A as P,S as V,ay as z,ak as H,G as O}from"./index.8d733f79.js";import{k as G}from"./deviceTree.170dfbd9.js";import{a as X}from"./dashboard.62cdb0f4.js";const J={key:0,class:"overlay"},K={class:"deviceData_wrap"},Q={style:{"border-bottom":"1px solid rgba(68,48,142,0.42)"}},R={class:"title"},U={class:"popContent"},Y={style:{"margin-top":"8px"}},Z={class:"dialogTabContainer"},tt={class:"tabWrap"},et={class:"tab-ul"},at=["onClick"],ot=s("div",{class:"dialogTabContent"},null,-1),rt={__name:"deviceDataDetail",setup(nt,{expose:w}){const{t:c,locale:st}=B(),_=m(!1),v=N({name:"",type:""}),g=m(),o=m([]),r=m(0),y=m(),I=t=>{if(!t){V.warning(c("noDevice"));return}r.value=0,o.value=[],_.value=!0,g.value=t,S()},S=()=>{G({deviceId:g.value}).then(t=>{t.data&&(v.name=t.data.name,v.type=t.data.deviceTypeName,Promise.all([M()]).then(n=>{console.log(n,o.value),o.value.length&&(z(()=>{const e=document.querySelector(".dialogTabContainer");r.value=(e.offsetWidth-1)/3,e.style.borderLeft="1px solid #2153A3"}),$(o.value[0]))}).catch(n=>{console.log(n)}))})},M=()=>new Promise((t,n)=>{X({deviceId:g.value}).then(e=>{var a;(a=e.data)!=null&&a.length&&(o.value=o.value.concat(e.data)),t(222)})}),$=t=>{y.value=t.tag,T(t)},T=t=>{if(!o.value.length)return;const n=document.querySelector(".dialogTabContent");let e="";t.tag==="EMAS"&&t.data.length&&t.data.forEach(a=>{e+=`
              <div class="p-name">${a.pointName}</div>
              <table class="p-table">
                <thead>
                  <tr>
                    <th>${c("name")}</th>
                    <th>${c("data")}</th>
                    <th>${c("unit")}</th>
                  </tr>
                </thead>
                <tbody>
                  ${a.metricList.map(i=>`
                      <tr>
                          <td>${i.name}</td>
                          <td>${i.value}</td>
                          <td>${i.unit}</td>
                      </tr>
                  `).join("")}
                </tbody>
              </table>
            `}),t.tag!=="EMAS"&&t.data.length&&(e+=`
              <table class="p-table">
                <thead>
                  <tr>
                    <th>${c("name")}</th>
                    <th>${c("data")}</th>
                    <th>${c("unit")}</th>
                    <th>${c("time")}</th>
                  </tr>
                </thead>
                <tbody>
                  ${t.data.map(a=>`
                      <tr>
                          <td>${a.name}</td>
                          <td>${a.value}</td>
                          <td>${a.unit}</td>
                          <td>${a.time}</td>
                      </tr>
                  `).join("")}
                </tbody>
              </table>
            `),n.innerHTML=e};let h=0;const A=()=>{h=Math.min(h+1,o.value.length-3),k()},E=()=>{h=Math.max(h-1,0),k()},k=()=>{let t=0;for(let e=0;e<h;e++)t-=r.value;const n=document.querySelector(".tabWrap");n.style.transform=`translateX(${t}px)`};return w({showModal:I}),(t,n)=>{const e=L("close"),a=H,i=O;return l(_)?(p(),f("div",J,[s("div",K,[s("div",Q,[s("div",R,d(t.$t("deviceData")),1),C(a,{color:"#C1D8F3",size:"18",onClick:n[0]||(n[0]=u=>_.value=!1),style:{float:"right","margin-top":"10px",cursor:"pointer"}},{default:W(()=>[C(e)]),_:1})]),s("div",U,[s("div",null,d(t.$t("deviceName"))+"\uFF1A"+d(l(v).name),1),s("div",Y,d(t.$t("deviceType"))+"\uFF1A"+d(l(v).type),1),s("div",{class:"popTab",style:D({"padding-bottom":l(y)!=="EMAS"?"16px":""})},[l(o).length>3?(p(),x(i,{key:0,onClick:E,class:"arrow",style:{"margin-right":"7px"},"icon-class":"my-arrow-l"})):b("",!0),s("div",Z,[q(s("div",tt,[s("div",et,[(p(!0),f(j,null,P(l(o),u=>(p(),f("div",{key:u.tag,class:"pop_tabItem",onClick:lt=>$(u),style:D({width:` ${l(r)}px`,background:u.tag===l(y)?"#008CFA":""})},d(u.tag),13,at))),128))])],512),[[F,l(r)]])]),l(o).length>3?(p(),x(i,{key:1,onClick:A,class:"arrow",style:{"margin-left":"7px"},"icon-class":"my-arrow-r"})):b("",!0)],4),ot])])])):b("",!0)}}};export{rt as default};
