From fd1845889744a82334799291674709de0971657a Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 04 十一月 2024 08:28:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/data/channel/opcua/tag/TagForm.vue        |   10 
 src/views/data/channel/common/tag/TagImportForm.vue |  147 ++++++++++++++++
 src/views/data/channel/opcua/tag/index.vue          |   50 +++++
 src/views/data/channel/opcda/tag/TagForm.vue        |   10 
 src/views/data/channel/kio/tag/TagForm.vue          |   10 
 src/api/data/channel/opcua/tag.ts                   |   10 +
 src/views/data/channel/http/api/tag/TagForm.vue     |   10 
 src/views/data/channel/http/api/index.vue           |    6 
 src/api/data/channel/modbus/tag.ts                  |   10 +
 src/views/data/channel/modbus/tag/index.vue         |   47 ++++
 src/api/data/channel/opcda/tag.ts                   |   10 +
 src/views/data/channel/modbus/tag/TagForm.vue       |    6 
 src/views/data/channel/opcda/index.vue              |    6 
 src/api/data/channel/http/tag.ts                    |   10 +
 src/views/data/channel/opcda/tag/index.vue          |   61 +++++-
 src/views/data/channel/kio/tag/index.vue            |   44 ++++
 src/api/data/channel/kio/tag.ts                     |   10 +
 src/views/data/channel/http/api/tag/index.vue       |   58 +++++
 18 files changed, 462 insertions(+), 53 deletions(-)

diff --git a/src/api/data/channel/http/tag.ts b/src/api/data/channel/http/tag.ts
index dfead66..281ab32 100644
--- a/src/api/data/channel/http/tag.ts
+++ b/src/api/data/channel/http/tag.ts
@@ -37,3 +37,13 @@
 export const deleteHttpTag = (id: number) => {
   return request.delete({ url: '/data/channel/http/tag/delete?id=' + id })
 }
+
+//导出HttpTag
+export const exportHttpTag = (params) => {
+  return request.download({ url: '/data/channel/http/tag/export', params })
+}
+
+// 下载用户导入模板
+export const importHttpTagTemplate = () => {
+  return request.download({ url: '/data/channel/http/tag/get-import-template' })
+}
diff --git a/src/api/data/channel/kio/tag.ts b/src/api/data/channel/kio/tag.ts
index 32a714e..b1ab25f 100644
--- a/src/api/data/channel/kio/tag.ts
+++ b/src/api/data/channel/kio/tag.ts
@@ -40,3 +40,13 @@
 export const deleteKioTag = (id: number) => {
   return request.delete({ url: '/data/channel/kio/tag/delete?id=' + id })
 }
+
+//导出KioTag
+export const exportKioTag = (params) => {
+  return request.download({ url: '/data/channel/kio/tag/export', params })
+}
+
+// 下载用户导入模板
+export const importKioTagTemplate = () => {
+  return request.download({ url: '/data/channel/kio/tag/get-import-template' })
+}
diff --git a/src/api/data/channel/modbus/tag.ts b/src/api/data/channel/modbus/tag.ts
index a6299df..5f49c61 100644
--- a/src/api/data/channel/modbus/tag.ts
+++ b/src/api/data/channel/modbus/tag.ts
@@ -41,3 +41,13 @@
 export const deleteModBusTag = (id: number) => {
   return request.delete({ url: '/data/channel/modbus/tag/delete?id=' + id })
 }
+
+//导出ModBusTag
+export const exportModBusTag = (params) => {
+  return request.download({ url: '/data/channel/modbus/tag/export', params })
+}
+
+// 下载用户导入模板
+export const importModBusTagTemplate = () => {
+  return request.download({ url: '/data/channel/modbus/tag/get-import-template' })
+}
diff --git a/src/api/data/channel/opcda/tag.ts b/src/api/data/channel/opcda/tag.ts
index 4f90eb1..089f2a8 100644
--- a/src/api/data/channel/opcda/tag.ts
+++ b/src/api/data/channel/opcda/tag.ts
@@ -38,3 +38,13 @@
 export const deleteOpcdaTag = (id: number) => {
   return request.delete({ url: '/data/channel/opcda/tag/delete?id=' + id })
 }
