husq
2023-09-27 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1
src/pages/page-web/projects/tsa.vue
@@ -1,77 +1,86 @@
<template>
  <div class="project-tsa-wrapper ">
  <div class="project-tsa-wrapper">
    <div>
      <a-row>
        <a-col :span="1"></a-col>
        <a-col :span="11">我的项目呼号</a-col>
        <a-col :span="11" align="right" style="font-weight: 700">{{ username }}</a-col>
        <a-col :span="11">项目名称</a-col>
        <a-col :span="11" align="right" style="font-weight: 700">{{ projectName }}</a-col>
        <a-col :span="1"></a-col>
      </a-row>
    </div>
    <div class="scrollbar" :style="{ height: scorllHeight + 'px' }">
      <!--机场-->
      <a-collapse :bordered="false" expandIconPosition="right" accordion style="background: #232323;">
        <a-collapse-panel :key="EDeviceTypeName.Dock" header="机场" style="border-bottom: 1px solid #4f4f4f;">
          <div v-if="onlineDocks.data.length === 0" style="height: 150px; color: white;">
            <a-empty style="color: #fff;" :image="simpleImage" description="暂无数据" :image-style="{ height: '60px' }" />
            <a-empty style="color: #fff;" :image="simpleImage" description="暂无数据"
                     :image-style="{ height: '60px' }"/>
          </div>
          <div v-else class="fz12" style="color: white;">
            <div v-for="dock in onlineDocks.data" :key="dock.sn"
              style="background: #3c3c3c; height: 90px; margin-bottom: 10px;">
                 style="background: #3c3c3c; height: 90px; margin-bottom: 10px;">
              <div style="border-radius: 2px; height: 100%; width: 100%;"
                class="flex-row flex-justify-between flex-align-center">
                   class="flex-row flex-justify-between flex-align-center">
                <div style="float: left; padding: 0px 5px 8px 8px; width: 88%">
                  <!-- // 机场设备标题 -->
                  <div style="width: 80%; height: 30px; line-height: 30px; font-size: 16px;">
                    <a-tooltip :title="`${dock.gateway.callsign} - ${dock.callsign ?? 'No Drone'}`">
                      <div class="text-hidden" style="max-width: 200px;">{{ dock.gateway.callsign }} - {{ dock.callsign ??
                        'No Drone' }}</div>
                      <div class="text-hidden" style="max-width: 200px;">{{ dock.gateway.callsign }} - {{
                          dock.callsign ??
                          'No Drone'
                        }}
                      </div>
                    </a-tooltip>
                  </div>
                  <!-- // 机场设备状态 -->
                  <div class="mt5 flex-align-center flex-row flex-justify-between" style="background: #595959;">
                    <div class="flex-align-center flex-row">
                      <span class="ml5 mr5">
                        <RobotOutlined />
                        <RobotOutlined/>
                      </span>
                      132
                      <div class="font-bold text-hidden" style="max-width: 80px;"
                        :style="dockInfo[dock.gateway.sn] && dockInfo[dock.gateway.sn].basic_osd?.mode_code !== EDockModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                        {{ dockInfo[dock.gateway.sn] ? EDockModeCode[dockInfo[dock.gateway.sn].basic_osd?.mode_code] :
                          EDockModeCode[EDockModeCode.Disconnected] }}
                           :style="dockInfo[dock.gateway.sn] && dockInfo[dock.gateway.sn].basic_osd?.mode_code !== EDockModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                        {{
                          dockInfo[dock.gateway.sn] ? EDockModeText[dockInfo[dock.gateway.sn].basic_osd?.mode_code] :
                              EDockModeText[EDockModeCode.Disconnected]
                        }}
                      </div>
                    </div>
                    <div class="mr5 flex-align-center flex-row" style="width: 85px; margin-right: 0; height: 18px;">
                      <div v-if="hmsInfo[dock.gateway.sn]" class="flex-align-center flex-row">
                        <div :class="hmsInfo[dock.gateway.sn][0].level === EHmsLevel.CAUTION ? 'caution-blink' :
                          hmsInfo[dock.gateway.sn][0].level === EHmsLevel.WARN ? 'warn-blink' : 'notice-blink'"
                          style="width: 18px; height: 16px; text-align: center;">
                             style="width: 18px; height: 16px; text-align: center;">
                          <span :style="hmsInfo[dock.gateway.sn].length > 99 ? 'font-size: 11px' : 'font-size: 12px'">{{
                            hmsInfo[dock.gateway.sn].length }}</span>
                              hmsInfo[dock.gateway.sn].length
                            }}</span>
                          <span class="fz10">{{ hmsInfo[dock.gateway.sn].length > 99 ? '+' : '' }}</span>
                        </div>
                        <a-popover trigger="click" placement="bottom" color="black"
                          v-model:visible="hmsVisible[dock.gateway.sn]"
                          @visibleChange="readHms(hmsVisible[dock.gateway.sn], dock.gateway.sn)"
                          :overlayStyle="{ width: '200px', height: '300px' }">
                                   v-model:visible="hmsVisible[dock.gateway.sn]"
                                   @visibleChange="readHms(hmsVisible[dock.gateway.sn], dock.gateway.sn)"
                                   :overlayStyle="{ width: '200px', height: '300px' }">
                          <div :class="hmsInfo[dock.gateway.sn][0].level === EHmsLevel.CAUTION ? 'caution' :
                            hmsInfo[dock.gateway.sn][0].level === EHmsLevel.WARN ? 'warn' : 'notice'"
                            style="margin-left: 3px; width: 62px; height: 16px;">
                            <span class="word-loop">{{ hmsInfo[dock.gateway.sn][0].message_en }}</span>
                               style="margin-left: 3px; width: 62px; height: 16px;">
                            <span class="word-loop">{{ hmsInfo[dock.gateway.sn][0].message_zh }}</span>
                          </div>
                          <template #content>
                            <a-collapse style="background: black; height: 300px; overflow-y: auto;" :bordered="false"
                              expand-icon-position="right" :accordion="true">
                                        expand-icon-position="right" :accordion="true">
                              <a-collapse-panel v-for="hms in hmsInfo[dock.gateway.sn]" :key="hms.hms_id"
                                :showArrow="false"
                                style=" margin: 0 auto 3px auto; border: 0; width: 140px; border-radius: 3px"
                                :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                                :showArrow="false"
                                                style=" margin: 0 auto 3px auto; border: 0; width: 140px; border-radius: 3px"
                                                :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                <template #header="{ isActive }">
                                  <div class="flex-row flex-align-center" style="width: 130px;">
                                    <div style="width: 110px;">
                                      <span class="word-loop">{{ hms.message_en }}</span>
                                      <span class="word-loop">{{ hms.message_zh }}</span>
                                    </div>
                                    <div style="width: 20px; height: 15px; font-size: 10px; z-index: 2 "
                                      class="flex-row flex-align-center flex-justify-center"
                                      :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                      <DoubleRightOutlined :rotate="isActive ? 90 : 0" />
                                         class="flex-row flex-align-center flex-justify-center"
                                         :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                      <DoubleRightOutlined :rotate="isActive ? 90 : 0"/>
                                    </div>
                                  </div>
                                </template>
