MrShi
3 天以前 43dc204f89527ba402666ba92345efbfe751f297
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<template>
    <GlobalWindow
        :title="title"
        width="100%"
        :visible.sync="visible"
        :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>
            <el-form-item label="状态" prop="status">
                <el-select v-model="searchForm.status" placeholder="请选择" @change="getList">
                    <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="bindStatus">
                <el-select v-model="searchForm.bindStatus" placeholder="请选择" @change="getList">
                    <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>
                <el-button type="primary" @click="getList">搜索</el-button>
            </el-form-item>
            <el-form-item>
                <el-button @click="reset">重置</el-button>
            </el-form-item>
        </el-form>
        <ul class="toolbar">
            <li><el-button type="primary">批量解绑</el-button></li>
        </ul>
        <el-table
            v-loading="loading"
            :data="list"
            stripe
        >
            <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"></el-table-column>
            <el-table-column label="状态" min-width="100px">
                <template slot-scope="{row}">
                    <el-switch
                        v-model="row.status"
                        active-color="#13ce66"
                        inactive-color="#ff4949"
                        :active-value="0"
                        :inactive-value="1">
                    </el-switch>
                </template>
            </el-table-column>
            <el-table-column label="运行状态" min-width="100px">
                <template slot-scope="{row}">
                    <el-link type="success" v-if="row.workingStatus === 0">正常</el-link>
                    <el-link type="warning" v-if="row.workingStatus === 1">故障</el-link>
                </template>
            </el-table-column>
            <el-table-column label="柜格状态" min-width="100px">
                <template slot-scope="{row}">
                    <el-link type="warning" v-if="row.bindStatus === 0">未绑定</el-link>
                    <el-link type="success" v-if="row.bindStatus === 1">已绑定</el-link>
                </template>
            </el-table-column>
            <el-table-column
                label="操作"
                min-width="100"
                fixed="right"
            >
                <template slot-scope="{row}">
                    <el-button type="text" v-if="row.bindStatus === 0">绑定</el-button>
                    <el-button type="text" v-if="row.bindStatus === 1">解绑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div style="width: 100%; text-align: right; margin-top: 20px">
            <el-pagination
                @current-change="handleCurrentChange"
                :current-page="page"
                :page-size="10"
                layout="total, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </div>
    </GlobalWindow>
</template>
 
<script>
  import BaseOpera from '@/components/base/BaseOpera'
  import GlobalWindow from '@/components/common/GlobalWindow'
  import { fetchList } from '@/api/business/jkCabinetGrid'
  export default {
    name: 'cabinetDetails',
    extends: BaseOpera,
    components: { GlobalWindow },
    data () {
      return {
        id: null,
        info: null,
        searchForm: {
          keyId: '',
          status: '',
          bindStatus: ''
        },
        list: [],
        page: 1,
        total: 0,
        loading: false
      }
    },
    methods: {
      open (title, id) {
        this.title = title
        this.id = id
        this.getList()
        this.visible = true
      },
      handleCurrentChange(e) {
        this.page = e
        this.getList()
      },
      reset() {
        this.searchForm.keyId = ''
        this.searchForm.status = ''
        this.searchForm.workingStatus = ''
        this.page = 1
        this.getList()
      },
      getList() {
        this.loading = true
        fetchList({
          capacity: 10,
          page: this.page,
          model: {
            cabinetId: this.id,
            keyId: this.searchForm.keyId,
            status: this.searchForm.status,
            workingStatus: this.searchForm.workingStatus
          }
        }).then(res => {
          console.log(res)
          this.list = res.records
          this.total = res.total
        }).finally(() => {
          this.loading = false
        })
      }
    }
  }
</script>