From b4a603e7e1c123195f5515aa7c3b247e1784fb76 Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期三, 24 一月 2024 14:53:00 +0800 Subject: [PATCH] 1 --- src/views/dashboard/components/DeviceStatusInfo.vue | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/views/dashboard/components/DeviceStatusInfo.vue b/src/views/dashboard/components/DeviceStatusInfo.vue index de86706..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> @@ -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) }) @@ -265,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