doum
2025-10-29 dd6a43fdbadaaf6d646b3eb2ca0a63f58ed77ea4
admin/src/components/business/cabinetDetails.vue
@@ -6,8 +6,8 @@
        :withFooter="false"
    >
        <el-form ref="searchForm" :model="searchForm" label-width="100px" inline>
            <el-form-item label="钥匙" prop="keyId">
                <el-input v-model="searchForm.keyId" placeholder="请输入钥匙编码或名称" @keypress.enter.native="getList"></el-input>
            <el-form-item label="钥匙编码" prop="keyCode">
                <el-input v-model="searchForm.keyCode" placeholder="请输入钥匙编码" @keypress.enter.native="getList"></el-input>
            </el-form-item>
            <el-form-item label="状态" prop="status">
                <el-select v-model="searchForm.status" placeholder="请选择" @change="getList">
@@ -31,35 +31,38 @@
            </el-form-item>
        </el-form>
        <ul class="toolbar">
            <li><el-button type="primary">批量解绑</el-button></li>
            <li><el-button type="primary" @click="bathUnBindKeys">批量解绑</el-button></li>
        </ul>
        <el-table
            v-loading="loading"
            :data="list"
            stripe
            @selection-change="handleSelectionChange"
        >
            <el-table-column type="selection" width="55"></el-table-column>
            <el-table-column prop="code" label="柜格编码" min-width="100px"></el-table-column>
            <el-table-column prop="cabinetName" label="所属钥匙柜" min-width="100px"></el-table-column>
            <el-table-column prop="keyId" label="绑定钥匙" min-width="100px">
                <template slot-scope="{row}">
                    <el-select v-model="row.keyId" placeholder="请选择">
                    <el-select v-model="row.keyId" placeholder="请选择" @change="blurFunc($event, row, 1)">
                        <el-option
                            v-for="item in keysAll"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                            :label="item.code"
                            :value="item.id"
                            :disabled="item.status !== 0">
                        </el-option>
                    </el-select>
                </template>
            </el-table-column>
            <el-table-column label="板号" min-width="100px">
                <template slot-scope="{row}">
                    <el-input v-model="row.boardCode" placeholder="请输入板号"></el-input>
                    <el-input v-model="row.boardCode" @blur="blurFunc($event, row, 2)" placeholder="请输入板号"></el-input>
                </template>
            </el-table-column>
            <el-table-column label="通道号" min-width="100px">
                <template slot-scope="{row}">
                    <el-input v-model="row.channelCode" placeholder="请输入通道号"></el-input>
                    <el-input v-model="row.channelCode" @blur="blurFunc($event, row, 3)" placeholder="请输入通道号"></el-input>
                </template>
            </el-table-column>
            <el-table-column label="状态" min-width="100px">
@@ -93,7 +96,8 @@
<script>
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import { fetchList, updateStatusById } from '@/api/business/jkCabinetGrid'
  import { fetchList, updateStatusById, unBindKeys, updateById } from '@/api/business/jkCabinetGrid'
  import { list } from '@/api/business/jkKeys'
  export default {
    name: 'cabinetDetails',
    extends: BaseOpera,
@@ -102,8 +106,9 @@
      return {
        id: null,
        info: null,
        ids: [],
        searchForm: {
          keyId: '',
          keyCode: '',
          status: '',
          bindStatus: ''
        },
@@ -116,8 +121,68 @@
      open (title, id) {
        this.title = title
        this.id = id
        this.searchForm = {
          keyCode: '',
          status: '',
          bindStatus: ''
        }
        this.getList()
        this.getKeysAll()
        this.visible = true
      },
      handleSelectionChange(e) {
        this.ids = e.map(item => item.id)
      },
      getKeysAll() {
        list({  })
            .then(res => {
              this.keysAll = res
            })
      },
      blurFunc(e, row, type) {
        let obj = {
          id: row.id
        }
        if (type === 1) {
          obj.keyId = row.keyId
        } else if (type === 2) {
          if (!row.boardCode) return
          if (!/^[1-9]\d*$/.test(row.boardCode)) {
            this.$message.warning('只能输入正整数')
            row.boardCode = ''
            return
          }
          obj.boardCode = row.boardCode
        } else if (type === 3) {
          if (!row.channelCode) return
          if (!/^[1-9]\d*$/.test(row.channelCode)) {
            this.$message.warning('只能输入正整数')
            row.channelCode = ''
            return
          }
          obj.channelCode = row.channelCode
        }
        updateById(obj)
            .then(res => {
              this.getList()
              if (type === 1) {
                this.getKeysAll()
              }
            })
      },
      bathUnBindKeys() {
        this.$confirm('确认批量解绑吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          unBindKeys(this.ids)
            .then(res => {
              this.getList()
            })
        }).catch(() => {
        });
      },
      changeStatus(status, id) {
        updateStatusById({ id, status })
@@ -130,9 +195,9 @@
        this.getList()
      },
      reset() {
        this.searchForm.keyId = ''
        this.searchForm.keyCode = ''
        this.searchForm.status = ''
        this.searchForm.workingStatus = ''
        this.searchForm.bindStatus = ''
        this.getList()
      },
      getList() {
@@ -144,6 +209,7 @@
            cabinetId: this.id,
            keyId: this.searchForm.keyId,
            status: this.searchForm.status,
            bindStatus: this.searchForm.bindStatus,
            workingStatus: this.searchForm.workingStatus
          }
        }).then(res => {