From 1519870c0e18171ced014a840e86a459dc6b00f1 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期二, 12 十二月 2023 17:26:06 +0800
Subject: [PATCH] 报工记录列表增加人员姓名

---
 src/views/dashboard/components/DeviceStatusInfo.vue |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue
index de86706..c66539b 100644
--- a/src/views/dashboard/components/DeviceStatusInfo.vue
+++ b/src/views/dashboard/components/DeviceStatusInfo.vue
@@ -34,7 +34,6 @@
           </span>
         </span>
       </span>
-      <!--      TODO: 搴旇鏀规垚 plc閲屽彇,缂烘帴鍙� -->
       <div class="device-b">宸ュ簭杩愯鏃堕棿锛歿{ runningTime }}</div>
     </div>
     <div v-if="type == 2" class="color-two">
@@ -49,7 +48,7 @@
           </template>
 
           <template v-else>
-            <span>涓嶅湪闆嗙兢涓�</span>
+            <span>鏈姞鍏ラ泦缇�</span>
           </template>
         </span>
       </span>
@@ -74,6 +73,8 @@
 import { useTasksStore } from '@/stores/tasks'
 import { storeToRefs } from 'pinia'
 import type { TasksGroupByChannel } from '@/api/task'
+import { isNumber } from 'lodash-es'
+import { useInterval } from '@vueuse/core'
 
 export interface DeviceStatusInfoProps {
   plc?: PLCResponse
@@ -150,7 +151,7 @@
  * @param channelNumber
  */
 function getChannelRunningTask(channelMap?: TasksGroupByChannel, channelNumber?: number) {
-  if (!channelMap || !channelNumber) {
+  if (!channelMap || !isNumber(channelNumber)) {
     return
   }
 
@@ -165,8 +166,17 @@
 // 宸ュ簭杩愯鏃堕棿
 const taskStore = useTasksStore()
 const { activeTask, channels } = storeToRefs(taskStore)
-// 宸ュ簭杩愯鏃堕棿: 浣跨敤褰撳墠閫変腑浠诲姟鎵�鍦ㄩ�氶亾鐨勬澶勪簬杩愯涓殑浠诲姟鏉ュ睍绀�
+const { counter, reset } = useInterval(1000, { controls: true })
 const runningTime = computed(() => {
+  if (counter.value > 1000) {
+    // 鎷夸竴涓� counter 瀹氭椂瑙﹀彂宸ュ簭杩愯鏃堕棿鐨勯噸鏂拌绠楀拰娓叉煋, 闃叉婧㈠嚭闇�瑕侀噸缃�
+    reset()
+  }
+  // 濡傛灉褰撳墠閫変腑鐨勬槸宸插畬鎴愮殑浠诲姟, 浣跨敤褰撳墠閫変腑浠诲姟鏉ュ睍绀�
+  if (activeTask?.value?.Procedure?.Status === 3) {
+    return getTaskRunningTime(activeTask.value.Procedure?.realStartTime, activeTask.value.Procedure?.realEndTime)
+  }
+  // 濡傛灉褰撳墠閫変腑鐨勬槸杩愯涓垨鑰呮湭寮�濮嬬殑浠诲姟, 浣跨敤褰撳墠閫変腑浠诲姟鎵�鍦ㄩ�氶亾鐨勬澶勪簬杩愯涓殑浠诲姟鏉ュ睍绀�
   const runningTask = getChannelRunningTask(channels?.value, activeTask?.value?.Channel)
   return getTaskRunningTime(runningTask?.Procedure?.realStartTime, runningTask?.Procedure?.realEndTime)
 })

--
Gitblit v1.8.0