From c9ff2979fbf0b648240a22014e0d7c404f6899eb Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期四, 07 十一月 2024 17:40:42 +0800
Subject: [PATCH] pointChart bug 修复

---
 src/views/data/channel/opcua/tag/index.vue |   94 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/src/views/data/channel/opcua/tag/index.vue b/src/views/data/channel/opcua/tag/index.vue
index a535147..524f4b5 100644
--- a/src/views/data/channel/opcua/tag/index.vue
+++ b/src/views/data/channel/opcua/tag/index.vue
@@ -51,6 +51,21 @@
             <Icon icon="ep:plus" class="mr-5px" />
             新增
           </el-button>
+          <el-button
+            type="warning"
+            plain
+            @click="handleImport"
+            v-hasPermi="['data:channel-opcua-tag:import']">
+            <Icon icon="ep:upload" /> 导入
+          </el-button>
+          <el-button
+            type="success"
+            plain
+            @click="handleExport"
+            :loading="exportLoading"
+            v-hasPermi="['data:channel-opcua-tag:export']">
+            <Icon icon="ep:download" />导出
+          </el-button>
         </el-form-item>
       </el-form>
     </ContentWrap>
@@ -89,8 +104,26 @@
           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"
+          :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">
@@ -124,12 +157,17 @@
     </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 OpcuaTagApi from "@/api/data/channel/opcua/tag";
+  import * as OpcUaTagApi from "@/api/data/channel/opcua/tag";
   import TagForm from './TagForm.vue'
+  import download from "@/utils/download";
+  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'})
 
@@ -145,7 +183,9 @@
     pageNo: 1,
     pageSize: 10,
     device: undefined,
+    deviceId: undefined,
     tagName: undefined,
+    currentValue:false,
     address: undefined
   })
   const queryFormRef = ref() // 搜索的表单
@@ -155,7 +195,7 @@
   const getList = async () => {
     loading.value = true
     try {
-      const page = await OpcuaTagApi.getOpcuaTagPage(queryParams)
+      const page = await OpcUaTagApi.getOpcuaTagPage(queryParams)
       list.value = page.list
       total.value = page.total
     } finally {
@@ -187,7 +227,7 @@
       // 删除的二次确认
       await message.delConfirm()
       // 发起删除
-      await OpcuaTagApi.deleteOpcuaTag(id)
+      await OpcUaTagApi.deleteOpcuaTag(id)
       message.success(t('common.delSuccess'))
       // 刷新列表
       await getList()
@@ -196,10 +236,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()
     }
@@ -218,4 +259,47 @@
   const handleClose = (done: () => void) => {
     drawer.value = false
   }
+
+  /** tag导入 */
+  const importFormRef = ref()
+  const handleImport = () => {
+    if(queryParams.device){
+      importFormRef.value.open(queryParams.device, '/data/channel/opcua/tag/import',OpcUaTagApi.importOpcUaTagTemplate(), 'OpcUa', queryParams.device)
+    }
+  }
+
+  /** 导出按钮操作 */
+  const handleExport = async () => {
+    try {
+      // 导出的二次确认
+      await message.exportConfirm()
+      // 发起导出
+      exportLoading.value = true
+      const data = await OpcUaTagApi.exportOpcUaTag(queryParams)
+      download.excel(data, 'OpcUa_' + queryParams.device + '_Tag列表.xlsx')
+    } catch {
+    } finally {
+      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