From 102002f53d93c88cdd85b23a4e070ab39539f633 Mon Sep 17 00:00:00 2001
From: songshankun <songshankun@foxmail.com>
Date: 星期五, 03 十一月 2023 16:12:14 +0800
Subject: [PATCH] feat: 工序运行时间使用当前选中任务所在通道的正处于运行中的任务来展示

---
 src/views/dashboard/components/DeviceStatusInfo.vue |   25 +++++++++++++++++++++++--
 src/stores/craftModel.ts                            |    4 +---
 src/api/index.ts                                    |    1 -
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/api/index.ts b/src/api/index.ts
index 84fceb8..6b41213 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -112,7 +112,6 @@
   procedureId: number
   page: number
   pageSize: number
-  number: string
 }
 
 /**
diff --git a/src/stores/craftModel.ts b/src/stores/craftModel.ts
index 5985e67..9b8afbd 100644
--- a/src/stores/craftModel.ts
+++ b/src/stores/craftModel.ts
@@ -1,4 +1,4 @@
-import { onUnmounted, ref, watch } from 'vue'
+import { ref, watch } from 'vue'
 import { defineStore } from 'pinia'
 import type { CraftModel } from '@/api/craftModel'
 import { apiGetCraftModelList } from '@/api'
@@ -11,13 +11,11 @@
   const taskStore = useTasksStore()
   function getCraftModelList() {
     if (taskStore.activeTask?.Procedure.ID) {
-      console.log(122)
       apiGetCraftModelList({
         procedureId: taskStore.activeTask?.Procedure.ID,
         page: 1,
         pageSize: 999
       }).then((res) => {
-        console.log()
         craftModelList.value = res.data ?? []
       })
     }
diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue
index 0730135..de86706 100644
--- a/src/views/dashboard/components/DeviceStatusInfo.vue
+++ b/src/views/dashboard/components/DeviceStatusInfo.vue
@@ -73,6 +73,7 @@
 import type { PLCResponse } from '@/api/plc'
 import { useTasksStore } from '@/stores/tasks'
 import { storeToRefs } from 'pinia'
+import type { TasksGroupByChannel } from '@/api/task'
 
 export interface DeviceStatusInfoProps {
   plc?: PLCResponse
@@ -143,11 +144,31 @@
   return `${days}澶�${hours}鏃�${m}鍒哷
 }
 
+/**
+ * 鑾峰彇鏌愪换鍔℃墍鍦ㄩ�氶亾鐨勮繍琛屼腑鐨勪换鍔�
+ * @param channelMap
+ * @param channelNumber
+ */
+function getChannelRunningTask(channelMap?: TasksGroupByChannel, channelNumber?: number) {
+  if (!channelMap || !channelNumber) {
+    return
+  }
+
+  const channel = channelMap[channelNumber]
+  if (channel) {
+    const taskList = channel?.Tasks ?? []
+
+    return taskList.find((ele) => ele.Procedure.Status === 2)
+  }
+}
+
 // 宸ュ簭杩愯鏃堕棿
 const taskStore = useTasksStore()
-const { activeTask } = storeToRefs(taskStore)
+const { activeTask, channels } = storeToRefs(taskStore)
+// 宸ュ簭杩愯鏃堕棿: 浣跨敤褰撳墠閫変腑浠诲姟鎵�鍦ㄩ�氶亾鐨勬澶勪簬杩愯涓殑浠诲姟鏉ュ睍绀�
 const runningTime = computed(() => {
-  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)
 })
 </script>
 

--
Gitblit v1.8.0