@@ -87,49 +96,54 @@
                      <div v-else class="width-100" style="height: 90%; background: rgba(0, 0, 0, 0.35)"></div>
                    </div>
                  </div>
                  <!-- // 机场是否启动 -->
                  <div class="mt5 flex-align-center flex-row flex-justify-between" style="background: #595959;">
                    <div class="flex-row">
                      <span class="ml5 mr5">
                        <RocketOutlined />
                        <RocketOutlined/>
                      </span>
                      <div class="font-bold text-hidden" style="max-width: 80px"
                        :style="deviceInfo[dock.sn] && deviceInfo[dock.sn].mode_code !== EModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                        {{ deviceInfo[dock.sn] ? EModeCode[deviceInfo[dock.sn].mode_code] :
                          EModeCode[EModeCode.Disconnected] }}
                           :style="deviceInfo[dock.sn] && deviceInfo[dock.sn].mode_code !== EModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                        {{
                          deviceInfo[dock.sn] ? EModeText[deviceInfo[dock.sn].mode_code] :
                              EModeText[EModeCode.Disconnected]
                        }}
                      </div>
                    </div>
                    <div class="mr5 flex-align-center flex-row" style="width: 85px; margin-right: 0; height: 18px;">
                      <div v-if="hmsInfo[dock.sn]" class="flex-align-center flex-row">
                        <div :class="hmsInfo[dock.sn][0].level === EHmsLevel.CAUTION ? 'caution-blink' :
                          hmsInfo[dock.sn][0].level === EHmsLevel.WARN ? 'warn-blink' : 'notice-blink'"
                          style="width: 18px; height: 16px; text-align: center;">
                             style="width: 18px; height: 16px; text-align: center;">
                          <span :style="hmsInfo[dock.sn].length > 99 ? 'font-size: 11px' : 'font-size: 12px'">{{
                            hmsInfo[dock.sn].length }}</span>
                              hmsInfo[dock.sn].length
                            }}</span>
                          <span class="fz10">{{ hmsInfo[dock.sn].length > 99 ? '+' : '' }}</span>
                        </div>
                        <a-popover trigger="click" placement="bottom" color="black" v-model:visible="hmsVisible[dock.sn]"
                          @visibleChange="readHms(hmsVisible[dock.sn], dock.sn)"
                          :overlayStyle="{ width: '200px', height: '300px' }">
                        <a-popover trigger="click" placement="bottom" color="black"
                                   v-model:visible="hmsVisible[dock.sn]"
                                   @visibleChange="readHms(hmsVisible[dock.sn], dock.sn)"
                                   :overlayStyle="{ width: '200px', height: '300px' }">
                          <div :class="hmsInfo[dock.sn][0].level === EHmsLevel.CAUTION ? 'caution' :
                            hmsInfo[dock.sn][0].level === EHmsLevel.WARN ? 'warn' : 'notice'"
                            style="margin-left: 3px; width: 62px; height: 16px;">
                            <span class="word-loop">{{ hmsInfo[dock.sn][0].message_en }}</span>
                               style="margin-left: 3px; width: 62px; height: 16px;">
                            <span class="word-loop">{{ hmsInfo[dock.sn][0].message_zh }}</span>
                          </div>
                          <template #content>
                            <a-collapse style="background: black; height: 300px; overflow-y: auto;" :bordered="false"
                              expand-icon-position="right" :accordion="true">
                                        expand-icon-position="right" :accordion="true">
                              <a-collapse-panel v-for="hms in hmsInfo[dock.sn]" :key="hms.hms_id" :showArrow="false"
                                style=" margin: 0 auto 3px auto; border: 0; width: 140px; border-radius: 3px"
                                :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                                style=" margin: 0 auto 3px auto; border: 0; width: 140px; border-radius: 3px"
                                                :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                <template #header="{ isActive }">
                                  <div class="flex-row flex-align-center" style="width: 130px;">
                                    <div style="width: 110px;">
                                      <span class="word-loop">{{ hms.message_en }}</span>
                                      <span class="word-loop">{{ hms.message_zh }}</span>
                                    </div>
                                    <div style="width: 20px; height: 15px; font-size: 10px; z-index: 2 "
                                      class="flex-row flex-align-center flex-justify-center"
                                      :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                      <DoubleRightOutlined :rotate="isActive ? 90 : 0" />
                                         class="flex-row flex-align-center flex-justify-center"
                                         :class="hms.level === EHmsLevel.CAUTION ? 'caution' : hms.level === EHmsLevel.WARN ? 'warn' : 'notice'">
                                      <DoubleRightOutlined :rotate="isActive ? 90 : 0"/>
                                    </div>
                                  </div>
                                </template>
