From 7e7424b2662e5b27dcc1c0d37f43e909e0b15ee1 Mon Sep 17 00:00:00 2001
From: songshankun <songshankun@foxmail.com>
Date: 星期四, 02 十一月 2023 16:47:38 +0800
Subject: [PATCH] feat: 轮询plc/设备/调整集群状态组件/title组件加图标

---
 src/views/dashboard/components/ProcessingInfo.vue |   42 ++++--------------------------------------
 1 files changed, 4 insertions(+), 38 deletions(-)

diff --git a/src/views/dashboard/components/ProcessingInfo.vue b/src/views/dashboard/components/ProcessingInfo.vue
index 6aaf8d9..f29a18e 100644
--- a/src/views/dashboard/components/ProcessingInfo.vue
+++ b/src/views/dashboard/components/ProcessingInfo.vue
@@ -62,6 +62,7 @@
 import type { ProductProgressParams } from '@/api'
 import { isNumber } from 'lodash-es'
 import { CHANNEL_NAME_MAP } from '@/common/constants'
+import { usePLCStore } from '@/stores/plc'
 
 const props = defineProps<{
   task?: Task
@@ -94,6 +95,8 @@
   return result > 100 ? 100 : result
 }
 
+const plcStore = usePLCStore()
+
 /**
  * 璁$畻瀹屾垚杩涘害, 浠诲姟鐘舵�佹湭鐢熶骇鍥哄畾涓� 0% 宸插畬鎴愬浐瀹氫负 100% 鐢熶骇涓垯浠巔lc鑾峰彇
  */
@@ -107,47 +110,10 @@
   }
 
   if (task?.value?.Procedure?.Status === 2) {
-    return calculateProgress(plcResponse?.value?.data as Statistics)
+    return calculateProgress(plcStore.plcInfo as Statistics)
   }
 
   return 0
-})
-
-/**
- * 濡傛灉浠诲姟鐘舵�佹槸杩涜涓�, 鍒欒疆璇� plc 鍙栬繘搴�
- */
-const {
-  data: plcResponse,
-  run: startPLCPolling,
-  cancel: cancelPLCPolling
-} = useRequest(
-  () =>
-    getProductProgress({
-      channel: task?.value?.Channel,
-      procedureId: task?.value?.Procedure.ID
-    } as ProductProgressParams),
-  {
-    manual: true,
-    pollingInterval: 6000,
-    pollingWhenHidden: false
-  }
-)
-
-/**
- * 浠诲姟鐘舵�佹槸鐢熶骇涓垯杞plc鍙栫洰鏍囨暟鍜屽畬鎴愭暟璁$畻瀹屾垚杩涘害
- */
-watch(
-  () => task?.value,
-  () => {
-    cancelPLCPolling()
-    if (task?.value?.Procedure?.Status === 2) {
-      startPLCPolling()
-    }
-  }
-)
-
-onUnmounted(() => {
-  cancelPLCPolling()
 })
 
 /**

--
Gitblit v1.8.0