+
+//导出OpcdaTag
+export const exportOpcDaTag = (params) => {
+  return request.download({ url: '/data/channel/opcda/tag/export', params })
+}
+
+// 下载用户导入模板
+export const importOpcDaTagTemplate = () => {
+  return request.download({ url: '/data/channel/opcda/tag/get-import-template' })
+}
diff --git a/src/api/data/channel/opcua/tag.ts b/src/api/data/channel/opcua/tag.ts
index e1373fb..6f21a1d 100644
--- a/src/api/data/channel/opcua/tag.ts
+++ b/src/api/data/channel/opcua/tag.ts
@@ -39,3 +39,13 @@
 export const deleteOpcuaTag = (id: number) => {
   return request.delete({ url: '/data/channel/opcua/tag/delete?id=' + id })
 }
+
+//导出OpcdaTag
+export const exportOpcUaTag = (params) => {
+  return request.download({ url: '/data/channel/opcua/tag/export', params })
+}
+
+// 下载用户导入模板
+export const importOpcUaTagTemplate = () => {
+  return request.download({ url: '/data/channel/opcua/tag/get-import-template' })
+}
diff --git a/src/views/data/channel/common/tag/TagImportForm.vue b/src/views/data/channel/common/tag/TagImportForm.vue
new file mode 100644
index 0000000..20baf6c
--- /dev/null
+++ b/src/views/data/channel/common/tag/TagImportForm.vue
@@ -0,0 +1,147 @@
+<template>
+  <Dialog v-model="dialogVisible" title="Tag导入" width="400">
+    <el-upload
+      ref="uploadRef"
+      v-model:file-list="fileList"
+      :action="importUrl + '?updateSupport=' + updateSupport + '&device=' + parameter"
+      :auto-upload="false"
+      :disabled="formLoading"
+      :headers="uploadHeaders"
+      :limit="1"
+      :on-error="submitFormError"
+      :on-exceed="handleExceed"
+      :on-success="submitFormSuccess"
+      accept=".xlsx, .xls"
+      drag
+    >
+      <Icon icon="ep:upload" />
+      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+      <template #tip>
+        <div class="el-upload__tip text-center">
+          <div class="el-upload__tip">
+            <el-checkbox v-model="updateSupport" />
+            是否更新已经存在的Tag数据
+          </div>
+          <span>仅允许导入 xls、xlsx 格式文件。</span>
+          <el-link
+            :underline="false"
+            style="font-size: 12px; vertical-align: baseline"
+            type="primary"
+            @click="importTemplate"
+          >
+            下载模板
+          </el-link>
+        </div>
+      </template>
+    </el-upload>
+    <template #footer>
+      <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
+      <el-button @click="dialogVisible = false">取 消</el-button>
+    </template>
+  </Dialog>
+</template>
+<script lang="ts" setup>
+
+import { getAccessToken, getTenantId } from '@/utils/auth'
+import download from '@/utils/download'
+import * as ModBusTagApi from "@/api/data/channel/modbus/tag"
+
+defineOptions({ name: 'PointImportForm' })
+
+const message = useMessage() // 消息弹窗
+
+const dialogVisible = ref(false) // 弹窗的是否展示
+const formLoading = ref(false) // 表单的加载中
+const uploadRef = ref()
+const importUrl = ref()
+const uploadHeaders = ref() // 上传 Header 头
+const fileList = ref([]) // 文件列表
+const updateSupport = ref(0) // 是否更新已经存在的测点数据
+const decName = ref()
+const typeName = ref()
+const parameter = ref()
+let importTemplateApi = reactive()
+/** 打开弹窗 */
+const open = (name?: string, url?:string, tagApi?:Object, type?:string, params?:string) => {
+  importTemplateApi = tagApi
+  dialogVisible.value = true
+  updateSupport.value = 0
+  fileList.value = []
+  decName.value = name
+  typeName.value = type
+  parameter.value = params
+  importUrl.value =  import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL + url
+  resetForm()
+}
+defineExpose({ open }) // 提供 open 方法,用于打开弹窗
+
+/** 提交表单 */
+const submitForm = async () => {
+  if (fileList.value.length == 0) {
+    message.error('请上传文件')
+    return
+  }
+  // 提交请求
+  uploadHeaders.value = {
+    Authorization: 'Bearer ' + getAccessToken(),
+    'tenant-id': getTenantId()
+  }
+  formLoading.value = true
+  uploadRef.value!.submit()
+}
+
+/** 文件上传成功 */
+const emits = defineEmits(['success'])
+const submitFormSuccess = (response: any) => {
+  if (response.code !== 0) {
+    message.error(response.msg)
+    formLoading.value = false
+    return
+  }
+  // 拼接提示语
+  const data = response.data
+  let text = '上传成功数量:' + data.createTagNames.length + ';'
+  for (let tagName of data.createTagNames) {
+    text += '< ' + tagName + ' >'
+  }
+  text += '更新成功数量:' + data.updateTagNames.length + ';'
+  for (const tagName of data.updateTagNames) {
+    text += '< ' + tagName + ' >'
+  }
+  text += '更新失败数量:' + Object.keys(data.failureTagNames).length + ';'
+  for (const tagName in data.failureTagNames) {
+    text += '< ' + tagName + ': ' + data.failureTagNames[tagName] + ' >'
+  }
+  message.alert(text)
+  formLoading.value = false
+  dialogVisible.value = false
+  // 发送操作成功的事件
+  emits('success')
+}
+
+/** 上传错误提示 */
+const submitFormError = (): void => {
+  message.error('上传失败,请您重新上传!')
+  formLoading.value = false
+}
+
+/** 重置表单 */
+const resetForm = async (): Promise<void> => {
+  // 重置上传状态和文件
+  formLoading.value = false
+  await nextTick()
+  uploadRef.value?.clearFiles()
+}
+
+/** 文件数超出提示 */
+const handleExceed = (): void => {
+  message.error('最多只能上传一个文件!')
+}
+
+/** 下载模板操作 */
+const importTemplate = async () => {
+  const res = await importTemplateApi
+  const excelName = typeName.value + '_' + decName.value + '_' + 'Tag导入模板.xlsx'
+  download.excel(res, excelName)
+}
+</script>
diff --git a/src/views/data/channel/http/api/index.vue b/src/views/data/channel/http/api/index.vue
index f3a7c9d..2fd6277 100644
--- a/src/views/data/channel/http/api/index.vue
+++ b/src/views/data/channel/http/api/index.vue
@@ -61,7 +61,7 @@
           <el-button
             link
             type="primary"