@@ -147,14 +161,14 @@
                  </div>
                </div>
                <div style="float: right; background: #595959; height: 100%; width: 40px;"
                  class="flex-row flex-justify-center flex-align-center">
                     class="flex-row flex-justify-center flex-align-center">
                  <div class="fz16"
                    @click="switchVisible($event, dock, true, dockInfo[dock.gateway.sn] && dockInfo[dock.gateway.sn].basic_osd?.mode_code !== EDockModeCode.Disconnected)">
                       @click="switchVisible($event, dock, true, dockInfo[dock.gateway.sn] && dockInfo[dock.gateway.sn].basic_osd?.mode_code !== EDockModeCode.Disconnected, dock.gateway.sn)">
                    <a v-if="osdVisible.gateway_sn === dock.gateway.sn && osdVisible.visible">
                      <EyeOutlined />
                      <EyeOutlined/>
                    </a>
                    <a v-else>
                      <EyeInvisibleOutlined />
                      <EyeInvisibleOutlined/>
                    </a>
                  </div>
                </div>
@@ -163,52 +177,63 @@
          </div>
        </a-collapse-panel>
      </a-collapse>
      <!--设备-->
      <a-collapse :bordered="false" expandIconPosition="right" accordion style="background: #232323;">
        <a-collapse-panel :key="EDeviceTypeName.Aircraft" header="在线设备" style="border-bottom: 1px solid #4f4f4f;">
          <div v-if="onlineDevices.data.length === 0" style="height: 150px; color: white;">
            <a-empty :image="simpleImage" style="color: #fff;" description="暂无数据" :image-style="{ height: '60px' }" />
            <a-empty :image="simpleImage" style="color: #fff;" description="暂无数据"
                     :image-style="{ height: '60px' }"/>
          </div>
          <div v-else class="fz12" style="color: white;">
            <div v-for="device in onlineDevices.data" :key="device.sn"
              style="background: #3c3c3c; height: 90px; margin-bottom: 10px;">
                 style="background: #3c3c3c; height: 90px; margin-bottom: 10px;">
              <div class="battery-slide" v-if="deviceInfo[device.sn]">
                <div style="background: #535759; width: 100%;"></div>
                <div class="capacity-percent" :style="{ width: deviceInfo[device.sn].battery.capacity_percent + '%' }">
                </div>
                <div class="return-home" :style="{ width: deviceInfo[device.sn].battery.return_home_power + '%' }"></div>
                <div class="return-home"
                     :style="{ width: deviceInfo[device.sn].battery.return_home_power + '%' }"></div>
                <div class="landing" :style="{ width: deviceInfo[device.sn].battery.landing_power + '%' }"></div>
                <div class="battery" :style="{ left: deviceInfo[device.sn].battery.capacity_percent + '%' }"></div>
              </div>
              <div style="border-bottom: 1px solid #515151; border-radius: 2px; height: 50px; width: 100%;"
                class="flex-row flex-justify-between flex-align-center">
                   class="flex-row flex-justify-between flex-align-center">
                <div style="float: left; padding: 5px 5px 8px 8px; width: 88%">
                  <div style="width: 100%; height: 100%;">
                    <a-tooltip>
                      <template #title>{{ device.model ? `${device.model} - ${device.callsign}` : 'No Drone' }}</template>
                      <span class="text-hidden" style="max-width: 200px; display: block; height: 20px;">{{ device.model ?
                        `${device.model} - ${device.callsign}` : 'No Drone' }}</span>
                      <template #title>{{
                          device.model ? `${device.model} - ${device.callsign}` : 'No Drone'
                        }}
                      </template>
                      <span class="text-hidden" style="max-width: 200px; display: block; height: 20px;">{{
                          device.model ?
                              `${device.model} - ${device.callsign}` : 'No Drone'
                        }}</span>
                    </a-tooltip>
                  </div>
                  <div class="mt5" style="background: #595959;">
                    <span class="ml5 mr5">
                      <RocketOutlined />
                      <RocketOutlined/>
                    </span>
                    <span class="font-bold"
                      :style="deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                      {{ deviceInfo[device.sn] ? EModeCode[deviceInfo[device.sn].mode_code] :
                        EModeCode[EModeCode.Disconnected] }}
                          :style="deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected ? 'color: #00ee8b' : 'color: red;'">
                      {{
                        deviceInfo[device.sn] ? EModeCode[deviceInfo[device.sn].mode_code] :
                            EModeCode[EModeCode.Disconnected]
                      }}
                    </span>
                  </div>
                </div>
                <div style="float: right; background: #595959; height: 50px; width: 40px;"
                  class="flex-row flex-justify-center flex-align-center">
                     class="flex-row flex-justify-center flex-align-center">
                  <div class="fz16"
                    @click="switchVisible($event, device, false, deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected)">
                       @click="switchVisible($event, device, false, deviceInfo[device.sn] && deviceInfo[device.sn].mode_code !== EModeCode.Disconnected)">
                    <a v-if="osdVisible.sn === device.sn && osdVisible.visible">
                      <EyeOutlined />
                      <EyeOutlined/>
                    </a>
                    <a v-else>
                      <EyeInvisibleOutlined />
                      <EyeInvisibleOutlined/>
                    </a>
                  </div>
                </div>
