潘志宝
2024-11-04 fd1845889744a82334799291674709de0971657a
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>