From 592164b38f12dd2a605c20f6d1c84ec6b28b4f56 Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期六, 09 十二月 2023 16:46:01 +0800 Subject: [PATCH] 报工报错的问题修改 --- src/views/dashboard/components/DeviceStatusInfo.vue | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue index de86706..6e8461d 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"> @@ -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