From 64aa95531c05aa40e9d8e8cb2be94ea1dfb4ce87 Mon Sep 17 00:00:00 2001 From: Lufaneng Date: Thu, 9 Oct 2025 11:31:33 +0800 Subject: [PATCH] 1 --- src/views/HandleControl/index.vue | 39 ++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/views/HandleControl/index.vue b/src/views/HandleControl/index.vue index a7c4e7b..c9adcf1 100644 --- a/src/views/HandleControl/index.vue +++ b/src/views/HandleControl/index.vue @@ -11,7 +11,7 @@

手动控制

- + 设备时间:{{ deviceTime ? dayjs(deviceTime).format('YYYY-MM-DD HH:mm') : '' }}
@@ -175,12 +175,9 @@ 设备号:{{ commit_uid }}
- + + 同步时间 + @@ -224,10 +221,33 @@ const commit_uid = localStorage.getItem('central_control_comm_uid') const router = useRouter() const currentTime = ref('') +const deviceTime = ref('') const systemRuntime = ref('38分钟') const brightnessDialogVisible = ref(false) const currentBrightness = ref(50) const selectedChannelName = ref(null) +const timeLoading = ref(false) + +const isUpDateTimeing = ref(false) +const getDeviceTime = () => { + isUpDateTimeing.value = true + RPC.post('/m9z/getDeviceTime', { comm_uid: commit_uid }).then(res => { + deviceTime.value = res.deviceTime + }).finally(() => { + isUpDateTimeing.value = false + }) +} +getDeviceTime() + +const setDeviceTime = () => { + timeLoading.value = true + RPC.post('/m9z/setDeviceTime', { comm_uid: commit_uid, device_time: dayjs().format('YYYY-MM-DD HH:mm:ss') }).then(res => { + ElMessage.success('同步时间成功') + getDeviceTime() + }).finally(() => { + timeLoading.value = false + }) +} const week = ref('') const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; @@ -459,6 +479,9 @@ const updateTime = () => { week.value = weekDays[now.getDay()] currentTime.value = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` + if (deviceTime.value && !isUpDateTimeing.value) { + deviceTime.value = dayjs(deviceTime.value).valueOf() + 1000 + } } // 切换回路状态 @@ -653,7 +676,7 @@ onUnmounted(() => { } .system-status { - min-width: 200px; + min-width: 300px; font-size: 18px; font-weight: 300; width: 270px;