@@ -216,11 +241,13 @@
              <div class="flex-row flex-justify-center flex-align-center" style="height: 40px;">
                <div class="flex-row" style="height: 20px; background: #595959; width: 94%;">
                  <span class="mr5"><a-image style="margin-left: 2px; margin-top: -2px; height: 20px; width: 20px;"
                      :src="rc" /></span>
                                             :src="rc"/></span>
                  <a-tooltip>
                    <template #title>{{ device.gateway.model }} - {{ device.gateway.callsign }} </template>
                    <template #title>{{ device.gateway.model }} - {{ device.gateway.callsign }}</template>
                    <div class="text-hidden" style="max-width: 200px;">{{ device.gateway.model }} - {{
                      device.gateway.callsign }}</div>
                        device.gateway.callsign
                      }}
                    </div>
                  </a-tooltip>
                </div>
              </div>
@@ -228,75 +255,52 @@
          </div>
        </a-collapse-panel>
      </a-collapse>
      <!-- 测试视频播放组件 -->
      <!-- <JessibucaVideo videoUrl="https://www.ainfo.top:700/rtp/34020000001110000101_34020000001310000001.flv" /> -->
    </div>
    <Drawer title="项目设置" :styleDrawer="styleDrawer" v-model:show="showDrawer">
      <DockConfig />
    </Drawer>
  </div>
