| | |
| | | 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 |
| | |
| | | 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> |
| | | |