MrShi
2026-01-13 3a154bdb0a5aaa2c0ac3eac95a6ba747068bd454
admin/src/views/business/jkCabinet.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,149 @@
<template>
  <TableLayout :permissions="['business:jkcabinet:query']">
    <!-- æœç´¢è¡¨å• -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="设备编号" prop="code">
        <el-input v-model="searchForm.code" placeholder="请输入设备编号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="设备名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入设备名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="运行状态" prop="runStatus">
        <el-select v-model="searchForm.runStatus" placeholder="请选择" @change="search">
          <el-option label="全部" value=""></el-option>
          <el-option label="在线" :value="0"></el-option>
          <el-option label="离线" :value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="searchForm.status" placeholder="请选择" @change="search">
          <el-option label="全部" value=""></el-option>
          <el-option label="启用" :value="0"></el-option>
          <el-option label="禁用" :value="1"></el-option>
        </el-select>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- è¡¨æ ¼å’Œåˆ†é¡µ -->
    <template v-slot:table-wrap>
      <ul class="toolbar" v-permissions="['business:jkcabinet:create', 'business:jkcabinet:delete']">
        <li><el-button type="primary" @click="$refs.operaJkCabinetWindow.open('新建设备')" icon="el-icon-plus" v-permissions="['business:jkcabinet:create']">新建</el-button></li>
        <li><el-button type="warning" @click="$refs.alcoholTest.open('新建酒精检测配置', form)">酒精检测配置</el-button></li>
      </ul>
      <el-table
        :height="tableHeightNew"
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
      >
        <el-table-column prop="code" label="设备编号" min-width="100px"></el-table-column>
        <el-table-column prop="name" label="设备名称" min-width="100px"></el-table-column>
        <el-table-column prop="devId" label="设备ID" min-width="100px"></el-table-column>
        <el-table-column prop="linkAddr" label="通讯地址" min-width="100px"></el-table-column>
        <el-table-column prop="port" label="端口号" min-width="100px"></el-table-column>
        <el-table-column prop="location" label="所在位置" min-width="100px"></el-table-column>
        <el-table-column label="柜格数量" min-width="100px">
          <template slot-scope="{row}">
            <el-button @click="$refs.cabinetDetails.open(row.name + '-柜格信息', row.id)">{{row.gridNum}}</el-button>
          </template>
        </el-table-column>
        <el-table-column label="运行状态" min-width="100px">
          <template slot-scope="{row}">
            <el-link type="success" :underline="false" v-if="row.runStatus === 0">在线</el-link>
            <el-link type="danger" :underline="false" v-if="row.runStatus === 1">离线</el-link>
          </template>
        </el-table-column>
        <el-table-column label="状态" min-width="100px">
          <template slot-scope="{row}">
            <el-switch
              v-model="row.status"
              @change="changeStatus($event, row.id)"
              active-color="#13ce66"
              inactive-color="#ff4949"
              :active-value="0"
              :inactive-value="1">
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column
          v-if="containPermissions(['business:jkcabinet:update', 'business:jkcabinet:delete'])"
          label="操作"
          min-width="200"
          fixed="right"
        >
          <template slot-scope="{row}">
            <el-button type="text" @click="$refs.cabinetDetails.open(row.name + '-柜格信息', row.id)">绑定钥匙</el-button>
            <el-button type="text" @click="$refs.operaJkCabinetWindow.open('编辑钥匙柜基本信息表', row)" v-permissions="['business:jkcabinet:update']">编辑</el-button>
            <el-button type="text" @click="deleteById(row)" v-permissions="['business:jkcabinet:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      >
      </pagination>
    </template>
    <!-- æ–°å»º/修改 -->
    <OperaJkCabinetWindow ref="operaJkCabinetWindow" @success="handlePageChange"/>
    <!-- æŸœå­è¯¦æƒ… -->
    <CabinetDetails ref="cabinetDetails" />
    <!-- æ–°å¢žé…’精检测 -->
    <AlcoholTest ref="alcoholTest" @success="GetCabinetConfig" />
  </TableLayout>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaJkCabinetWindow from '@/components/business/OperaJkCabinetWindow'
import CabinetDetails from '@/components/business/cabinetDetails'
import AlcoholTest from '@/components/business/alcoholTest'
import { updateStatusById, getCabinetConfig } from '@/api/business/jkCabinet'
export default {
  name: 'JkCabinet',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaJkCabinetWindow, CabinetDetails, AlcoholTest},
  data () {
    return {
      // æœç´¢
      searchForm: {
        code: '',
        name: '',
        status: '',
        runStatus: ''
      },
      form: null
    }
  },
  created () {
    this.config({
      module: '钥匙柜基本信息表',
      api: '/business/jkCabinet',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
    this.GetCabinetConfig()
  },
  methods: {
    changeStatus(status, id) {
      updateStatusById({ id, status })
        .then(res => {
          this.search()
        })
    },
    GetCabinetConfig() {
      getCabinetConfig()
        .then(res => {
          this.form = res
        })
    }
  }
}
</script>