</template>
<script lang="ts" setup>
import { styleDrawer } from './common/common'
import { useConnectWebSocket } from '/@/hooks/use-connect-websocket'
import { flyTo } from '/@/hooks/use-center-point'
import { computed, onMounted, reactive, ref, watch, WritableComputedRef } from 'vue'
import { EDeviceTypeName, ELocalStorageKey } from '/@/types'
import Drawer from '/@/components/Drawer/Drawer.vue'
import noData from '/@/assets/icons/no-data.png'
import { Empty } from 'ant-design-vue'
import rc from '/@/assets/icons/rc.png'
import { OnlineDevice, EModeCode, OSDVisible, EDockModeCode, DeviceOsd } from '/@/types/device'
import { OnlineDevice, EModeCode, OSDVisible, EDockModeCode, DeviceOsd, EDockModeText, EModeText } from '/@/types/device'
import { useMyStore } from '/@/store'
import { getDeviceTopo, getUnreadDeviceHms, updateDeviceHms } from '/@/api/manage'
import { RocketOutlined, EyeInvisibleOutlined, EyeOutlined, RobotOutlined, DoubleRightOutlined } from '@ant-design/icons-vue'
import { getDeviceTopo, getUnreadDeviceHms, updateDeviceHms, testBind } from '/@/api/manage'
import {
  RocketOutlined,
  EyeInvisibleOutlined,
  EyeOutlined,
  RobotOutlined,
  DoubleRightOutlined
} from '@ant-design/icons-vue'
import { EHmsLevel } from '/@/types/enums'
import { UranusMqtt } from '/@/mqtt/index'
import DockConfig from './components/DockConfig.vue'
import { cesiumOperation } from '/@/hooks/use-cesium-tsa'
const { appContext } = getCurrentInstance()
const global = appContext.config.globalProperties
const route = useRoute()
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE
// const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE
const store = useMyStore()
const username = ref(localStorage.getItem(ELocalStorageKey.Username))
const workspaceId = ref(localStorage.getItem(ELocalStorageKey.WorkspaceId)!)
// const workSpaceId = ref(localStorage.getItem(ELocalStorageKey.workSpaceId)!)
const osdVisible = ref({} as OSDVisible)
const hmsVisible = new Map<string, boolean>()
const scorllHeight = ref()
const showDrawer = ref(false)
const onlineDevices = reactive({
  data: [] as OnlineDevice[]
})
const onlineDocks = reactive({
  data: [
    {
      model: '我是model字段',
      callsign: '我是callsign字段',
      sn: '我是sn字段',
      mode: '我是mode字段',
      gateway: {
        model: 'gateway.model',
        callsign: 'gateway.callsign',
        sn: '我是gateway.sn字段',
        mode: '我是gateway.mode字段',
      },
      payload: [
        {
          index: 1,
          model: '2',
          control_source: 'A',
          payload_sn: 'payload_sn',
          payload_index: 'payload_index',
          payload_name: 'payload_name',
        },
      ]
    },
  ] as unknown as OnlineDevice[]
  data: [] as OnlineDevice[]
})
const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
const dockInfo = computed(() => store.state.deviceState.dockInfo)
const projectName = computed(() => store.state.common.projectName)
const workSpaceId = computed(() => store.state.common.projectId)
const hmsInfo = computed({
  get: () => store.state.hmsInfo,
  set: (val) => {
@@ -304,39 +308,98 @@
  }
})
watch(
  () => store.state.osdVisible.visible,
  (newVal, oldVal) => {
    osdVisible.value.visible = newVal
  },
  {
    deep: true,
  })
