From 291bf570b2106cb99b0e689af7d6ccaacc9e5c1c Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 25 十二月 2024 18:10:42 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat-ui-vue3 --- src/views/data/channel/modbus/tag/index.vue | 77 ++++++++++++++++++++++++++++++++------ 1 files changed, 65 insertions(+), 12 deletions(-) diff --git a/src/views/data/channel/modbus/tag/index.vue b/src/views/data/channel/modbus/tag/index.vue index 860d737..528d368 100644 --- a/src/views/data/channel/modbus/tag/index.vue +++ b/src/views/data/channel/modbus/tag/index.vue @@ -1,7 +1,7 @@ <template> <el-drawer v-model="drawer" - size="50%" + size="60%" title="ModBus Tag" :direction="direction" :before-close="handleClose" @@ -35,11 +35,11 @@ </el-form-item> <el-form-item> <el-button @click="handleQuery"> - <Icon icon="ep:search" class="mr-5px" /> + <Icon icon="ep:search" class="mr-5px"/> 搜索 </el-button> <el-button @click="resetQuery"> - <Icon icon="ep:refresh" class="mr-5px" /> + <Icon icon="ep:refresh" class="mr-5px"/> 重置 </el-button> <el-button @@ -47,7 +47,7 @@ plain @click="openForm('create')" v-hasPermi="['data:channel-modbus:create']"> - <Icon icon="ep:plus" class="mr-5px" /> + <Icon icon="ep:plus" class="mr-5px"/> 新增 </el-button> <el-button @@ -55,7 +55,8 @@ plain @click="handleImport" v-hasPermi="['data:channel-modbus-tag:import']"> - <Icon icon="ep:upload" /> 导入 + <Icon icon="ep:upload"/> + 导入 </el-button> <el-button type="success" @@ -63,8 +64,15 @@ @click="handleExport" :loading="exportLoading" v-hasPermi="['data:channel-modbus-tag:export']"> - <Icon icon="ep:download" />导出 + <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> @@ -120,6 +128,27 @@ <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" + min-width="100" + :formatter="(row) => {if (row.dataValue === -2.0) {return '--';}return row.dataValue;}" + /> + <el-table-column + prop="dataTime" + label="数据时间" + header-align="center" + align="center" + min-width="150" + /> + <el-table-column + prop="dataQuality" + label="数据质量" + header-align="center" + align="center" + /> <el-table-column label="操作" align="center" min-width="110" fixed="right"> <template #default="scope"> <el-button @@ -150,17 +179,19 @@ /> </ContentWrap> <!-- 表单弹窗:添加/修改 --> - <TagForm ref="formRef" @success="getList" /> - <TagImportForm ref="importFormRef" @success="getList" /> + <TagForm ref="formRef" @success="getList"/> + <TagImportForm ref="importFormRef" @success="getList"/> </el-drawer> </template> <script lang="ts" setup> - import type { DrawerProps } from 'element-plus' + import type {DrawerProps} from 'element-plus' import * as ModBusTagApi from "@/api/data/channel/modbus/tag"; import TagForm from './TagForm.vue' import download from "@/utils/download"; import {ref} from "vue"; import TagImportForm from '../../common/tag/TagImportForm.vue' + import {onBeforeUnmount, onMounted} from "vue"; + import * as HttpTagApi from "@/api/data/channel/http/tag"; defineOptions({name: 'ModBusTag'}) @@ -175,8 +206,10 @@ const queryParams = reactive({ pageNo: 1, pageSize: 10, + deviceId: undefined, device: undefined, tagName: undefined, + currentValue:false, address: undefined }) const queryFormRef = ref() // 搜索的表单 @@ -227,10 +260,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() } @@ -253,8 +287,8 @@ /** tag导入 */ const importFormRef = ref() const handleImport = () => { - if(queryParams.device){ - importFormRef.value.open(queryParams.device, '/data/channel/modbus/tag/import',ModBusTagApi.importModBusTagTemplate(), 'ModBus', queryParams.device) + if (queryParams.device) { + importFormRef.value.open(queryParams.device, '/data/channel/modbus/tag/import', ModBusTagApi.importModBusTagTemplate(), 'ModBus', queryParams.device) } } @@ -272,4 +306,23 @@ exportLoading.value = false } } + let intervalId; + + onMounted(async () => { + // 创建定时器 + intervalId = setInterval(async () => { + if(queryParams.currentValue){ + const page = await ModBusTagApi.getModBusTagPage(queryParams) + list.value = page.list + total.value = page.total + } + }, 10000); + }); + + // 在组件卸载时清除定时器 + onBeforeUnmount(() => { + if (intervalId) { + clearInterval(intervalId); + } + }); </script> -- Gitblit v1.9.3