-            @click="openTagList(scope.row.id)"
+            @click="openTagList(scope.row.id, scope.row.name)"
             v-hasPermi="['data:channel-http:update']"
           >
             TAG
@@ -146,8 +146,8 @@
 
 /** TAG操作 */
 const tagRef = ref()
-const openTagList = (id?: string) => {
-  tagRef.value.open(id)
+const openTagList = (id?: string, name?:string) => {
+  tagRef.value.open(id,name)
 }
 
 /** 删除按钮操作 */
diff --git a/src/views/data/channel/http/api/tag/TagForm.vue b/src/views/data/channel/http/api/tag/TagForm.vue
index 210c944..5d61c53 100644
--- a/src/views/data/channel/http/api/tag/TagForm.vue
+++ b/src/views/data/channel/http/api/tag/TagForm.vue
@@ -31,7 +31,7 @@
           <el-form-item label="是否启用" prop="enabled">
             <el-select v-model="formData.enabled" placeholder="请选择">
               <el-option
-                v-for="dict in getBoolDictOptions(DICT_TYPE.IS_ENABLED)"
+                v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -56,8 +56,8 @@
 </template>
 <script lang="ts" setup>
 import * as HttpTagApi from '@/api/data/channel/http/tag'
-import { CommonEnabledBool } from '@/utils/constants'
-import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict'
+import {CommonEnabled} from '@/utils/constants'
+import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
 
 defineOptions({name: 'HttpTagForm'})
 
@@ -73,7 +73,7 @@
   tagName: undefined,
   dataType: undefined,
   tagDesc: '',
-  enabled: CommonEnabledBool.ENABLE,
+  enabled: CommonEnabled.ENABLE,
 })
 const formRules = reactive({
   tagName: [{required: true, message: 'Tag名称不能为空', trigger: 'blur'}],
@@ -136,7 +136,7 @@
     tagName: undefined,
     dataType: undefined,
     tagDesc: '',
-    enabled: CommonEnabledBool.ENABLE,
+    enabled: CommonEnabled.ENABLE,
   }
   formRef.value?.resetFields()
 }