const getResource = (name: string) => {
  return new URL(`/src/assets/icons/${name}`, import.meta.url).href
}
// 获取ws连接过来的sn设备号
const snCode = ref<string[]>([])
// 添加机场标注
watch(() => store.state.deviceState, data => {
  const cesium = cesiumOperation(global.$viewer)
  if (snCode.value.includes(data.currentSn)) return
  snCode.value.push(data.currentSn)
  // cesium.removeAllPoint()
  if (data.currentType === EDeviceTypeName.Aircraft && data.deviceInfo[data.currentSn]) {
    // 无人机图标
    const setting = {
      longitude: data.deviceInfo[data.currentSn].longitude,
      latitude: data.deviceInfo[data.currentSn].latitude,
      billboard: {
        image: getResource('drone.png'),
        outlineWidth: 0,
        width: 36,
        height: 36,
        scale: 1.0,
      }
    }
    cesium.addPoint(setting)
    // if (osdVisible.value.visible && osdVisible.value.sn !== '') {
    //   deviceInfo.value.device = data.deviceInfo[osdVisible.value.sn]
    // }
  }
  if (data.currentType === EDeviceTypeName.Dock && data.dockInfo[data.currentSn]) {
    // 机场图标位置
    const setting = {
      longitude: data.dockInfo[data.currentSn].basic_osd?.longitude,
      latitude: data.dockInfo[data.currentSn].basic_osd?.latitude,
      billboard: {
        image: getResource('dock.png'),
        outlineWidth: 0,
        width: 36,
        height: 36,
        scale: 1.0,
      }
    }
    cesium.addPoint(setting)
    // cesium.flyTo(setting)
  }
}, {
  deep: true,
})
const bind = async (sn: string) => {
  const res = await testBind(sn)
  if (res.code === 0) {
    Promise.resolve(true)
  } else {
    Promise.resolve(false)
  }
}
onMounted(() => {
  // flyTo(global.$viewer, route.params.longitude as unknown as number, route.params.latitude as unknown as number)
  // getOnlineTopo()
  // setTimeout(() => {
  //   watch(() => store.state.deviceStatusEvent,
  //     data => {
  //       getOnlineTopo()
  //       if (data.deviceOnline.sn) {
  //         getUnreadHms(data.deviceOnline.sn)
  //       }
  //     },
  //     {
  //       deep: true
  //     }
  //   )
  //   getOnlineDeviceHms()
  // }, 3000)
  getOnlineTopo()
  setTimeout(() => {
    watch(() => store.state.deviceStatusEvent,
      data => {
        getOnlineTopo()
        if (data.deviceOnline.sn) {
          getUnreadHms(data.deviceOnline.sn)
        }
      },
      {
        deep: true
      }
    )
    getOnlineDeviceHms()
  }, 3000)
  const element = document.getElementsByClassName('scrollbar').item(0) as HTMLDivElement
  const parent = element?.parentNode as HTMLDivElement
  scorllHeight.value = parent?.clientHeight - parent?.firstElementChild?.clientHeight
})
const messageHandler = async (payload: any) => {
  console.log(payload, 'payload')
  // if (payload.type === 'hms') {
  //   const { data
}
// 监听ws 消息
useConnectWebSocket(messageHandler)
function getOnlineTopo () {
  getDeviceTopo(workspaceId.value).then((res) => {
  getDeviceTopo(workSpaceId.value).then((res) => {
    if (res.code !== 0) {
      return
    }
    const snList: any[] = []
    onlineDevices.data = []
    onlineDocks.data = []
    res.data.forEach((gateway: any) => {
@@ -372,38 +435,42 @@
      if (gateway.status && EDeviceTypeName.Gateway === gateway.domain) {
        onlineDevices.data.push(device)
      }
      snList.push(gateway.device_sn)
      bind(gateway.device_sn)
    })
    store.commit('SET_SN_LIST', snList)
  })
}
function switchVisible (e: any, device: OnlineDevice, isDock: boolean, isClick: boolean) {
  showDrawer.value = !showDrawer.value
  // if (!isClick) {
  //   e.target.style.cursor = 'not-allowed'
  //   return
  // }
  // if (device.sn === osdVisible.value.sn) {
  //   osdVisible.value.visible = !osdVisible.value.visible
  // } else {
  //   osdVisible.value.sn = device.sn
  //   osdVisible.value.callsign = device.callsign
  //   osdVisible.value.model = device.model
  //   osdVisible.value.visible = true
  //   osdVisible.value.gateway_sn = device.gateway.sn
  //   osdVisible.value.is_dock = isDock
  //   osdVisible.value.gateway_callsign = device.gateway.callsign
  //   osdVisible.value.payloads = device.payload
  // }
  // store.commit('SET_OSD_VISIBLE_INFO', osdVisible)
function switchVisible (e: any, device: OnlineDevice, isDock: boolean, isClick: boolean, sn?: any) {
  // showDrawer.value = !showDrawer.value
  if (!isClick) {
    e.target.style.cursor = 'not-allowed'
    return
  }
  if (device.sn === osdVisible.value.sn) {
    osdVisible.value.visible = !osdVisible.value.visible
  } else {
    osdVisible.value.sn = device.sn
    osdVisible.value.callsign = device.callsign
    osdVisible.value.model = device.model
    osdVisible.value.visible = true
    osdVisible.value.gateway_sn = device.gateway.sn
    osdVisible.value.is_dock = isDock
    osdVisible.value.gateway_callsign = device.gateway.callsign
    osdVisible.value.payloads = device.payload
  }
  console.log(osdVisible.value, 'value')
  store.commit('SET_OSD_VISIBLE_INFO', osdVisible.value)
  store.commit('SET_HMSInfo_DetailSn', sn)
}
function getUnreadHms (sn: string) {
  getUnreadDeviceHms(workspaceId.value, sn).then(res => {
  getUnreadDeviceHms(workSpaceId.value, sn).then(res => {
    if (res.data.length !== 0) {
      hmsInfo.value[sn] = res.data
    }
  })
  console.info(hmsInfo.value)
}
function getOnlineDeviceHms () {
@@ -425,7 +492,7 @@
function readHms (visiable: boolean, sn: string) {
  if (!visiable) {
    updateDeviceHms(workspaceId.value, sn).then(res => {
    updateDeviceHms(workSpaceId.value, sn).then(res => {
      if (res.code === 0) {
        delete hmsInfo.value[sn]
      }
@@ -435,7 +502,7 @@
</script>
<style lang="scss">
.project-tsa-wrapper> :first-child {
.project-tsa-wrapper > :first-child {
  height: 50px;
  line-height: 50px;
  align-items: center;
@@ -454,8 +521,8 @@
  }
}
.ant-collapse>.ant-collapse-item>.ant-collapse-header {
  color: white;
.ant-collapse > .ant-collapse-item > .ant-collapse-header {
  color: white !important;
  border: 0;
  padding-left: 14px;
}
@@ -495,7 +562,7 @@
  }
}
.battery-slide>div {
.battery-slide > div {
  position: relative;
  margin-top: -2px;
  min-height: 2px;
@@ -570,4 +637,5 @@
    transform: translateX(-100%);
    -webkit-transform: translateX(-100%);
  }
}</style>
}
</style>