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/modbus/tag/index.vue   |   72 ++++++-
 src/views/data/channel/opcua/tag/index.vue    |   22 ++
 src/views/data/channel/modbus/index.vue       |    6 
 src/views/data/channel/opcda/tag/index.vue    |   47 ++++
 src/views/data/channel/kio/index.vue          |    4 
 src/views/data/channel/kio/tag/index.vue      |   52 +++++
 src/views/data/channel/http/api/index.vue     |    2 
 src/views/data/channel/http/api/tag/index.vue |  253 ++++++++++++++-----------
 src/views/data/point/DaPointChart.vue         |   86 ++-----
 9 files changed, 355 insertions(+), 189 deletions(-)

diff --git a/src/views/data/channel/http/api/index.vue b/src/views/data/channel/http/api/index.vue
index 2fd6277..e3b06be 100644
--- a/src/views/data/channel/http/api/index.vue
+++ b/src/views/data/channel/http/api/index.vue
@@ -146,7 +146,7 @@
 
 /** TAG操作 */
 const tagRef = ref()
-const openTagList = (id?: string, name?:string) => {
+const openTagList = (id?: string,name?: string) => {
   tagRef.value.open(id,name)
 }
 
diff --git a/src/views/data/channel/http/api/tag/index.vue b/src/views/data/channel/http/api/tag/index.vue
index c2cd9fd..82cf55a 100644
--- a/src/views/data/channel/http/api/tag/index.vue
+++ b/src/views/data/channel/http/api/tag/index.vue
@@ -26,11 +26,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
@@ -39,7 +39,7 @@
             @click="openForm('create')"
             v-hasPermi="['data:channel-http:create']"
           >
-            <Icon icon="ep:plus" class="mr-5px" />
+            <Icon icon="ep:plus" class="mr-5px"/>
             新增
           </el-button>
           <el-button
@@ -47,7 +47,8 @@
             plain
             @click="handleImport"
             v-hasPermi="['data:channel-http-tag:import']">
-            <Icon icon="ep:upload" /> 导入
+            <Icon icon="ep:upload"/>
+            导入
           </el-button>
           <el-button
             type="success"
@@ -55,8 +56,15 @@
             @click="handleExport"
             :loading="exportLoading"
             v-hasPermi="['data:channel-http-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>
@@ -94,6 +102,25 @@
             <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">
           <template #default="scope">
             <el-button
@@ -124,126 +151,128 @@
       />
     </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 * as HttpTagApi from "@/api/data/channel/http/tag";
-import TagForm from './TagForm.vue'
-import download from "@/utils/download";
-import {ref} from "vue";
-import TagImportForm from '../../../common/tag/TagImportForm.vue'
+  import type {DrawerProps} from 'element-plus'
+  import * as HttpTagApi from "@/api/data/channel/http/tag";
+  import TagForm from './TagForm.vue'
+  import download from "@/utils/download";
+  import {ref} from "vue";
+  import {onBeforeUnmount, onMounted} from "vue";
+  import TagImportForm from '../../../common/tag/TagImportForm.vue'
 
-defineOptions({name: 'HttpTag'})
+  defineOptions({name: 'HttpTag'})
 
-const message = useMessage() // 消息弹窗
-const {t} = useI18n() // 国际化
+  const message = useMessage() // 消息弹窗
+  const {t} = useI18n() // 国际化
 
-const drawer = ref(false)
-const direction = ref<DrawerProps['direction']>('rtl')
-const loading = ref(true) // 列表的加载中
-const total = ref(0) // 列表的总页数
-const list = ref([]) // 列表的数据
-const queryParams = reactive({
-  pageNo: 1,
-  pageSize: 10,
-  apiId: undefined,
-  tagName: undefined,
-  httpName: undefined
-})
-const queryFormRef = ref() // 搜索的表单
-const exportLoading = ref(false) // 导出的加载中
+  const drawer = ref(false)
+  const direction = ref<DrawerProps['direction']>('rtl')
+  const loading = ref(true) // 列表的加载中
+  const total = ref(0) // 列表的总页数
+  const list = ref([]) // 列表的数据
+  const queryParams = reactive({
+    pageNo: 1,
+    pageSize: 10,
+    apiId: undefined,
+    tagName: undefined,
+    httpName: undefined,
+    currentValue:false,
+  })
+  const queryFormRef = ref() // 搜索的表单
+  const exportLoading = ref(false) // 导出的加载中
 
-/** 查询列表 */
-const getList = async () => {
-  loading.value = true
-  try {
-    const page = await HttpTagApi.getHttpTagPage(queryParams)
-    list.value = page.list
-    total.value = page.total
-  } finally {
-    loading.value = false
+  /** 查询列表 */
+  const getList = async () => {
+    loading.value = true
+    try {
+      const page = await HttpTagApi.getHttpTagPage(queryParams)
+      list.value = page.list
+      total.value = page.total
+    } finally {
+      loading.value = false
+    }
   }
-}
 
-/** 搜索按钮操作 */
-const handleQuery = () => {
-  queryParams.pageNo = 1
-  getList()
-}
-
-/** 重置按钮操作 */
-const resetQuery = () => {
-  queryFormRef.value.resetFields()
-  handleQuery()
-}
-
-/** 添加/修改操作 */
-const formRef = ref()
-const openForm = (type: string, id?: number) => {
-  formRef.value.open(type, id, queryParams.apiId)
-}
-
-/** 删除按钮操作 */
-const handleDelete = async (id: number) => {
-  try {
-    // 删除的二次确认
-    await message.delConfirm()
-    // 发起删除
-    await HttpTagApi.deleteHttpTag(id)
-    message.success(t('common.delSuccess'))
-    // 刷新列表
-    await getList()
-  } catch {
-  }
-}
-
-/** 打开弹窗 */
-const open = async (apiId?: string, name?:string) => {
-  resetForm()
-  drawer.value = true
-  queryParams.apiId = apiId
-  queryParams.httpName = name
-  if (apiId) {
+  /** 搜索按钮操作 */
+  const handleQuery = () => {
+    queryParams.pageNo = 1
     getList()
   }
-}
-defineExpose({open}) // 提供 open 方法,用于打开弹窗
 
-/** 重置表单 */
-const resetForm = () => {
-  queryParams.pageNo = 1
-  queryParams.pageSize = 10
-  queryParams.apiId = ''
-  queryParams.tagName = ''
-}
-
-const handleClose = (done: () => void) => {
-  drawer.value = false
-}
-
-/** tag导入 */
-const importFormRef = ref()
-const handleImport = () => {
-  if(queryParams.apiId){
-    importFormRef.value.open(queryParams.httpName, '/data/channel/http/tag/import',HttpTagApi.importHttpTagTemplate(), 'Http', queryParams.apiId)
+  /** 重置按钮操作 */
+  const resetQuery = () => {
+    queryFormRef.value.resetFields()
+    handleQuery()
   }
-}
 
-/** 导出按钮操作 */
-const handleExport = async () => {
-  try {
-    // 导出的二次确认
-    await message.exportConfirm()
-    // 发起导出
-    exportLoading.value = true
-    const data = await HttpTagApi.exportHttpTag(queryParams)
-    download.excel(data, 'Http_' + queryParams.httpName + '_Tag列表.xlsx')
-  } catch {
-  } finally {
-    exportLoading.value = false
+  /** 添加/修改操作 */
+  const formRef = ref()
+  const openForm = (type: string, id?: number) => {
+    formRef.value.open(type, id, queryParams.apiId)
   }
-}
+
+  /** 删除按钮操作 */
+  const handleDelete = async (id: number) => {
+    try {
+      // 删除的二次确认
+      await message.delConfirm()
+      // 发起删除
+      await HttpTagApi.deleteHttpTag(id)
+      message.success(t('common.delSuccess'))
+      // 刷新列表
+      await getList()
+    } catch {
+    }
+  }
+
+  /** 打开弹窗 */
+  const open = async (apiId?: string, name?: string) => {
+    resetForm()
+    drawer.value = true
+    queryParams.apiId = apiId
+    queryParams.httpName = name
+    if (apiId) {
+      getList()
+    }
+  }
+  defineExpose({open}) // 提供 open 方法,用于打开弹窗
+
+  /** 重置表单 */
+  const resetForm = () => {
+    queryParams.pageNo = 1
+    queryParams.pageSize = 10
+    queryParams.apiId = ''
+    queryParams.tagName = ''
+  }
+
+  const handleClose = (done: () => void) => {
+    drawer.value = false
+  }
+
+  /** tag导入 */
+  const importFormRef = ref()
+  const handleImport = () => {
+    if (queryParams.apiId) {
+      importFormRef.value.open(queryParams.httpName, '/data/channel/http/tag/import', HttpTagApi.importHttpTagTemplate(), 'Http', queryParams.apiId)
+    }
+  }
+
+  /** 导出按钮操作 */
+  const handleExport = async () => {
+    try {
+      // 导出的二次确认
+      await message.exportConfirm()
+      // 发起导出
+      exportLoading.value = true
+      const data = await HttpTagApi.exportHttpTag(queryParams)
+      download.excel(data, 'Http_' + queryParams.httpName + '_Tag列表.xlsx')
+    } catch {
+    } finally {
+      exportLoading.value = false
+    }
+  }
 </script>
diff --git a/src/views/data/channel/kio/index.vue b/src/views/data/channel/kio/index.vue
index dc9be25..ded1abb 100644
--- a/src/views/data/channel/kio/index.vue
+++ b/src/views/data/channel/kio/index.vue
@@ -145,8 +145,8 @@
 
   /** TAG操作 */
   const tagRef = ref()
-  const openTagList = (name?: string) => {
-    tagRef.value.open(name)
+  const openTagList = (id?: string,name?: string) => {
+    tagRef.value.open(id,name)
   }
 
   /** 删除按钮操作 */
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>
diff --git a/src/views/data/channel/modbus/index.vue b/src/views/data/channel/modbus/index.vue
index 58b0942..c97cada 100644
--- a/src/views/data/channel/modbus/index.vue
+++ b/src/views/data/channel/modbus/index.vue
@@ -75,7 +75,7 @@
           <el-button
             link
             type="primary"
-            @click="openTagList(scope.row.name)"
+            @click="openTagList(scope.row.id,scope.row.name)"
             v-hasPermi="['data:channel-modbus:update']"
           >
             TAG
@@ -161,8 +161,8 @@
 
   /** TAG操作 */
   const tagRef = ref()
-  const openTagList = (name?: string) => {
-    tagRef.value.open(name)
+  const openTagList = (id?: string,name?: string) => {
+    tagRef.value.open(id,name)
   }
 
   /** 删除按钮操作 */
diff --git a/src/views/data/channel/modbus/tag/index.vue b/src/views/data/channel/modbus/tag/index.vue
index 860d737..7739240 100644
--- a/src/views/data/channel/modbus/tag/index.vue
+++ b/src/views/data/channel/modbus/tag/index.vue
@@ -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,24 @@
             <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">
           <template #default="scope">
             <el-button
@@ -150,17 +176,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 +203,10 @@
   const queryParams = reactive({
     pageNo: 1,
     pageSize: 10,
+    deviceId: undefined,
     device: undefined,
     tagName: undefined,
+    currentValue:false,
     address: undefined
   })
   const queryFormRef = ref() // 搜索的表单
@@ -227,10 +257,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 +284,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 +303,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>
diff --git a/src/views/data/channel/opcda/tag/index.vue b/src/views/data/channel/opcda/tag/index.vue
index cfd1c01..17d4011 100644
--- a/src/views/data/channel/opcda/tag/index.vue
+++ b/src/views/data/channel/opcda/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>
     <!-- 列表 -->
@@ -85,6 +91,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">
@@ -128,6 +152,8 @@
   import download from "@/utils/download";
   import {ref,reactive} from "vue";
   import TagImportForm from '../../common/tag/TagImportForm.vue'
+  import {onBeforeUnmount, onMounted} from "vue";
+  import * as OpcdaTagApi from "@/api/data/channel/opcda/tag";
 
   defineOptions({name: 'ModBusTag'})
 
@@ -145,9 +171,11 @@
     serverId: undefined,
     tagName: undefined,
     serverName: undefined
+    currentValue:false,
   })
   const queryFormRef = ref() // 搜索的表单
   const exportLoading = ref(false) // 导出的加载中
+
   /** 查询列表 */
   const getList = async () => {
     loading.value = true
@@ -238,4 +266,23 @@
       exportLoading.value = false
     }
   }
+  let intervalId;
+
+  onMounted(async () => {
+    // 创建定时器
+    intervalId = setInterval(async () => {
+      if(queryParams.currentValue){
+        const page = await OpcdaTagApi.getOpcdaTagPage(queryParams)
+        list.value = page.list
+        total.value = page.total
+      }
+    }, 10000);
+  });
+
+  // 在组件卸载时清除定时器
+  onBeforeUnmount(() => {
+    if (intervalId) {
+      clearInterval(intervalId);
+    }
+  });
 </script>
diff --git a/src/views/data/channel/opcua/tag/index.vue b/src/views/data/channel/opcua/tag/index.vue
index 3f48f5b..1ef3fc1 100644
--- a/src/views/data/channel/opcua/tag/index.vue
+++ b/src/views/data/channel/opcua/tag/index.vue
@@ -108,6 +108,24 @@
             <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">
           <template #default="scope">
             <el-button
@@ -164,6 +182,7 @@
     pageNo: 1,
     pageSize: 10,
     device: undefined,
+    deviceId: undefined,
     tagName: undefined,
     address: undefined
   })
@@ -215,10 +234,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()
     }
diff --git a/src/views/data/point/DaPointChart.vue b/src/views/data/point/DaPointChart.vue
index ddc9a2d..305e0e7 100644
--- a/src/views/data/point/DaPointChart.vue
+++ b/src/views/data/point/DaPointChart.vue
@@ -10,21 +10,21 @@
       :model="dataForm"
       @keydown.enter="getDataList()"
     >
-      <el-form-item>
+      <el-form-item label="开始时间">
         <el-date-picker
+          size="mini"
           v-model="dataForm.startTime"
           type="datetime"
-          value-format="yyyy-MM-dd HH:mm:ss"
-          placeholder="选择日期时间"
-       />
+          :clearable="false"
+          placeholder="选择日期时间"/>
       </el-form-item>
-      <el-form-item>
+      <el-form-item label="结束时间">
         <el-date-picker
+          size="mini"
           v-model="dataForm.endTime"
           type="datetime"
-          value-format="yyyy-MM-dd HH:mm:ss"
-          placeholder="选择日期时间"
-        />
+          :clearable="false"
+          placeholder="选择日期时间"/>
       </el-form-item>
       <el-form-item>
         <el-button @click="getDataList()">查询</el-button>
@@ -49,67 +49,39 @@
   import {ref} from 'vue';
   import * as echarts from 'echarts';
   import * as DaPoint from '@/api/data/da/point/daPointChart'
+  import {getYMDHMS} from "@/utils/dateUtil"
   import download from "@/utils/download";
   const message = useMessage() // 消息弹窗
   const visible = ref(false);
   const chartDom = ref(null);
   let myChart = null;
-  const dataForm = ref({
-    id: "",
-    pointNo: "",
-    pointName: "",
-    pointTypeName: "",
-    startTime: getYMDHMS(),
-    endTime: undefined,
-  });
   const queryParams = reactive({
     codes: [],
     startDate: undefined,
     endDate: undefined,
   })
-  function getYMDHMS() {
-    let timestamp = new Date().getTime();
-    let time = new Date(timestamp - 1000 * 60 * 30);
-    let year = time.getFullYear();
-    let month = (time.getMonth() + 1).toString();
-    let date = time.getDate().toString();
-    let hours = time.getHours().toString();
-    let minute = time.getMinutes().toString();
+  const chartParams = reactive({
+    pointNos:[],
+    start : undefined,
+    end : undefined,
+  })
+  const dataForm = ref({
+    id: "",
+    pointNo: "",
+    pointName: "",
+    pointTypeName: "",
+    startTime: getYMDHMS(new Date() - 1000 * 60 * 60),
+    endTime: getYMDHMS(new Date()),
+  });
 
-    if (month < 10) {
-      month = "0" + month;
-    }
-    if (date < 10) {
-      date = "0" + date;
-    }
-    if (hours < 10) {
-      hours = "0" + hours;
-    }
-    if (minute < 10) {
-      minute = "0" + minute;
-    }
-    return (
-      year +
-      "-" +
-      month +
-      "-" +
-      date +
-      " " +
-      hours +
-      ":" +
-      minute +
-      ":" +
-      "00"
-    );
-  }
   /** 打开弹窗 */
   const open = async (row: object) => {
     visible.value = true
     dataForm.value.id = row.id;
     dataForm.value.pointNo = row.pointNo;
     dataForm.value.pointName = row.pointName;
-    dataForm.value.startTime = getYMDHMS();
-    dataForm.value.endTime = "";
+    dataForm.value.startTime = getYMDHMS(new Date(this.dataForm.startTime) - 1000 * 60 * 60);
+    dataForm.value.endTime = getYMDHMS(new Date(this.dataForm.endTime) - 1000 * 60 * 60),
     getDataList();
   }
 
@@ -120,8 +92,8 @@
     if (dataForm.value.id) {
       try {
         queryParams.codes=[dataForm.value.pointNo];
-        queryParams.startDate = dataForm.value.startTime;
-        queryParams.endDate = dataForm.value.endTime;
+        queryParams.startDate = getYMDHMS(new Date(this.dataForm.startTime) - 1000 * 60 * 60);
+        queryParams.endDate = getYMDHMS(new Date(this.dataForm.endTime) - 1000 * 60 * 60);
         const data = await DaPoint.getPointDaChart(queryParams)
         let seriesData = []
         data.series.forEach(item => {
@@ -196,9 +168,9 @@
   /** 导出按钮操作 */
   const exportLoading = ref(false)
   const handleExport = async () => {
-    queryParams.pointNos=[dataForm.value.pointNo];
-    queryParams.start = dataForm.value.startTime;
-    queryParams.end = dataForm.value.endTime;
+    chartParams.pointNos=[dataForm.value.pointNo];
+    chartParams.start = dataForm.value.startTime;
+    chartParams.end = dataForm.value.endTime;
     try {
       // 导出的二次确认
       await message.exportConfirm()

--
Gitblit v1.9.3