diff --git a/src/views/data/channel/http/api/tag/index.vue b/src/views/data/channel/http/api/tag/index.vue
index 4fbca5b..c2cd9fd 100644
--- a/src/views/data/channel/http/api/tag/index.vue
+++ b/src/views/data/channel/http/api/tag/index.vue
@@ -2,7 +2,7 @@
   <el-drawer
     v-model="drawer"
     size="50%"
-    title="Kio Tag"
+    title="Http Tag"
     :direction="direction"
     :before-close="handleClose"
   >
@@ -37,10 +37,25 @@
             type="primary"
             plain
             @click="openForm('create')"
-            v-hasPermi="['data:channel-kio:create']"
+            v-hasPermi="['data:channel-http:create']"
           >
             <Icon icon="ep:plus" class="mr-5px" />
             新增
+          </el-button>
+          <el-button
+            type="warning"
+            plain
+            @click="handleImport"
+            v-hasPermi="['data:channel-http-tag:import']">
+            <Icon icon="ep:upload" /> 导入
+          </el-button>
+          <el-button
+            type="success"
+            plain
+            @click="handleExport"
+            :loading="exportLoading"
+            v-hasPermi="['data:channel-http-tag:export']">
+            <Icon icon="ep:download" />导出
           </el-button>
         </el-form-item>
       </el-form>
@@ -75,7 +90,7 @@
           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>
@@ -85,7 +100,7 @@
               link
               type="primary"
               @click="openForm('update', scope.row.id)"
-              v-hasPermi="['data:channel-kio:update']"
+              v-hasPermi="['data:channel-http:update']"
             >
               编辑
             </el-button>
@@ -93,7 +108,7 @@
               link
               type="danger"
               @click="handleDelete(scope.row.id)"
-              v-hasPermi="['data:channel-kio:delete']"
+              v-hasPermi="['data:channel-http:delete']"
             >
               删除
             </el-button>
@@ -110,12 +125,16 @@
     </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 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'
 
 defineOptions({name: 'HttpTag'})
 
@@ -131,7 +150,8 @@
   pageNo: 1,
   pageSize: 10,
   apiId: undefined,
-  tagName: undefined
+  tagName: undefined,
+  httpName: undefined
 })
 const queryFormRef = ref() // 搜索的表单
 const exportLoading = ref(false) // 导出的加载中
@@ -181,10 +201,11 @@
 }
 
 /** 打开弹窗 */
-const open = async (apiId?: string) => {
+const open = async (apiId?: string, name?:string) => {
   resetForm()
   drawer.value = true
   queryParams.apiId = apiId
+  queryParams.httpName = name
   if (apiId) {
     getList()
   }
@@ -202,4 +223,27 @@
 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/tag/TagForm.vue b/src/views/data/channel/kio/tag/TagForm.vue
index ff2fc72..ad6da51 100644
--- a/src/views/data/channel/kio/tag/TagForm.vue
+++ b/src/views/data/channel/kio/tag/TagForm.vue
@@ -36,7 +36,7 @@
           <el-form-item label="是否启用" prop="enabled">
             <el-select v-model="formData.enabled" placeholder="请选择">
               <el-option
-                v-for="dict in getBoolDictOptions(DICT_TYPE.IS_ENABLED)"
+                v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -61,9 +61,9 @@
 </template>
 <script lang="ts" setup>
   import * as KioTagApi from '@/api/data/channel/kio/tag'
-  import { CommonEnabledBool } from '@/utils/constants'
+  import {CommonEnabled} from '@/utils/constants'
   import {isPositiveInteger} from '@/utils/validate'
-  import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict'
+  import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
 
   defineOptions({name: 'KioTagForm'})
 
@@ -79,7 +79,7 @@
     dataType: undefined,
     tagId: undefined,
     tagDesc: '',
-    enabled: CommonEnabledBool.ENABLE,
+    enabled: CommonEnabled.ENABLE,
     device: undefined,
     samplingRate: undefined
 
@@ -152,7 +152,7 @@
       dataType: undefined,
       tagId: undefined,
       tagDesc: '',
-      enabled: CommonEnabledBool.ENABLE,
+      enabled: CommonEnabled.ENABLE,
       device: undefined,
       samplingRate: undefined
     }
diff --git a/src/views/data/channel/kio/tag/index.vue b/src/views/data/channel/kio/tag/index.vue
index 990c389..47f38fe 100644
--- a/src/views/data/channel/kio/tag/index.vue
+++ b/src/views/data/channel/kio/tag/index.vue
@@ -42,6 +42,21 @@
             <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>
     </ContentWrap>
@@ -75,7 +90,7 @@
           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>
@@ -110,12 +125,16 @@
     </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 {ref} from "vue";
+  import TagImportForm from '../../common/tag/TagImportForm.vue'
 
   defineOptions({name: 'KioTag'})
 
@@ -202,4 +221,27 @@
   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
+    }
+  }
 </script>
