alarmFocus.vue
8.52 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
<template>
<v-layout>
<template slot="breadcrumb" style="position: relative">
<el-breadcrumb-item>统计报表</el-breadcrumb-item>
<el-breadcrumb-item class="last">警情中心</el-breadcrumb-item>
<p style="font-weight:bold; padding-top: 10px;font-size:20px;">我的关注</p>
<p>展示我关注车辆以及车辆的报警动态</p>
</template>
<template slot="main">
<div class="ibox ibox-search">
<!-- 表单查询 -->
<el-form :inline="true" :rules="rules" ref="form" :model="form">
<el-form-item prop="queryTerm">
<el-input placeholder="请输入对应条件值" v-model="form.queryTerm" size="small" class="input-with-select" clearable>
<el-select v-model="form.queryType" slot="prepend" style="width:100px;" placeholder="请选择" size="small">
<el-option label="工单号" value="sqbh"></el-option>
<el-option label="车架号" value="standno"></el-option>
<el-option label="姓名" value="name"></el-option>
<el-option label="设备号" value="sn"></el-option>
</el-select>
</el-input>
</el-form-item>
<!-- 车辆分组分类组件 -->
<v-vechicle-select ref="vechicle" label="车辆归属:" @onVechicleChange="vechicleChange"></v-vechicle-select>
<!-- 车辆分组分类组件 /-->
<el-form-item>
<el-button type="primary" @click="onSubmit('form')" size="small">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="resetForm('form')" size="small">重置</el-button>
</el-form-item>
</el-form>
<!-- 表单查询 /-->
</div>
<div class="ibox">
<div class="ibox-title">
<el-button type="primary" plain size="small" class="pull-right ibox-ctrl" @click="exportExcel">导出excel <i class="fa fa-download"></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 :render-header="renderHeader" width="300" align="center">
<template slot-scope="scope">
<div>
{{scope.row.sqbh}}/{{scope.row.name}}/{{scope.row.sn}}
<br/>{{scope.row.standno}}
</div>
</template>
</el-table-column>
<el-table-column prop="attentionTime" label="关注时间" min-width="160" align="center"></el-table-column>
<el-table-column prop="alarmLevel" label="警情等级" min-width="80" align="center">
<template slot-scope="scope">
<div>
{{scope.row.alarmLevel}}
<i class="fa fa-long-arrow-down" v-if="scope.row.alarmStauts===1" style="color:red;"></i>
<i class="fa fa-long-arrow-up" v-if="scope.row.alarmStauts===0" v-else style="color:red;"></i>
</div>
</template>
</el-table-column>
<el-table-column prop="sn" label="报警说明&建议" min-width="220" align="left">
<template slot-scope="scope">
<div>
说明:{{scope.row.alarmExplain}}
<br/>建议:{{scope.row.alarmSuggest}}
</div>
</template>
</el-table-column>
<el-table-column prop="alarmTime" label="报警时间" min-width="180" align="center"></el-table-column>
<el-table-column fixed="right" label="操作" width="140" align="center">
<template slot-scope="scope">
<el-row style="padding: 10px 0">
<el-col :span="12">
<el-badge v-if="scope.row.unread!=0" :value="scope.row.unread" class="item">
<el-button @click="openDetail(scope.row)" type="text" size="medium">详情</el-button>
</el-badge>
<el-button v-else @click="openDetail(scope.row)" type="text" size="medium">详情</el-button>
</el-col>
<el-col :span="12">
<el-button type="text" size="medium" @click="cancelFocus(scope.row.vehicleId)">取消关注</el-button>
</el-col>
</el-row>
</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>
</template>
</v-layout>
</template>
<script>
import vDateRange from 'components/DateRange.vue'
const vVechicleSelect = () => import(/* webpackChunkName: "vVechicleSelect" */ 'components/VechicleSelect.vue');
import {exportExcel} from 'utils'
import {services} from '../../api'
const REPORT_SERVICE = services.report;
export default{
data(){
return {
loading: true,
currentPage: 1,
pageSize: 10,
total: 0,
tableData: [],
search: '',
form: {
date: moment().subtract(1, 'days'),
classIdList: '',
groupId: '',
queryType: 'sqbh',
queryTerm: ''
},
selectedIds: [],
label: '工单号/姓名/设备号<br/>车架号'
}
},
created(){
this.getData();
},
computed: {
},
methods: {
getIndex(index){
return (this.currentPage-1)*this.pageSize+index+1;
},
getData(curr=this.currentPage, size=this.pageSize){
this.loading = true;
let params = this.getParams();
params.currentPage = curr;
params.pageSize = size;
REPORT_SERVICE.getAlarmFocusList(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;
});
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.$refs.vechicle.resetSelet();
},
getParams(){
const form = this.form;
const params = {};
if(form.groupId){
params.groupId = form.groupId;
}
if(form.classIdList){
params.classId = form.classIdList;
}
const queryTerm = form.queryTerm.trim();
if(queryTerm){
params[form.queryType] = queryTerm;
}
return params;
},
selectChange(selection){
this.selectedIds = [];
selection.map((obj)=>{
this.selectedIds.push(obj.id)
});
},
vechicleChange(groupId, classId){
this.form.groupId = groupId;
this.form.classIdList = classId;
},
handleSizeChange(val) {
this.pageSize = val;
this.getData(this.currentPage,this.pageSize)
},
handleCurrentChange(val) {
this.currentPage = val;
this.getData(val)
},
onSubmit(form){
this.$refs[form].validate((valid) => {
if (valid) {
this.currentPage = 1;
this.pageSize = 10;
this.getData();
} else {
return false;
}
});
},
exportExcel(){
const url = 'attentionCenter/exportAttentionAlarm';
if(this.selectedIds.length){
exportExcel(url, {idList: this.selectedIds.join(',')})
}else{
exportExcel(url, this.getParams())
}
},
openDetail(row){
row.unread = 0;
let routeData = this.$router.resolve({
path: '/report/alarmDetail',
query: {
vehicleId: row.vehicleId
}
});
window.open(routeData.href, '_blank');
},
cancelFocus(vehicleId){
REPORT_SERVICE.toggleAlarmItemStatus({
vehicleId,
status: 0
}).then((result)=>{
if(result.returnCode == 0){
this.$message({
type: 'success',
message: '取消关注成功'
});
this.getData();
}else{
this.$message({
type: 'error',
message: '取消关注失败'
});
}
})
},
renderHeader(h, { column, $index }) {
const self = this;
return [
h('span', '工单号/姓名/设备号'),
h('br'),
h('span', '车架号'),
];
}
},
components:{
vDateRange,
vVechicleSelect
}
}
</script>
<style scoped>
</style>