index.vue
13 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<template>
<div class="manage-container clerk-wrapper">
<el-row class="manage-head-wrapper">
<el-col :span="20">
<!-- 广场 -->
<div class="manage-select-box">
<el-select v-model="mallVal" class="mall-opt" filterable @change="chooseMall(mallVal)">
<el-option v-for="item in mallOpt" :label="item.name" :value="item.id" :key="item.value">
</el-option>
</el-select>
</div>
<div class="manage-select-box">
<el-select v-model="status" class="mall-opt" :placeholder='$t("pholder.state")'>
<el-option :label='$t("pholder.all")' value=""></el-option>
<el-option :label='$t("pholder.state1")' value="1"></el-option>
<el-option :label='$t("pholder.state2")' value="2"></el-option>
</el-select>
</div>
<el-button type="primary" class="search-btn" plain size="mini" @click="searchFun">
{{ $t('button.search')}}</el-button>
</el-col>
<el-col :span="4" :sm="4">
<div class="btn-box">
<el-button
type="primary"
size="mini"
class="manage-refresh-btn fl-btn"
@click='exportData'
>{{$t('allPages.load')}}</el-button>
</div>
</el-col>
</el-row>
<el-row class="manage-content">
<el-radio-group v-model="isRelation" class="relationTab" @change="radioChange">
<el-radio-button label="1">已关联监控点</el-radio-button>
<el-radio-button label="2">未关联监控点</el-radio-button>
</el-radio-group>
<el-table v-if="isRelation==1" v-loading="loading" :data="tableData" :max-height="tableHeight"
:span-method="objectSpanMethodAuto1">
<el-table-column prop="floorName" :label="$t('table.floorName')"></el-table-column>
<el-table-column prop="zoneName" :label="$t('table.shop')"></el-table-column>
<el-table-column prop="gateName" :label="$t('table.monitorSiteName')"></el-table-column>
<el-table-column prop="dataDirection" label="数据方向"></el-table-column>
<el-table-column prop="localIp" :label="$t('table.localIP')"></el-table-column>
<el-table-column prop="channelNo" label="通道号"></el-table-column>
<el-table-column prop="softwareVersion" :label="$t('dialog.swVersion')"></el-table-column>
<el-table-column prop="hardwareVersion" :label="$t('dialog.hwVersion')"></el-table-column>
<el-table-column :label="$t('table.operate')" width="100">
<template slot-scope="scope">
<el-button @click="editRow(scope.row)" type="text" size="small" class="tab-btn">
{{$t('button.look')}}</el-button>
</template>
</el-table-column>
</el-table>
<el-table v-if="isRelation==2" v-loading="loading" :data="tableData" :max-height="tableHeight"
:span-method="objectSpanMethodAuto2">
<el-table-column prop="floorName" :label="$t('table.floorName')"></el-table-column>
<el-table-column prop="gateName" :label="$t('table.monitorSiteName')"></el-table-column>
<el-table-column prop="status" :label="$t('table.state')"></el-table-column>
<el-table-column prop="type" label="监控点类型"></el-table-column>
<el-table-column prop="localIp" :label="$t('table.localIP')"></el-table-column>
<el-table-column prop="channelNo" label="通道号"></el-table-column>
<el-table-column prop="name" label="通道类型"></el-table-column>
<el-table-column prop="softwareVersion" :label="$t('dialog.swVersion')"></el-table-column>
<el-table-column prop="hardwareVersion" :label="$t('dialog.hwVersion')"></el-table-column>
<el-table-column :label="$t('table.operate')" width="100">
<template slot-scope="scope">
<el-button @click="editRow(scope.row)" type="text" size="small" class="tab-btn">
{{$t('button.look')}}</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
<el-dialog :title="$t('button.details')" class="manage-dialog"
:visible.sync="bindVisible" :close-on-click-modal="false" @close="bindVisible=false">
<div class="imgBox">
<el-image :src="imageUrl"></el-image>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
mallName: "",
mallVal: null,
mallOpt: [],
tableData: [],
loading: true,
isRelation: 1,
status: '',
rowIndexArr: [],
rowIndexArr1:[],
bindVisible:false,
imageUrl : ''
};
},
computed: {
tableHeight() {
const windowInnerHeight = window.innerHeight;
return windowInnerHeight - windowInnerHeight * 0.24;
}
},
mounted() {
this.getMallList();
},
methods: {
// 广场
getMallList() {
this.mallOpt = [];
this.mallVal = null;
this.mallName = "";
const storageMallVal = this.getSessionLocal("mallId")
this.$api.base.mall({
accountId: this.$cookie.get("accountId"),
status_arr: '1,3'
}, null, true).then(res => {
let result = res.data.data;
if (result.length > 0) {
this.mallOpt = result;
if (storageMallVal) {
this.mallVal = storageMallVal - 0;
const matchedMall = result.find(item => item.id === this.mallVal)
this.mallName = matchedMall.name;
} else {
this.mallVal = result[0].id;
this.setSessionLocal("mallId", this.mallVal);
this.mallName = result[0].name;
}
this.getTableData()
}
})
},
chooseMall(mallId) {
this.setSessionLocal("mallId", mallId);
const matchedMall = this.mallOpt.find(item => item.id == mallId)
this.mallName = matchedMall.name;
this.getTableData()
},
radioChange(data) {
this.getTableData()
},
getTableData() {
this.loading = true
this.tableData = [];
let tabelParams = {
mallId: this.mallVal,
status: this.status,
};
if (this.isRelation == 1) {
this.$api.management.getRelatedList(tabelParams, null, true).then(data => {
let result = data.data;
this.loading = false
this.tableData = result.data;
this.tableFilter(this.tableData)
})
} else {
this.$api.management.getUnrelatedList(tabelParams, null, true).then(data => {
let result = data.data;
this.loading = false
this.tableData = result.data;
this.tableFilter(this.tableData)
})
}
},
searchFun() {
this.getTableData();
},
tableFilter(tableData) {
let res = tableData
this.rowIndexArr = [];
this.rowIndexArr1 = []
res.reduce((result, currentVal, currentIndex) => {
// 将单元格合并的起始位0放到数组中
// 每次出现两个日期不相等时,说明之前的日期是相等的,此时需要合并,保存这个拐点的index,作为下一个合并的开始位置
if (result == 0 || result != currentVal.floorName) {
this.rowIndexArr.push(currentIndex)
}
return currentVal.floorName
}, 0)
// 最后将数据的长度保存起来,目的是最后一次合并时,知道要合并多少条数据
this.rowIndexArr.push(res.length)
if(this.isRelation==1){
res.reduce((result, currentVal, currentIndex) => {
// 将单元格合并的起始位0放到数组中
// 每次出现两个日期不相等时,说明之前的日期是相等的,此时需要合并,保存这个拐点的index,作为下一个合并的开始位置
if (result == 0 || result != currentVal.zoneName) {
this.rowIndexArr1.push(currentIndex)
}
return currentVal.zoneName
}, 0)
// 最后将数据的长度保存起来,目的是最后一次合并时,知道要合并多少条数据
this.rowIndexArr1.push(res.length)
}
},
objectSpanMethodAuto1({row, column, rowIndex,columnIndex}) {
if (columnIndex === 0) {
// 此时rowIndexArr存储了所有合并开始的点的索引,两个索引的差值,就是合并的项数
if (this.rowIndexArr.includes(rowIndex)) {
return {
rowspan: this.rowIndexArr[this.rowIndexArr.indexOf(rowIndex) + 1] - rowIndex,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 0
}
}
}
if (columnIndex === 1) {
// 此时rowIndexArr存储了所有合并开始的点的索引,两个索引的差值,就是合并的项数
if (this.rowIndexArr1.includes(rowIndex)) {
return {
rowspan: this.rowIndexArr1[this.rowIndexArr1.indexOf(rowIndex) + 1] - rowIndex,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 0
}
}
}
},
objectSpanMethodAuto2({row, column, rowIndex,columnIndex}) {
if (columnIndex === 0) {
// 此时rowIndexArr存储了所有合并开始的点的索引,两个索引的差值,就是合并的项数
if (this.rowIndexArr.includes(rowIndex)) {
return {
rowspan: this.rowIndexArr[this.rowIndexArr.indexOf(rowIndex) + 1] - rowIndex,
colspan: 1
}
} else {
return {
rowspan: 0,
colspan: 0
}
}
}
},
editRow(row){
this.bindVisible = true;
this.imageUrl = window._vionConfig.picUrl + "/snapshot/real/" + row.channelNo + ".jpg?t=" + Date.parse(new Date()) / 1000;
},
exportData(){
let token = this.$cookie.get("atoken");
let Url = `${window._vionConfig.apiUrl}/organizational/relationship/gate/download?mallId=${this.mallVal}&status=${this.status}&authorization=${token}`
window.open(Url);
}
}
};
</script>
<style scoped lang="less">
.manage-select-box .el-select {
width: 200px;
}
.manage-container {
height: 100%;
/deep/ .el-table .cell {
padding-right: 0;
}
/deep/.el-table tr {
cursor: pointer;
}
/deep/.el-table__body tr.current-row>td.el-table__cell {
background-color: #c8e1ff;
}
}
.manage-content {
height: calc(100% - 100px);
}
.relationTab {
margin-bottom: 15px;
}
.manage-dialog{
/deep/.el-dialog{
width: 800px !important;
.imgBox{
min-width: 200px;
min-height: 200px;
text-align: center;
.el-image__error{
width: 200px;
height: 200px;
}
}
}
}
</style>