diff --git a/src/views/data/channel/modbus/tag/TagForm.vue b/src/views/data/channel/modbus/tag/TagForm.vue
index a8ec15d..d248a96 100644
--- a/src/views/data/channel/modbus/tag/TagForm.vue
+++ b/src/views/data/channel/modbus/tag/TagForm.vue
@@ -55,7 +55,7 @@
           <el-form-item label="是否启用" prop="enabled">
             <el-select v-model="formData.enabled" placeholder="请选择">
               <el-option
-                v-for="dict in getBoolDictOptions(DICT_TYPE.IS_ENABLED)"
+                v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -82,7 +82,7 @@
   import * as ModBusTagApi from '@/api/data/channel/modbus/tag'
   import { CommonEnabled } from '@/utils/constants'
   import {isPositiveInteger} from '@/utils/validate'
-  import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict'
+  import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
 
   defineOptions({name: 'ModBusTagForm'})
 
@@ -98,7 +98,7 @@
     dataType: undefined,
     enabled: CommonEnabled.ENABLE,
     format: undefined,
-    device: '1',
+    device: '',
     address: '',
     samplingRate: undefined,
     tagDesc: '',
diff --git a/src/views/data/channel/modbus/tag/index.vue b/src/views/data/channel/modbus/tag/index.vue
index 335b5e1..860d737 100644
--- a/src/views/data/channel/modbus/tag/index.vue
+++ b/src/views/data/channel/modbus/tag/index.vue
@@ -46,10 +46,24 @@
             type="primary"
             plain
             @click="openForm('create')"
-            v-hasPermi="['data:channel-modbus:create']"
-          >
+            v-hasPermi="['data:channel-modbus:create']">
             <Icon icon="ep:plus" class="mr-5px" />
             新增
+          </el-button>
+          <el-button
+            type="warning"
+            plain
+            @click="handleImport"
+            v-hasPermi="['data:channel-modbus-tag:import']">
+            <Icon icon="ep:upload" /> 导入
+          </el-button>
+          <el-button
+            type="success"
+            plain
+            @click="handleExport"
+            :loading="exportLoading"
+            v-hasPermi="['data:channel-modbus-tag:export']">
+            <Icon icon="ep:download" />导出
           </el-button>
         </el-form-item>
       </el-form>
@@ -102,7 +116,7 @@
           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>
@@ -137,12 +151,16 @@
     </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 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'
 
   defineOptions({name: 'ModBusTag'})
 
@@ -231,4 +249,27 @@
   const handleClose = (done: () => void) => {
     drawer.value = false
   }
+
+  /** tag导入 */
+  const importFormRef = ref()
+  const handleImport = () => {
+    if(queryParams.device){
+      importFormRef.value.open(queryParams.device, '/data/channel/modbus/tag/import',ModBusTagApi.importModBusTagTemplate(), 'ModBus', queryParams.device)
+    }
+  }
+
+  /** 导出按钮操作 */
+  const handleExport = async () => {
+    try {
+      // 导出的二次确认
+      await message.exportConfirm()
+      // 发起导出
+      exportLoading.value = true
+      const data = await ModBusTagApi.exportModBusTag(queryParams)
+      download.excel(data, 'ModBus_' + queryParams.device + '_Tag列表.xlsx')
+    } catch {
+    } finally {
+      exportLoading.value = false
+    }
+  }
 </script>
diff --git a/src/views/data/channel/opcda/index.vue b/src/views/data/channel/opcda/index.vue
index b538779..6481531 100644
--- a/src/views/data/channel/opcda/index.vue
+++ b/src/views/data/channel/opcda/index.vue
@@ -60,7 +60,7 @@
           <el-button
             link
             type="primary"
