import{_ as ee,a5 as te,b as oe,r as D,w as ae,e as re,aA as ie,ek as le,S as y,o as ne,c as se,O as de,n as L,D as ce,J as A}from"./index.8d733f79.js";import{d as pe,o as ue,p as me,q as ge,r as fe,s as he}from"./dashboard.62cdb0f4.js";const ve=te({name:"Devicecare"}),ye=Object.assign(ve,{props:{factoryId:{type:String,default:""}},setup(N,{expose:B}){const c=N,{t:i}=oe(),O="./",{proxy:l}=ce();let o=null,n=null;const j=e=>{var t;return(t=A.session.getJSON("enums").alarmLevel.find(r=>+r.key===e))==null?void 0:t.desc},P=e=>{var t;return(t=A.session.getJSON("enums").faultLevel.find(r=>+r.key===e))==null?void 0:t.desc},g=D([]);let p=null,u=null;const k=D(null);let b=null,_={},d=[],M=null,v=0;const f={};let m,w,h=null;const T=e=>{if(e.target.classList.contains("pop_arrow_r")&&(v=Math.min(v+1,d.length-3),x()),e.target.classList.contains("pop_arrow_l")&&(v=Math.max(v-1,0),x()),e.target.classList.contains("pop_tabItem")){document.querySelectorAll(".pop_tabItem").forEach(a=>a.classList.remove("pop_tabItem_active")),e.target.classList.add("pop_tabItem_active");const t=e.target.getAttribute("data-tab"),r=d.find(a=>a.tag===t);V(r)}};ae(()=>c.factoryId,(e,t)=>{e&&(o&&(o.destroy(),o=null),p&&(clearInterval(p),p=null),setTimeout(()=>{E()},0))},{immediate:!0,deep:!0}),re(()=>{h=document.getElementById("dashboard_factory"),h&&h.addEventListener("click",T)});const x=()=>{let e=0;for(let r=0;r<v;r++)e-=M;const t=document.querySelector(".tabWrap");t.style.transform=`translateX(${e}px)`};ie(()=>{p&&(clearInterval(p),p=null),m&&(clearTimeout(m),m=null),h&&(h.removeEventListener("click",T),h=null),o&&o.destroy(),u=null});function E(){!c.factoryId||(k.value=null,pe({buildId:c.factoryId}).then(e=>{e.data?q():J()}))}function J(){le({factoryId:c.factoryId}).then(e=>{e.data&&(k.value=`${O}/equipment-web/file/downloadImage?fileId=${e.data}`)})}function q(){o=new jsmap.JSMap({container:"factoryDashboardMap",mapServerURL:"./loadMap/factory",showGlobe:!0,showLoading:!1}),o.openMapById(c.factoryId),o.on("loadComplete",()=>{console.log("Map loadComplete!",o,o.focusFloorId),w=new jsmap.JSAttributeQuery(o),u=null,o.removeAllBoxMarker(),o.removeAllDomMarker(),o.removeAllImageMarker(),o.removeAllIconTextMarker(),S(),p=setInterval(()=>{S()},10*60*1e3)}),o.on("mapClickNode",e=>{const t=Object.fromEntries(e.properties);if(e.properties){const r=e.properties.get("markerType");if(r==="orgIcon"){u&&(u.show=!0),u=e.markers[0],e.markers[0].show=!1,o.removeAllBoxMarker(),o.removeAllDomMarker(),o.removeAllImageMarker(),X(t);for(let a=0;a<t.railList.length;a++)t.railList[a].x=Number(t.railList[a].x),t.railList[a].y=Number(t.railList[a].y);Q(t)}else r==="deviceIcon"&&Y(t);e.properties&&e.properties.get("name")&&(m&&(clearTimeout(m),m=null),m=setTimeout(()=>{const a=e.properties.get("name");_={x:e.x,y:e.y,z:e.z},R(a)},500))}})}const F=e=>{const r=w.query({markerType:[jsmap.JSMarkerType.TILE],propertiesFilter:a=>{if(a.has("name")){const s=`${a.get("name")}`;return s!==void 0&&s!==""&&s.indexOf(e)!==-1}else return!1}}).map(a=>a._properties.get("name"));return[...new Set(r)]},H={matteColor:"rgba(255,255,255,0.1)",visibleColor:"rgb(255,255,0)",highlight:!1,matteEffect:!0},C=()=>{o.setMapTileOnlyVisibleByFilter({visible:!0},H),o.showGlobe=!0,o.showBuildingMarker=!0,o.removeAllImageMarker(),o.removeAllDomMarker()};B({handleHighlightMarker:e=>{if(console.log("\u67E5\u8BE2\u7684\u8BBE\u5907\u7F16\u7801",e),!e){C();return}const t=w.query({markerType:[jsmap.JSMarkerType.TILE],propertiesFilter:r=>{if(r.has("name")){const a=`${r.get("name")}`;return a!==void 0&&a!==""&&a===e}else return!1}});if(!t.length){C(),y.error(i("modelCodeNotFound"));return}t.length>0&&(o.flyToMarker(t[0]),o.setMapTileOnlyVisibleByFilter({filter:r=>r.has("id")?r.get("id")===t[0].getProperties().get("id"):!1},{matteColor:"rgba(255,255,255,0.03)",visibleColor:"rgb(255,255,255)",highlight:!0,matteEffect:!0}),o.showGlobe=!1,o.backgroundColor="#262626",o.showBuildingMarker=!1)},getMapModelCode:F});const R=e=>{d=[],ue({deviceMapCode:e,factoryId:c.factoryId}).then(t=>{t.data&&(f.name=t.data.name,f.type=t.data.deviceTypeName,f.id=t.data.id,Promise.all([W(e),z(e)]).then(r=>{console.log(r,d),U()}).catch(r=>{console.log(r)}))})},W=e=>new Promise((t,r)=>{me({deviceCode:e,factoryId:c.factoryId}).then(a=>{var s;(s=a.data)!=null&&s.length&&(d=d.concat(a.data)),t(222)})});let I;const z=e=>new Promise((t,r)=>{ge({modelCode:e,factoryId:c.factoryId}).then(a=>{I=a.data||"",t(333)})}),U=()=>{b&&(o.removeAllDomMarker(),b=null),b=new jsmap.JSDomMarker({id:"devicePop",position:_,floorId:1,depthTest:!0,displayCondition:new jsmap.JSDisplayCondition(0,1e5),alwaysShow:!0,content:`<div class="factoryPopContainer">
                <div class="popTitle">
                  <div class="df">
                    <span>${i("deviceData")}</span> 
                    <div class="linkText" id="deviceLink">${i("detail")}</div>
                    ${I?'<div class="linkText" id="otherLink">\u8BBE\u5907\u7BA1\u7406\u5E73\u53F0</div>':""}
                  </div>
                  <img src="/imgs/close.png" class="popClose" id="closePop"/>
                </div>
                <div class="popContent">
                  <div>${i("deviceName")}\uFF1A${f.name}</div>
                  <div style="margin-top:8px">${i("deviceType")}\uFF1A${f.type}</div>
                  <div class="popTab">
                    ${d.length>3?'<div class="arrow pop_arrow_l" style="margin-right: 7px"><</div>':""}
                    <div class="tabContainer"></div>
                    ${d.length>3?'<div class="arrow pop_arrow_r" style="margin-left: 7px">></div>':""}
                  </div>
                  <div class="popTabContent"></div>
                </div>
              </div>`,callback:e=>{if(d.length){const t=document.querySelector(".tabContainer");M=(t.offsetWidth-2)/3;const r=`<div class="tabWrap">
                        <div class="tab-ul">
                          ${d.map(a=>`
                            <div class="pop_tabItem" data-tab='${a.tag}' style="width: ${M}px">${a.tag}</div>
                          `).join("")}
                        </div>
                      </div>`;t.innerHTML=r,setTimeout(()=>{$(".pop_tabItem")[0].click()},100)}else $(".tabContainer")[0].style.border="none",$(".factoryPopContainer")[0].style.height="200px";$("#closePop").click(()=>{o.removeAllDomMarker()}),$("#deviceLink").click(()=>{l.$router.hasRoute("deviceBoard")?l.$router.push({path:"/dashboard/device",query:{deviceId:f.id,path:l.$route.path,factoryId:c.factoryId,isMenu:l.$route.query.isMenu,isShowBoard:l.$route.query.isShowBoard}}):l.$modal.msgError(i("noDeviceAuth"))}),I&&$("#otherLink").click(()=>{window.open(I,"_blank")})}}),o.addMarker(b)},V=e=>{if(!d.length)return;const t=document.querySelector(".popTabContent");let r="";e.tag==="EMAS"&&e.data.length&&e.data.forEach(a=>{r+=`
              <div class="p-name">${a.pointName}</div>
              <table class="p-table">
                <thead>
                  <tr>
                    <th>${i("name")}</th>
                    <th>${i("data")}</th>
                    <th>${i("unit")}</th>
                  </tr>
                </thead>
                <tbody>
                  ${a.metricList.map(s=>`
                      <tr>
                          <td>${s.name}</td>
                          <td>${s.value}</td>
                          <td>${s.unit}</td>
                      </tr>
                  `).join("")}
                </tbody>
              </table>
            `}),e.tag!=="EMAS"&&e.data.length&&(r+=`
              <table class="p-table">
                <thead>
                  <tr>
                    <th>${i("name")}</th>
                    <th>${i("data")}</th>
                    <th>${i("unit")}</th>
                    <th>${i("time")}</th>
                  </tr>
                </thead>
                <tbody>
                  ${e.data.map(a=>`
                      <tr>
                          <td>${a.name}</td>
                          <td>${a.value}</td>
                          <td>${a.unit}</td>
                          <td>${a.time}</td>
                      </tr>
                  `).join("")}
                </tbody>
              </table>
            `),t.innerHTML=r};function S(){fe({factoryId:c.factoryId}).then(e=>{if(u=null,e.data&&e.data.length)for(let t=0;t<e.data.length;t++)e.data[t].regionInfo&&e.data[t].regionInfo.icon&&e.data[t].regionInfo.icon.x&&G({...e.data[t].regionInfo,name:e.data[t].name,orgId:e.data[t].id})}).catch(()=>{})}function G(e){const t=new jsmap.JSIconTextMarker({id:"iconTextTest",position:{x:Number(e.icon.x),y:Number(e.icon.y),z:0},floorId:1,image:"/imgs/org.png",text:e.name,font:"bold 14px sans-serif",fontColor:"#00C5FF",imageHeight:60,imageWidth:36,fontStrokeColor:"rgba(0,10,18,0.55)",backgroundColor:"rgba(0,0,0,0)",backgroundRadius:1,backgroundStrokeWidth:1,iconTextType:jsmap.JSIconTextType.TOPTEXT_BOTTOMICON,allowPicking:!0,depthTest:!1,alwaysShow:!0,offset:jsmap.JSControlPosition.CENTER_BOTTOM,show:!0,properties:{...e,markerType:"orgIcon"},callback:r=>{console.log(r)}});o.addMarker(t)}function Q(e){const t=new jsmap.JSBoxMarker({position:e.railList,floorId:1,color:"rgba(129,212,250,0.5)",height:1,stretchHeight:Number(e.height||12),allowPicking:!1,displayCondition:new jsmap.JSDisplayCondition(0,1e5),depthTest:!1,alwaysShow:!0,show:!0,callback:r=>{console.log(r)}});o.addMarker(t)}function X(e){he({orgId:e.orgId}).then(t=>{g.value=t.data.deviceList,Z(e,t.data)}).catch(()=>{})}function Z(e,t){n&&(o.removeMarker(n),n=null),n=new jsmap.JSDomMarker({id:`pop_${e.orgId}`,position:{x:Number(e.railList[0].x),y:Number(e.railList[0].y),z:Number(e.height||12)},floorId:1,depthTest:!0,displayCondition:new jsmap.JSDisplayCondition(0,1e5),alwaysShow:!0,content:`<div class="factoryPopContent" id="alarmContent_pop">
                <div class="pop" style="background-image: url(/imgs/popCard.png);height:200px;line-height:24px">
                  <div class="popTitle" style="padding-top:2px" title="${e.name}">
                    ${e.name}
                    <img src="/imgs/close.png" class="popClose_normal" id="close_org"/>
                  </div>
                  <div style="margin-top:10px">${i("deviceNum")}\uFF1A${t.total||0}</div>
                  <div >${i("defectDeviceNum")}\uFF1A${t.defectNum||0}</div>
                  <div >${i("alarmDeviceNum")}\uFF1A${t.alarmNum||0}</div>
                  <div >${i("normalDeviceNum")}\uFF1A${t.normalNum||0}</div>
                  <div class="linkText_org" id="deviceLink">${i("viewDevicePoint")}</div>
                  <div class="linkText_org" id="orgLink">${i("pLineDetail")}</div>
                </div>
                <div class="bottom_line"></div>
						  </div>`,marginOffset:{x:0,y:-80},callback:r=>{$("#close_org").click(()=>{o.removeMarker(n),o.removeAllDomMarker(),o.removeAllBoxMarker(),g.value=[],u.show=!0}),$("#deviceLink").click(()=>{if(!g.value||!g.value.length){y.error(i("orgNoSensorLink"));return}o.removeAllDomMarker();for(let a=0;a<g.value.length;a++){const s=g.value[a];K(s)}}),$("#orgLink").click(()=>{l.$router.hasRoute("orgBoard")?l.$router.push({path:"/dashboard/org",query:{orgId:e.orgId,isMenu:l.$route.query.isMenu,isShowBoard:l.$route.query.isShowBoard}}):y.error(i("noOrgAuth"))})}}),o.addMarker(n)}function K(e){const t=new jsmap.JSImageMarker({id:e.deviceId,image:`/imgs/${e.status}Point.png`,position:new jsmap.JSPoint(Number(e.xcoordinate),Number(e.ycoordinate),0),width:32,height:16,floorId:Number(e.floor),offset:jsmap.JSControlPosition.CENTER_TOP,depthTest:!1,show:!0,allowPicking:!0,displayCondition:new jsmap.JSDisplayCondition(0,1e3),properties:{...e,markerType:"deviceIcon"},alwaysShow:!0,callback:()=>{}});o.addMarker(t)}function Y(e){n&&(o.removeMarker(n),n=null);let t="";e.status==="fault"?t=`<div style="line-height:24px;margin-top: 12px;">
                  <div>${i("defectLevel")}\uFF1A${P(e.faultLevel)||""}</div>
                  <div>${i("defectTime")}\uFF1A${e.faultTime||""}</div>
                  <div>${i("defectHandle")}\uFF1A<span style="color:#EE5454;cursor:pointer" id="falutDeal">${i("goHandle")}</span></div>
              </div>`:t=`<div style="line-height:24px;margin-top: 12px;">
                  <div>${i("alarmLevel")}\uFF1A${j(e.alarmLevel)||""}</div>
                  <div>${i("firstAlarmTime")}\uFF1A${e.firstAlarmTime||""}</div>
                  <div>${i("handleAlarm")}\uFF1A<span style="color:#F4E002;cursor:pointer" id="alarmDeal">${i("goHandle")}</span></div>
              </div>`,n=new jsmap.JSDomMarker({id:e.deviceId,position:{x:Number(e.xcoordinate),y:Number(e.ycoordinate),z:1},floorId:Number(e.floor),depthTest:!0,displayCondition:new jsmap.JSDisplayCondition(0,1e3),alwaysShow:!0,content:`<div class="factoryPopContent" id="alarmContent_pop">
                <div class="pop" style="background-image: url(/imgs/${e.status}Pop.png);${e.status!=="normal"?"height:150px":""}">
                  <div class="popTitle" style="${e.status!=="normal"?"padding-top:8px":""}" title="${e.name}">
                    ${e.name}
                    <img src="/imgs/close.png" class="${e.status!=="normal"?"popClose":"popClose_normal"}" id="popCloseBtn"/>
                  </div>
                  ${e.status!=="normal"?t:""}
                </div>
						  </div>`,marginOffset:{x:100,y:4},callback:()=>{$("#popCloseBtn").click(()=>{o.removeMarker(n)}),$("#falutDeal").click(()=>{l.$router.hasRoute("smartAlarm")?l.$router.push({path:"/alarm/process",query:{status:"fault"}}):l.$router.hasRoute("allStatusAlarm")?l.$router.push({path:"/alarm/allAlarm",query:{status:"fault"}}):y.error(i("noZNBJAuth"))}),$("#alarmDeal").click(()=>{l.$router.hasRoute("smartAlarm")?l.$router.push({path:"/alarm/process",query:{status:"raw"}}):l.$router.hasRoute("allStatusAlarm")?l.$router.push({path:"/alarm/allAlarm",query:{status:"raw"}}):y.error(i("noZNBJAuth"))})}}),o.addMarker(n)}return(e,t)=>(ne(),se("div",{id:"factoryDashboardMap",style:de({backgroundImage:L(k)?"url("+L(k)+")":""})},null,4))}}),Ie=ee(ye,[["__scopeId","data-v-e38da266"]]);export{Ie as default};
