From 82e27d0cadbddfc73e8b978e778b802dc8e51fa1 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期五, 29 三月 2024 10:51:36 +0800 Subject: [PATCH] 报工入参修改和工序ID修改 --- src/views/dashboard/components/DeviceStatusInfo.vue | 44 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue index 0730135..3946950 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> @@ -73,6 +72,9 @@ import type { PLCResponse } from '@/api/plc' 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 @@ -143,11 +145,40 @@ return `${days}澶�${hours}鏃�${m}鍒哷 } +/** + * 鑾峰彇鏌愪换鍔℃墍鍦ㄩ�氶亾鐨勮繍琛屼腑鐨勪换鍔� + * @param channelMap + * @param channelNumber + */ +function getChannelRunningTask(channelMap?: TasksGroupByChannel, channelNumber?: number) { + if (!channelMap || !isNumber(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 { counter, reset } = useInterval(1000, { controls: true }) const runningTime = computed(() => { - return getTaskRunningTime(activeTask?.value?.Procedure?.realStartTime, activeTask?.value?.Procedure?.realEndTime) + 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) }) </script> @@ -244,9 +275,12 @@ margin: 8px 5px 0 5px; } span { - height: 32px; + height: 29px; display: inline-block; + line-height: 29px; + vertical-align: middle; text-align: center; + font-size: 12px; display: inline-block; float: left; font-weight: bold; -- Gitblit v1.8.0