Browse Source

机库告警信息通过websokcet赋值

李富豪 1 year ago
parent
commit
c92fd11141

+ 6 - 49
Web/src/pages/page-web/projects/task/taskList/index.vue

@@ -114,17 +114,16 @@
 </template>
 
 <script lang="ts" setup>
-import { reactive, onMounted, watch, computed } from 'vue';
+import { reactive, onMounted, watch } from 'vue';
 import { Modal, message } from 'ant-design-vue';
 import { ExclamationCircleOutlined, ApiOutlined, CopyOutlined, GatewayOutlined, DeleteOutlined } from '@ant-design/icons-vue';
 import Search from './components/Search.vue';
 import Airport from '/@/components/airport/index.vue';
 import CreateTaskModal from './components/CreateTaskModal.vue';
 import noDataSrc from '/@/assets/icons/no-data.png';
-import { useMyStore } from '/@/store';
 import { useFormatTask } from '/@/components/task/use-format-task';
 import { apis } from '/@/api/custom';
-import { getDeviceTopo, getUnreadDeviceHms } from '/@/api/manage';
+import { getDeviceTopo } from '/@/api/manage';
 import { createPlan } from '/@/api/wayline';
 import { getWorkspaceId } from '/@/utils';
 import { OnlineDevice, EModeCode } from '/@/types/device';
@@ -163,18 +162,8 @@ watch(() => checkState.checkSnList, val => {
   checkState.checkAll = val.length === state.onlineDockList.length;
 }, { deep: true });
 
-const store = useMyStore();
 const { formatMediaTaskStatus } = useFormatTask();
 
-const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
-const dockInfo = computed(() => store.state.deviceState.dockInfo)
-const hmsInfo = computed({
-  get: () => store.state.hmsInfo,
-  set: (val) => {
-    return val
-  }
-})
-
 const fetchOnlineDock = async () => {
   state.onlineDockListLoading = true;
   try {
@@ -244,43 +233,11 @@ const fetchList = async () => {
   }
 }
 
-function getUnreadHms(sn: string) {
-  getUnreadDeviceHms(getWorkspaceId(), sn).then(res => {
-    if (res.data.length !== 0) {
-      hmsInfo.value[sn] = res.data
-    }
-  })
-}
-
-function getOnlineDeviceHms() {
-  const snList = Object.keys(dockInfo.value)
-  if (snList.length === 0) {
-    return
-  }
-  snList.forEach(sn => {
-    getUnreadHms(sn)
-  })
-  const deviceSnList = Object.keys(deviceInfo.value)
-  if (deviceSnList.length === 0) {
-    return
-  }
-  deviceSnList.forEach(sn => {
-    getUnreadHms(sn)
-  })
-}
-
 onMounted(async () => {
-  await fetchOnlineDock();
-  setTimeout(() => {
-    watch(() => store.state.deviceStatusEvent, async data => {
-      await fetchOnlineDock()
-      if (data.deviceOnline.sn) {
-        getUnreadHms(data.deviceOnline.sn)
-      }
-    }, { deep: true })
-    getOnlineDeviceHms()
-  }, 500)// 默认3秒,此时改成0.5秒
-  await fetchList();
+  await Promise.all([
+    fetchOnlineDock(),
+    fetchList(),
+  ])
 });
 
 // 全选

+ 0 - 44
Web/src/pages/page-web/projects/tsa.vue

@@ -76,14 +76,6 @@ const state = reactive({
 })
 
 const mapClickElement = computed(() => store.state.mapClickElement)
-const deviceInfo = computed(() => store.state.deviceState.deviceInfo)
-const dockInfo = computed(() => store.state.deviceState.dockInfo)
-const hmsInfo = computed({
-  get: () => store.state.hmsInfo,
-  set: (val) => {
-    return val
-  }
-})
 
 watch(() => mapClickElement.value, (newValue, oldValue) => {
   if (newValue) {
@@ -93,17 +85,6 @@ watch(() => mapClickElement.value, (newValue, oldValue) => {
 
 onMounted(() => {
   getOnlineTopo()
-  setTimeout(() => {
-    watch(() => store.state.deviceStatusEvent,
-      data => {
-        getOnlineTopo()
-        if (data.deviceOnline.sn) {
-          getUnreadHms(data.deviceOnline.sn)
-        }
-      }, { deep: true }
-    )
-    getOnlineDeviceHms()
-  }, 500)// 默认3秒,此时改成0.5秒
   const element = document.getElementsByClassName('scrollbar').item(0) as HTMLDivElement
   const parent: any = element?.parentNode as HTMLDivElement
   scorllHeight.value = parent?.clientHeight - parent?.firstElementChild?.clientHeight
@@ -169,31 +150,6 @@ function switchVisible(device: OnlineDevice, isDock: boolean) {
   store.commit('SET_OSD_VISIBLE_INFO', osdVisible)
 }
 
-function getUnreadHms(sn: string) {
-  getUnreadDeviceHms(workspaceId.value, sn).then(res => {
-    if (res.data.length !== 0) {
-      hmsInfo.value[sn] = res.data
-    }
-  })
-}
-
-function getOnlineDeviceHms() {
-  const snList = Object.keys(dockInfo.value)
-  if (snList.length === 0) {
-    return
-  }
-  snList.forEach(sn => {
-    getUnreadHms(sn)
-  })
-  const deviceSnList = Object.keys(deviceInfo.value)
-  if (deviceSnList.length === 0) {
-    return
-  }
-  deviceSnList.forEach(sn => {
-    getUnreadHms(sn)
-  })
-}
-
 const handleClickItem = (record: any) => {
   const sn = record.sn;
   if (state.selectedSn === sn) {