| | |
| | | <template> |
| | | <el-drawer |
| | | v-model="drawer" |
| | | size="50%" |
| | | size="60%" |
| | | title="Kio Tag" |
| | | :direction="direction" |
| | | :before-close="handleClose" |
| | |
| | | <el-input |
| | | v-model="queryParams.tagName" |
| | | placeholder="请输入Tag名称" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="地址" prop="address"> |
| | | <el-input |
| | | v-model="queryParams.address" |
| | | placeholder="请输入Modbus地址" |
| | | clearable |
| | | @keyup.enter="handleQuery" |
| | | class="!w-240px" |
| | |
| | | <Icon icon="ep:plus" class="mr-5px" /> |
| | | 新增 |
| | | </el-button> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | @click="handleImport" |
| | | v-hasPermi="['data:channel-kio-tag:import']"> |
| | | <Icon icon="ep:upload" /> 导入 |
| | | </el-button> |
| | | <el-button |
| | | type="success" |
| | | plain |
| | | @click="handleExport" |
| | | :loading="exportLoading" |
| | | v-hasPermi="['data:channel-kio-tag:export']"> |
| | | <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> |
| | |
| | | align="center" |
| | | > |
| | | <template #default="scope"> |
| | | <el-tag v-if="scope.row.enabled === true" size="small">是</el-tag> |
| | | <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" |
| | | 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 |
| | |
| | | </ContentWrap> |
| | | <!-- 表单弹窗:添加/修改 --> |
| | | <TagForm ref="formRef" @success="getList" /> |
| | | <TagImportForm ref="importFormRef" @success="getList" /> |
| | | </el-drawer> |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import type { DrawerProps } from 'element-plus' |
| | | import * as KioTagApi from "@/api/data/channel/kio/tag"; |
| | | import TagForm from './TagForm.vue' |
| | | import download from "@/utils/download"; |
| | | 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'}) |
| | | |
| | |
| | | pageNo: 1, |
| | | pageSize: 10, |
| | | device: undefined, |
| | | deviceId: undefined, |
| | | currentValue:false, |
| | | tagName: undefined |
| | | }) |
| | | const queryFormRef = ref() // 搜索的表单 |
| | |
| | | } |
| | | |
| | | /** 打开弹窗 */ |
| | | 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() |
| | | } |
| | |
| | | const handleClose = (done: () => void) => { |
| | | drawer.value = false |
| | | } |
| | | |
| | | /** tag导入 */ |
| | | const importFormRef = ref() |
| | | const handleImport = () => { |
| | | if(queryParams.device){ |
| | | importFormRef.value.open(queryParams.device, '/data/channel/kio/tag/import',KioTagApi.importKioTagTemplate(), 'Kio', queryParams.device) |
| | | } |
| | | } |
| | | |
| | | /** 导出按钮操作 */ |
| | | const handleExport = async () => { |
| | | try { |
| | | // 导出的二次确认 |
| | | await message.exportConfirm() |
| | | // 发起导出 |
| | | exportLoading.value = true |
| | | const data = await KioTagApi.exportKioTag(queryParams) |
| | | download.excel(data, 'Kio_' + queryParams.device + '_Tag列表.xlsx') |
| | | } catch { |
| | | } finally { |
| | | 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> |