From 93ce037957861a48dbcb35004d1ff073eb63010a Mon Sep 17 00:00:00 2001 From: dongyukun <1208714201@qq.com> Date: 星期三, 06 十一月 2024 09:34:32 +0800 Subject: [PATCH] 自动刷新tag当前值,日期选择器bug修复 --- src/views/data/channel/kio/tag/index.vue | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/views/data/channel/kio/tag/index.vue b/src/views/data/channel/kio/tag/index.vue index 47f38fe..d334fb4 100644 --- a/src/views/data/channel/kio/tag/index.vue +++ b/src/views/data/channel/kio/tag/index.vue @@ -58,6 +58,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> <!-- 列表 --> @@ -92,6 +98,24 @@ <template #default="scope"> <el-tag v-if="scope.row.enabled === 1" size="small">是</el-tag> <el-tag v-else size="small" type="danger">否</el-tag> + </template> + </el-table-column> + <el-table-column + prop="dataValue" + label="数据值" + header-align="center" + align="center" + :formatter="(row) => {if (row.dataValue === -2.0) {return '--';}return row.dataValue;}" + /> + <el-table-column + prop="quality" + label="数据质量" + header-align="center" + align="center" + > + <template #default="scope"> + <el-tag v-if="scope.row.dataValue === Number(-2.0)" type="danger" size="small">bad</el-tag> + <el-tag v-else size="small">good</el-tag> </template> </el-table-column> <el-table-column label="操作" align="center" min-width="110" fixed="right"> @@ -133,8 +157,9 @@ import * as KioTagApi from "@/api/data/channel/kio/tag"; import TagForm from './TagForm.vue' import download from "@/utils/download"; - import {ref} from "vue"; import TagImportForm from '../../common/tag/TagImportForm.vue' + import {ref, onBeforeUnmount, onMounted} from "vue"; + import * as HttpTagApi from "@/api/data/channel/http/tag"; defineOptions({name: 'KioTag'}) @@ -150,6 +175,8 @@ pageNo: 1, pageSize: 10, device: undefined, + deviceId: undefined, + currentValue:false, tagName: undefined }) const queryFormRef = ref() // 搜索的表单 @@ -200,10 +227,11 @@ } /** 打开弹窗 */ - const open = async (device?: string) => { + const open = async (deviceId?: string,device?: string) => { resetForm() drawer.value = true queryParams.device = device + queryParams.deviceId = deviceId if (device) { getList() } @@ -244,4 +272,24 @@ exportLoading.value = false } } + + let intervalId; + + onMounted(async () => { + // 创建定时器 + intervalId = setInterval(async () => { + if(queryParams.currentValue){ + const page = await KioTagApi.getKioTagPage(queryParams) + list.value = page.list + total.value = page.total + } + }, 10000); + }); + + // 在组件卸载时清除定时器 + onBeforeUnmount(() => { + if (intervalId) { + clearInterval(intervalId); + } + }); </script> -- Gitblit v1.9.3