doum
8 小时以前 d782070a1cdddf68d1b71e8e5dffb84f24543968
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<template>
  <TableLayout1 class="menu-layout" :permissions="['system:menu:query']">
    <template v-slot:menu>
      <div
          style="width: 100%; height: 50px; background: rgba(242, 242, 242, 1); line-height: 50px; text-align: center; font-size: 14px;">
        区域信息</div>
      <div style="width: 100%; height: calc(100vh - 170px); overflow-y: scroll;">
        <Tree :list="regionList" :defaultProps="{ name: 'name', status: 'fsStatus', children: 'childList', id: 'indexCode' }"  @callback="callback" />
      </div>
    </template>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" >
        <li><el-button type="primary"  icon="el-icon-refresh" :loading="isWorking.sort"  @click="refreshRegionData()">刷新缓存</el-button></li>
      </ul>
      <el-form ref="searchForm" slot="search-form"   label-width="100px" inline>
        <div class="platgroup_tabs">
          <div class="tab" :class="{ active: activeGroup === item.id }" @click="groupClick(item)"
               v-for="(item, i) in groupList" :key="i">
            {{ item.name }}
          </div>
        </div>
      </el-form>
      <el-table :height="tableHeightNew" v-loading="isWorking.search" :data="currentList" stripe @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column   prop="name" label="设备名称" min-width="120px">  </el-table-column>
        <el-table-column prop="indexCode" label="设备indexCode" min-width="200px"></el-table-column>
        <el-table-column prop="regionName" label="区域名称" min-width="200px"></el-table-column>
      </el-table>
      <!--    查看人员开卡记录    -->
    </template>
  </TableLayout1>
</template>
 
<script>
import TableLayout1 from '@/layouts/TableLayout1'
import BaseTable from '@/components/base/BaseTable'
import Tree from '@/components/common/Tree'
import { refreshRegionData, regionList } from '@/api/business/warning'
export default {
  name: 'regionDevice',
  extends: BaseTable,
  components: { TableLayout1, Tree },
  data: function () {
    return {
      regionList: [],
      curentReg: {},
      activeType: 0,
      activeGroup: 0,
      currentList: [],
      groupList: [{ id: 0, name: '监控点', type: 0 }, { id: 1, name: '消防设备', type: 1 }, { id: 2, name: '消防传感器', type: 2 }],
      isWorking: {
        sort: false
      }
    }
  },
  methods: {
    currentDataList () {
      this.currentList = []
      if (this.activeGroup === 0) {
        this.currentList = this.curentReg.carmeraList || []
      } else if (this.activeGroup === 1) {
        this.currentList = this.curentReg.deviceList || []
      } else if (this.activeGroup === 2) {
        this.currentList = this.curentReg.sensorList || []
      }
    },
    groupClick (item) {
      this.activeGroup = item.id
      this.activeType = item.type
      this.currentDataList()
      this.handlePageChange()
    },
    // 查询数据
    handlePageChange () {
    },
    // 排序
    refreshRegionData () {
      if (this.isWorking.sort) {
        return
      }
      this.isWorking.sort = true
      refreshRegionData({})
        .then(() => {
          this.loadRegions()
          this.$tip.apiSuccess('刷新成功!')
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking.sort = false
        })
    },
    loadRegions () {
      if (this.isWorking.loading) {
        return
      }
      this.isWorking.loading =true
      this.regionList = []
      this.curentReg = {}
      this.currentList = []
      regionList(1)
        .then(res => {
          if (res && res.length > 0) {
            res[0].fsStatus = 1
            this.regionList = res
            this.curentReg = res[0]
            this.currentDataList()
          }
        }) .catch(e => {
          })
          .finally(() => {
            this.isWorking.loading = false
          })
    },
    getDepartmentTree (tree) {
      if (tree == null) {
        return []
      }
      return tree.map(item => {
        const newItem = { ...item }
        if (newItem) {
          newItem.children = newItem.childList
        }
        if (item.children && item.children.length == 0) {
          this.$delete(newItem, 'children')
        } else {
          newItem.children = this.getDepartmentTree(newItem.children)
        }
 
        if (newItem.type === this.searchForm.companyType) {
          // newItem.disabled =false
        } else {
          newItem.disabled = true
        }
        return newItem
      })
    },
    callback (row) {
      console.log(row)
      this.curentReg = row
      this.currentDataList()
    }
  },
  created () {
    this.config({
      module: '菜单',
      api: '/system/menu'
    })
    this.loadRegions()
  }
}
</script>
 
<style lang="scss" scoped>
@import "@/assets/style/variables.scss";
.platgroup_tabs {
  flex: 1;
  display: flex;
  border-bottom: 1px solid #dfe2e8;
 
  .tab {
    color: #666666;
    margin-right: 40px;
    cursor: pointer;
    padding-bottom: 18px;
    border-bottom: 2px solid #fff;
  }
 
  .active {
    font-weight: 500;
    font-size: 15px;
    color: #222222;
    border-bottom: 2px solid $primary-color;
  }
}
.menu-layout {
  /deep/ .table-content {
    margin-top: 0px;
  }
}
// 图标列
.table-column-icon {
  // element-ui图标
  i {
    background-color: $primary-color;
    opacity: 0.72;
    font-size: 20px;
    color: #fff;
    padding: 4px;
    border-radius: 50%;
  }
  // 自定义图标
  [class^="eva-icon-"] {
    width: 20px;
    height: 20px;
    background-size: 16px;
    vertical-align: middle;
  }
}
</style>