guoshilong
2023-09-23 fb336f319c71291fa09de3e7f67f1ccfab3cb7c8
src/pages/page-web/projects/tsa.vue
@@ -1,5 +1,5 @@
<template>
  <div class="project-tsa-wrapper ">
  <div class="project-tsa-wrapper">
    <div>
      <a-row>
        <a-col :span="1"></a-col>
@@ -56,7 +56,7 @@
                          <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>
                            <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"
@@ -68,7 +68,7 @@
                                <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"
@@ -116,7 +116,7 @@
                          <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>
                            <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"
@@ -127,7 +127,7 @@
                                <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"
@@ -152,7 +152,7 @@
                <div style="float: right; background: #595959; height: 100%; width: 40px;"
                  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 />
                    </a>
@@ -233,10 +233,10 @@
          </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>
@@ -247,21 +247,17 @@
import rc from '/@/assets/icons/rc.png'
import { OnlineDevice, EModeCode, OSDVisible, EDockModeCode, DeviceOsd, EDockModeText, EModeText } from '/@/types/device'
import { useMyStore } from '/@/store'
import { getDeviceTopo, getUnreadDeviceHms, updateDeviceHms } from '/@/api/manage'
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 Drawer from '/@/components/Drawer/Drawer.vue'
import { styleDrawer } from './common/common'
import DockConfig from './components/DockConfig.vue'
const showDrawer = ref(false)
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 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()
@@ -275,13 +271,69 @@
const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
const dockInfo = computed(() => store.state.deviceState.dockInfo)
const workSpaceId = computed(() => store.state.common.projectId)
const hmsInfo = computed({
  get: () => store.state.hmsInfo,
  set: (val) => {
    return val
  }
})
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(() => {
  getOnlineTopo()
  setTimeout(() => {
@@ -302,18 +354,13 @@
  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) => {
@@ -349,11 +396,14 @@
      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) {
function switchVisible (e: any, device: OnlineDevice, isDock: boolean, isClick: boolean, sn?: any) {
  // showDrawer.value = !showDrawer.value
  if (!isClick) {
    e.target.style.cursor = 'not-allowed'
@@ -371,16 +421,17 @@
    osdVisible.value.gateway_callsign = device.gateway.callsign
    osdVisible.value.payloads = device.payload
  }
  store.commit('SET_OSD_VISIBLE_INFO', osdVisible)
  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 () {
@@ -402,7 +453,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]
      }
@@ -432,7 +483,7 @@
}
.ant-collapse>.ant-collapse-item>.ant-collapse-header {
  color: white;
  color: white !important;
  border: 0;
  padding-left: 14px;
}