alarmDispose.vue
9.19 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
<template>
<v-layout>
<template slot="breadcrumb">
<div style="width: 100%;height: 100%;z-index: 1000;"></div>
<el-breadcrumb-item>统计报表</el-breadcrumb-item>
<el-breadcrumb-item>警情配置(广汽)</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" style="padding: 0">
<!-- 表单查询 -->
<el-form :inline="true" :model="form" ref="form" >
<div style="width: 100%; border-bottom: 1px solid #e7eaec;">
<div class="ibox-title" style="padding-bottom: 0">
<h3 class="pull-left" style="margin-top:5px;margin-left:20px;padding:18px;border-bottom: 2px solid #094;">配置列表</h3>
</div>
</div>
<!-- 项目分组 -->
<el-form-item class='seachFrist'>
<el-select v-model='form.groupName' placeholder="项目分组" size="small" @change="getLabel">
<el-option
v-for="(item,index) in options"
:key="index"
:label="item.lable"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<!-- 报警类型分类 /-->
<el-form-item style=
"margin-top: 20px;">
<el-select v-model="form.alarmType" placeholder="报警类型" size="small">
<el-option label="电量报警" value="0"></el-option>
<el-option label="超时报警" value="1"></el-option>
<el-option label="离线超时报警" value="2"></el-option>
<el-option label="设备报警" value="3"></el-option>
<el-option label="设备分离报警" value="10"></el-option>
<el-option label="出省报警(经销商)" value="9"></el-option>
<el-option label="区域报警(个人)" value="12"></el-option>
<!-- <el-option label="二押区域报警" value="4"></el-option>
<el-option label="翻转报警" value="5"></el-option>
<el-option label="高危区域报警" value="6"></el-option>
<el-option label="出国报警" value="7"></el-option>
<el-option label="出入边境省份预警" value="8"></el-option>
-->
</el-select>
</el-form-item>
<el-form-item style=
"margin-top: 20px;" label="规则名称">
<el-input placeholder="请输入规则名称" v-model="form.ruleName" size="small" class="input-with-select" clearable>
</el-input>
</el-form-item>
<el-form-item class='search'>
<el-button type="primary" @click="onSubmit" size="small">查询</el-button>
</el-form-item>
<el-form-item class='search'>
<el-button type="primary" @click="resetForm('form')" size="small">重置</el-button>
</el-form-item>
<el-form-item class='search'>
<el-button type="primary" @click="newAlarmDispose('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">批量导出 <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 prop="ruleName" label="规则名称" min-width="160" align="center"></el-table-column>
<el-table-column fixed prop="alarmType" label="报警类型" min-width="160" align="center"></el-table-column>
<el-table-column prop="projectType" label="项目分组" min-width="100" align="center"></el-table-column>
<el-table-column fixed prop="alarmLevel" label="报警级别" min-width="180" align="center"></el-table-column>
<el-table-column prop="alarmCondition" label="报警条件" min-width="120" align="center"></el-table-column>
<el-table-column prop="setTime" label="设置日期" min-width="100" align="center"></el-table-column>
<el-table-column fixed="right" label="操作" min-width="160" align="center">
<template slot-scope="scope">
<el-button @click='editAlarm(scope.row.id)' type="text" size="medium">修改</el-button>
<el-button @click='delet(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>
<alarm-dispose-module @getData = 'getData' :detailFormVisible="detailFormVisible" :detailForm="detailForm" @onAlarmDisposeModuleChange="alarmDisposeModule" :optionsData='optionsData' :dataId='id'></alarm-dispose-module>
</template>
</v-layout>
</template>
<script>
const vVechicleSelect = () => import(/* webpackChunkName: "vVechicleSelect" */ 'components/VechicleSelect.vue');
import alarmDisposeModule from './alarmDisposeModule'
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: [],
options:[],
optionsData:[],
form: {
groupName:'',
alarmType: '',
ruleName: ''
},
labelName:'',
id:'',
detailForm:{},
detailFormVisible: false,
selectedIds: []
}
},
created(){
this.getData();
this.gqQueryTerm();
},
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();
let param=this.getParams();
params.currentPage = curr;
params.pageSize = size;
REPORT_SERVICE.gqAlarmCenterList(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;
});
},
gqQueryTerm(){
REPORT_SERVICE.gqQueryTerm({queryId:3}).then((response)=>{
this.options = response.data
this.optionsData = response.data
});
},
getLabel(val){
let obj = {};
obj = this.options.find((item)=>{
return item.value === val;
});
this.labelName = obj.lable;
console.log(this.labelName)
},
resetForm(formName) {
this.form.groupName =''
this.form.alarmType =''
this.form.ruleName =''
this.labelName = ''
},
newAlarmDispose(){
this.id= '';
this.detailFormVisible = true;
},
getParams(){
const form = this.form;
const params = {};
if(this.labelName){
params.groupName = this.labelName;
}
if(form.alarmType){
params.alarmType = form.alarmType;
}
if(form.ruleName){
params.ruleName = form.ruleName;
}
return params;
},
selectChange(selection){
this.selectedIds = [];
selection.map((obj)=>{
this.selectedIds.push(obj.id)
});
},
alarmDisposeModule(isOpen){
this.detailFormVisible = isOpen
},
delet(id){
this.$confirm('确定要删除该配置吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
REPORT_SERVICE.deleteAlarmRule({id: id}).then((res)=>{
if(res.returnCode == 0){
this.$message({
message: res.message,
type: 'success'
});
this.getData()
}
});
});
},
editAlarm(id){
REPORT_SERVICE.getAlarmRuleById({id: id}).then((res)=>{
if(res.returnCode == 0){
this.id = id;
this.detailForm = res.data;
this.detailFormVisible = true;
}
});
},
handleSizeChange(val) {
this.pageSize = val;
this.getData(this.currentPage,this.pageSize)
},
handleCurrentChange(val) {
this.currentPage = val;
this.getData(val)
},
onSubmit(){
this.currentPage = 1;
this.pageSize = 10;
this.getData();
},
exportExcel(){
const url = 'gqAlarmCenter/exportGqAlarmRule';
if(this.selectedIds.length){
exportExcel(url, {idList: this.selectedIds.join(',')})
}else{
exportExcel(url, this.getParams())
}
}
},
components:{
alarmDisposeModule,
vVechicleSelect
}
}
</script>
<style lang="scss" scoped>
.seachFrist{
padding-left:20px;
margin-top: 20px;
}
.search{
margin-top: 20px;
}
</style>