-            @click="openTagList(scope.row.id)"
+            @click="openTagList(scope.row.id,scope.row.serverName)"
             v-hasPermi="['data:channel-opcda:update']"
           >
             TAG
@@ -145,8 +145,8 @@
 
   /** TAG操作 */
   const tagRef = ref()
-  const openTagList = (id?: string) => {
-    tagRef.value.open(id)
+  const openTagList = (id?: string,serverName?:string) => {
+    tagRef.value.open(id,serverName)
   }
 
   /** 删除按钮操作 */
diff --git a/src/views/data/channel/opcda/tag/TagForm.vue b/src/views/data/channel/opcda/tag/TagForm.vue
index 9f4b6ab..813b9ca 100644
--- a/src/views/data/channel/opcda/tag/TagForm.vue
+++ b/src/views/data/channel/opcda/tag/TagForm.vue
@@ -36,7 +36,7 @@
           <el-form-item label="是否启用" prop="enabled">
             <el-select v-model="formData.enabled" placeholder="请选择">
               <el-option
-                v-for="dict in getBoolDictOptions(DICT_TYPE.IS_ENABLED)"
+                v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -54,8 +54,8 @@
 </template>
 <script lang="ts" setup>
   import * as OpcdaTagApi from '@/api/data/channel/opcda/tag'
-  import { CommonEnabledBool } from '@/utils/constants'
-  import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict'
+  import {CommonEnabled} from '@/utils/constants'
+  import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
 
   defineOptions({name: 'OpcdaTagForm'})
 
@@ -70,7 +70,7 @@
     serverId: undefined,
     tagName: undefined,
     dataType: undefined,
-    enabled: CommonEnabledBool.ENABLE,
+    enabled: CommonEnabled.ENABLE,
     itemId: undefined
   })
   const formRules = reactive({
@@ -133,7 +133,7 @@
       serverId: undefined,
       tagName: undefined,
       dataType: undefined,
-      enabled: CommonEnabledBool.ENABLE,
+      enabled: CommonEnabled.ENABLE,
       itemId: undefined
     }
     formRef.value?.resetFields()
diff --git a/src/views/data/channel/opcda/tag/index.vue b/src/views/data/channel/opcda/tag/index.vue
index 98f57da..cfd1c01 100644
--- a/src/views/data/channel/opcda/tag/index.vue
+++ b/src/views/data/channel/opcda/tag/index.vue
@@ -2,7 +2,7 @@
   <el-drawer
     v-model="drawer"
     size="50%"
-    title="ModBus Tag"
+    title="OpcDA Tag"
     :direction="direction"
     :before-close="handleClose"
   >
@@ -37,10 +37,25 @@
             type="primary"
             plain
             @click="openForm('create')"
-            v-hasPermi="['data:channel-modbus:create']"
+            v-hasPermi="['data:channel-opcda:create']"
           >
             <Icon icon="ep:plus" class="mr-5px" />
             新增
+          </el-button>
+          <el-button
+            type="warning"
+            plain
+            @click="handleImport"
+            v-hasPermi="['data:channel-opcda-tag:import']">
+            <Icon icon="ep:upload" /> 导入
+          </el-button>
+          <el-button
+            type="success"
+            plain
+            @click="handleExport"
+            :loading="exportLoading"
+            v-hasPermi="['data:channel-opcda-tag:export']">
+            <Icon icon="ep:download" />导出
           </el-button>
         </el-form-item>
       </el-form>
@@ -68,7 +83,7 @@
           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>
@@ -103,12 +118,16 @@
     </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 OpcdaTagApi from "@/api/data/channel/opcda/tag";
+  import * as OpcDaTagApi from "@/api/data/channel/opcda/tag";
   import TagForm from './TagForm.vue'
+  import download from "@/utils/download";
+  import {ref,reactive} from "vue";
+  import TagImportForm from '../../common/tag/TagImportForm.vue'
 
   defineOptions({name: 'ModBusTag'})
 
@@ -124,16 +143,16 @@
     pageNo: 1,
     pageSize: 10,
     serverId: undefined,
-    tagName: undefined
+    tagName: undefined,
+    serverName: undefined
   })
   const queryFormRef = ref() // 搜索的表单
   const exportLoading = ref(false) // 导出的加载中
