潘志宝
2024-11-04 fd1845889744a82334799291674709de0971657a
src/views/data/channel/kio/tag/index.vue
@@ -24,15 +24,6 @@
            class="!w-240px"
          />
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input
            v-model="queryParams.address"
            placeholder="请输入Modbus地址"
            clearable
            @keyup.enter="handleQuery"
            class="!w-240px"
          />
        </el-form-item>
        <el-form-item>
          <el-button @click="handleQuery">
            <Icon icon="ep:search" class="mr-5px" />
@@ -50,6 +41,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>
@@ -84,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>
@@ -119,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'})
@@ -211,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>