From 67b64ee5d6f791d8ae79209e84bb4d8544ee5807 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 19 十一月 2024 08:45:11 +0800 Subject: [PATCH] predictTime --- src/views/data/channel/opcua/tag/index.vue | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/src/views/data/channel/opcua/tag/index.vue b/src/views/data/channel/opcua/tag/index.vue index 1ef3fc1..21937ef 100644 --- a/src/views/data/channel/opcua/tag/index.vue +++ b/src/views/data/channel/opcua/tag/index.vue @@ -67,6 +67,12 @@ <Icon icon="ep:download" />导出 </el-button> </el-form-item> + <el-form-item label="更新当前值" label-width="100px"> + <el-switch + v-model="queryParams.currentValue" + active-color="#13ce66" + inactive-color="#ff4949"/> + </el-form-item> </el-form> </ContentWrap> <!-- 列表 --> @@ -165,8 +171,9 @@ import * as OpcUaTagApi from "@/api/data/channel/opcua/tag"; import TagForm from './TagForm.vue' import download from "@/utils/download"; - import {ref,reactive} from "vue"; + import {ref, reactive, onMounted, onBeforeUnmount} from "vue"; import TagImportForm from '../../common/tag/TagImportForm.vue' + import * as OpcdaTagApi from "@/api/data/channel/opcda/tag"; defineOptions({name: 'OpcuaTag'}) @@ -184,6 +191,7 @@ device: undefined, deviceId: undefined, tagName: undefined, + currentValue:false, address: undefined }) const queryFormRef = ref() // 搜索的表单 @@ -280,4 +288,24 @@ exportLoading.value = false } } + + let intervalId; + + onMounted(async () => { + // 创建定时器 + intervalId = setInterval(async () => { + if(queryParams.currentValue){ + const page = await OpcUaTagApi.getOpcuaTagPage(queryParams) + list.value = page.list + total.value = page.total + } + }, 10000); + }); + + // 在组件卸载时清除定时器 + onBeforeUnmount(() => { + if (intervalId) { + clearInterval(intervalId); + } + }); </script> -- Gitblit v1.9.3