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/modbus/tag/index.vue |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

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>

--
Gitblit v1.9.3