-
   /** 查询列表 */
   const getList = async () => {
     loading.value = true
     try {
-      const page = await OpcdaTagApi.getOpcdaTagPage(queryParams)
+      const page = await OpcDaTagApi.getOpcdaTagPage(queryParams)
       list.value = page.list
       total.value = page.total
     } finally {
@@ -165,7 +184,7 @@
       // 删除的二次确认
       await message.delConfirm()
       // 发起删除
-      await OpcdaTagApi.deleteOpcdaTag(id)
+      await OpcDaTagApi.deleteOpcdaTag(id)
       message.success(t('common.delSuccess'))
       // 刷新列表
       await getList()
@@ -174,10 +193,11 @@
   }
 
   /** 打开弹窗 */
-  const open = async (serverId?: string) => {
+  const open = async (serverId?: string, serverName?: string) => {
     resetForm()
     drawer.value = true
     queryParams.serverId = serverId
+    queryParams.serverName = serverName
     if (serverId) {
       getList()
     }
@@ -195,4 +215,27 @@
   const handleClose = (done: () => void) => {
     drawer.value = false
   }
+
+  /** tag导入 */
+  const importFormRef = ref()
+  const handleImport = () => {
+    if(queryParams.serverId){
+      importFormRef.value.open(queryParams.serverName, '/data/channel/opcda/tag/import',OpcDaTagApi.importOpcDaTagTemplate(), 'OpcDa', queryParams.serverId)
+    }
+  }
+
+  /** 导出按钮操作 */
+  const handleExport = async () => {
+    try {
+      // 导出的二次确认
+      await message.exportConfirm()
+      // 发起导出
+      exportLoading.value = true
+      const data = await OpcDaTagApi.exportOpcDaTag(queryParams)
+      download.excel(data, 'OpcDa_' + queryParams.serverName + '_Tag列表.xlsx')
+    } catch {
+    } finally {
+      exportLoading.value = false
+    }
+  }
 </script>
diff --git a/src/views/data/channel/opcua/tag/TagForm.vue b/src/views/data/channel/opcua/tag/TagForm.vue
index 810fbff..adb01a8 100644
--- a/src/views/data/channel/opcua/tag/TagForm.vue
+++ b/src/views/data/channel/opcua/tag/TagForm.vue
@@ -36,7 +36,7 @@
           <el-form-item label="是否启用" prop="enabled">
             <el-select v-model="formData.enabled" placeholder="请选择">
               <el-option
-                v-for="dict in getBoolDictOptions(DICT_TYPE.IS_ENABLED)"
+                v-for="dict in getIntDictOptions(DICT_TYPE.COM_IS_INT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -54,8 +54,8 @@
 </template>
 <script lang="ts" setup>
   import * as OpcuaTagApi from '@/api/data/channel/opcua/tag'
-  import { CommonEnabledBool } from '@/utils/constants'
-  import { DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict'
+  import {CommonEnabled} from '@/utils/constants'
+  import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
 
   defineOptions({name: 'OpcuaTagForm'})
 
@@ -70,7 +70,7 @@
     device: undefined,
     tagName: undefined,
     dataType: undefined,
-    enabled: CommonEnabledBool.ENABLE,
+    enabled: CommonEnabled.ENABLE,
     address: undefined,
     samplingRate: undefined
   })
@@ -134,7 +134,7 @@
       device: undefined,
       tagName: undefined,
       dataType: undefined,
-      enabled: CommonEnabledBool.ENABLE,
+      enabled: CommonEnabled.ENABLE,
       address: undefined,
       samplingRate: undefined
     }
diff --git a/src/views/data/channel/opcua/tag/index.vue b/src/views/data/channel/opcua/tag/index.vue
index a535147..3f48f5b 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,7 +104,7 @@
           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>
@@ -124,12 +139,16 @@
     </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} from "vue";
+  import TagImportForm from '../../common/tag/TagImportForm.vue'
 
   defineOptions({name: 'OpcuaTag'})
 
@@ -155,7 +174,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 +206,7 @@
       // 删除的二次确认
       await message.delConfirm()
       // 发起删除
-      await OpcuaTagApi.deleteOpcuaTag(id)
+      await OpcUaTagApi.deleteOpcuaTag(id)
       message.success(t('common.delSuccess'))
       // 刷新列表
       await getList()
@@ -218,4 +237,27 @@
   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
+    }
+  }
 </script>

--
Gitblit v1.9.3