fence-old.vue
14 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<template>
<v-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
<el-breadcrumb-item>围栏管理</el-breadcrumb-item>
</template>
<template slot="main">
<div class="ibox">
<!-- 表单查询 -->
<el-form :inline="true" ref="form" :model="form" >
<el-form-item>
<el-select v-model="form.dateType" style="width:100px;" placeholder="请选择" size="small">
<el-option label="创建时间" value="1"></el-option>
<el-option label="监控时间" value="2"></el-option>
</el-select>
<el-date-picker
v-model="form.dateRange"
size="small"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="form.status" placeholder="请选择" size="small" style="width:90px;">
<el-option label="全部" value="3"></el-option>
<el-option label="已开启" value="1"></el-option>
<el-option label="已关闭" value="0"></el-option>
</el-select>
</el-form-item>
<el-form-item label="监控类型">
<el-select v-model="form.electricFenceType" placeholder="请选择" size="small" style="width:100px;">
<el-option label="全部" value=""></el-option>
<el-option label="驶入" value="1"></el-option>
<el-option label="驶出" value="2"></el-option>
<el-option label="驶入驶出" value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-input placeholder="请输入对应条件值" v-model="form.queryTerm" size="small" class="input-with-select" maxlength="50" clearable>
<el-select v-model="form.queryType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
<el-option label="围栏名称" value="1"></el-option>
<el-option label="围栏编号" value="2"></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="query" size="small" :loading="queryLoading">查询</el-button>
</el-form-item>
</el-form>
<!-- 表单查询 /-->
</div>
<div class="ibox">
<div class="ibox-title">
<h3 class="pull-left">围栏管理</h3>
<el-button type="primary" plain size="small" class="pull-right ibox-ctrl" @click="exportExcel">导出excel <i class="fa fa-download"></i></el-button>
<el-button type="primary" plain size="small" class="pull-right ibox-ctrl" @click="addFence">新增围栏 <i class="fa fa-plus"></i></el-button>
</div>
<div class="ibox-content">
<el-table
:data="tableData"
border
size="small"
v-loading="loading"
@selection-change="selectChange"
style="width: 100%">
<el-table-column type="selection" width="40" align="center"></el-table-column>
<el-table-column fixed type="index" label="序号" :index="getIndex" align="center" width="70"></el-table-column>
<el-table-column fixed prop="fenceNo" label="围栏编号" min-width="160" align="center"></el-table-column>
<el-table-column fixed prop="electricFenceName" label="围栏名称" min-width="160" align="center"></el-table-column>
<el-table-column prop="electricFenceType" label="监控类型" min-width="100" align="center">
<template slot-scope="scope">
<span v-if="scope.row.electricFenceType=='1'">驶入</span>
<span v-if="scope.row.electricFenceType=='2'">驶出</span>
<span v-if="scope.row.electricFenceType=='3'">驶入驶出</span>
</template>
</el-table-column>
<el-table-column label="监控时间" min-width="160" align="center">
<template slot-scope="scope">
{{scope.row.startTime}}<br/>{{scope.row.endTime}}
</template>
</el-table-column>
<el-table-column prop="monitorArea" label="监控区域" min-width="200" align="center"></el-table-column>
<el-table-column prop="relNum" label="关联用户数" min-width="100" align="center"></el-table-column>
<el-table-column prop="status" label="状态" min-width="100" align="center">
<template slot-scope="scope">
<span v-if="scope.row.status=='0'">已关闭</span>
<span v-if="scope.row.status=='1'">已开启</span>
<span v-if="scope.row.status=='2'">已删除</span>
</template>
</el-table-column>
<el-table-column prop="createDate" label="创建时间" min-width="160" align="center"></el-table-column>
<el-table-column prop="userName" label="创建人" min-width="120" align="center"></el-table-column>
<el-table-column fixed="right" label="操作" min-width="160" align="center">
<template slot-scope="scope">
<el-button @click="toggleFenceStatus(scope.row)" type="text" size="medium">
<span v-show="scope.row.status=='0'">开启</span>
<span v-show="scope.row.status=='1'">关闭</span>
</el-button>
<el-button @click="editFence(scope.row.id)" type="text" size="medium">编辑</el-button>
<el-button @click="deleteFence(scope.row.id)" type="text" size="medium">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="table-page-wrap">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 20, 30, 40]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</div>
</div>
<!-- 围栏编辑新增弹框 -->
<fence-modal
:fenceId="fenceId"
:fenceModalVisible="fenceModalVisible"
@onUpdateList="getData"
@onFenceModalChange="fenceModalChange"
@onFenceMapModalChange="fenceMapModalChange"
@onUserListModalChange="userListModalChange"
@onUserListInit="(res)=>userListInit=res"
:mapData="mapForm"
:userData="userArr"
@onUpdateUserData="updateUserData"
@onUpdateMapData="updateMapData">
</fence-modal>
<!-- 围栏编辑新增弹框 /-->
<!-- 围栏调用地图弹框 -->
<fence-map-modal
:fenceMapModalVisible="fenceMapModalVisible"
@onFenceMapModalChange="fenceMapModalChange"
:mapData="mapForm"
@onUpdateMapData="updateMapData">
</fence-map-modal>
<!-- 围栏调用地图弹框 /-->
<!-- 关联用户弹框 -->
<user-list-modal
:userData="userArr"
:init="userListInit"
@onUserListInit="(res)=>userListInit=res"
@onUpdateUserData="updateUserData"
:userListModalVisible="userListModalVisible"
@onUserListModalChange="userListModalChange">
</user-list-modal>
<!-- 关联用户弹框 /-->
</template>
</v-layout>
</template>
<script>
import vDateRange from 'components/DateRange.vue'
import vVechicleSelect from 'components/VechicleSelect.vue'
import fenceModal from './fenceModal.vue'
import fenceMapModal from './fenceMapModal.vue'
import userListModal from './userListModal.vue'
import {services} from '../../api'
import {CONSTANT} from '../../constant'
const MONITOR_SERVICE = services.monitor;
export default{
data(){
return {
queryLoading: false,
loading: true,
currentPage: 1,
pageSize: 10,
total: 0,
tableData: [],
form: {
dateType: '',
dateRange: '',
status: '3',
electricFenceType: '',
queryType: '1',
queryTerm: ''
},
mapForm: {
lng: '',
lat: '',
address: '',
radius: ''
},
userArr: [],
userListInit: false,
selectedIds: [],
fenceModalVisible: false,
fenceId: undefined,
fenceMapModalVisible: false,
userListModalVisible: false
}
},
created(){
this.getData();
},
computed: {
},
methods: {
getIndex(index){
return (this.currentPage-1)*this.pageSize+index+1;
},
query(){
this.currentPage = 1;
this.pageSize = 10;
this.getData();
},
getData(curr=this.currentPage, size=this.pageSize){
this.loading = true;
let params = this.getParams();
params.currentPage = curr;
params.pageSize = size;
this.queryLoading = true;
MONITOR_SERVICE.getFenceList(params).then((response)=>{
if(Array.isArray(response.data)){
this.tableData = response.data;
this.total = response.recordsTotal;
}else{
this.tableData = [];
this.total = 0;
}
this.loading = false;
this.queryLoading = false;
});
},
getParams(){
const form = this.form;
const params = {};
if(form.dateRange && form.dateRange.length){
form.sTime = moment(form.dateRange[0]).format('YYYY-MM-DD HH:mm:ss');
form.eTime = moment(form.dateRange[1]).format('YYYY-MM-DD HH:mm:ss');
}else{
form.sTime = '';
form.eTime = '';
}
if(form.sTime&&form.eTime){
if(form.dateType ==2){
params.sMonitorTime = form.sTime;
params.eMonitorTime = form.eTime;
}
if(form.dateType ==1){
params.sTime = form.sTime;
params.eTime = form.eTime;
}
}
params.status = form.status;
if(form.electricFenceType){
params.electricFenceType = form.electricFenceType;
}
if(form.groupId){
params.groupId = form.groupId;
}
if(form.classIdList){
params.classIdList = form.classIdList;
}
const queryTerm = form.queryTerm.trim();
if(queryTerm){
switch(form.queryType){
case '1':
params.electricFenceName = queryTerm;
break;
case '2':
params.fenceNo = queryTerm;
break;
}
}
return params;
},
dateRangeChange(dateArr){
if(dateArr && dateArr.length){
this.form.sTime = dateArr[0].format('YYYY-MM-DD HH:mm:ss');
this.form.eTime = dateArr[1].format('YYYY-MM-DD HH:mm:ss');
}else{
this.form.sTime = '';
this.form.eTime = '';
}
},
toggleFenceStatus(obj){
const tip = obj.status == 0?'开启':'关闭';
this.$confirm('确定要'+tip+'该围栏吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
MONITOR_SERVICE.updateFenceStatus({id: obj.id}).then((res)=>{
if(res.returnCode == 0){
this.$message({
message: res.message,
type: 'success'
});
obj.status = obj.status==0?1:0;
}
});
});
},
resetMapForm(){
this.mapForm.lng = '';
this.mapForm.lat = '';
this.mapForm.address = '';
this.mapForm.radius = '';
},
addFence(){
this.resetMapForm();
this.fenceId = undefined;
this.userArr = [];
this.fenceModalVisible = true;
},
editFence(id){
this.resetMapForm();
this.fenceId = id;
this.userArr = [];
this.fenceModalVisible = true;
},
deleteFence(id){
this.$confirm('确定要删除该围栏吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
MONITOR_SERVICE.deleteFence({id: id}).then((res)=>{
if(res.returnCode == 0){
this.$message({
message: res.message,
type: 'success'
});
this.getData()
}
});
});
},
selectChange(selection){
this.selectedIds = [];
selection.map((obj)=>{
this.selectedIds.push(obj.id)
});
},
handleSizeChange(val) {
this.pageSize = val;
this.getData(this.currentPage,this.pageSize)
},
handleCurrentChange(val) {
this.currentPage = val;
this.getData(val)
},
onSubmit(){
this.getParams()
},
fenceModalChange(isOpen){
this.fenceModalVisible = isOpen;
},
fenceMapModalChange(isOpen, mapData){
this.fenceMapModalVisible = isOpen;
},
updateMapData(data){
if(data){
this.mapForm.lng = data.lng;
this.mapForm.lat = data.lat;
this.mapForm.address = data.address;
this.mapForm.radius = data.radius;
}else{
this.mapForm.lng = '';
this.mapForm.lat = '';
this.mapForm.address = '';
this.mapForm.radius = '';
}
},
userListModalChange(isOpen){
this.userListModalVisible = isOpen;
},
updateUserData(data){
this.userArr = data;
},
exportExcel(){
if(this.selectedIds.length){
this.exportForm(CONSTANT.API_URL+'ecFence/exportFence', {idList: this.selectedIds.join(',')})
}else{
this.exportForm(CONSTANT.API_URL+'ecFence/exportFence', this.getParams())
}
},
exportForm(url,oParam,formId){
if(!formId){
formId = 'exportForm';
}
let exportForm = document.querySelector("#"+formId);
if(exportForm){
document.body.removeChild(exportForm)
}
exportForm = document.createElement('form');
exportForm.id = 'exportForm';
exportForm.action = url;
exportForm.method = 'get';
exportForm.attributes['accept-charset'] = 'utf-8';
exportForm.style.display = 'none';
document.body.appendChild(exportForm);
let _input = '';
for(let key in oParam){
_input+='<input type="hidden" name="'+key+'" id="'+key+'" value="'+(oParam[key])+'"/>';
}
exportForm.innerHTML = _input;
exportForm.submit();
}
},
components:{
vDateRange,
vVechicleSelect,
fenceModal,
fenceMapModal,
userListModal
}
}
</script>
<style scoped>
</style>