alarm.vue
12.6 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
<template>
<view class="alert-page">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<f-navbar>
<view class="u-flex" slot="left">
<u-icon color="#fff"></u-icon>
<view class="actName u-line-1"></view>
</view>
<view class="u-flex filter" slot="right">
<view class="filter-input"><u--input prefixIcon="search" placeholder="输入设备SN或名称搜索" border="surround" shape="circle"></u--input></view>
<view class="filter-text">
<view><text class="text">筛选</text></view>
</view>
<view class="filter-icon"><image class="image" @click="openSearchDialog" src="../../static/shaixuan.png"></image></view>
</view>
</f-navbar>
<view @click="openOrg" class="org-sty">
<view class="org-item">
<view class="u-flex item"><text class="text-bold">组织关系</text></view>
<view class="u-flex item-child">
<image class="image" src="../../static/org.png" mode=""></image>
<text class="text-12">告警数:{{ alertTotal }}</text>
</view>
</view>
<view class="org-item "><image class="org-image" src="../../static/right-arrow.png"></image></view>
</view>
<!-- 自带分页组件 -->
<mescroll-body ref="mescrollRef" :up="upOption" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
<view class="device-list">
<view @click="openAlertDetail(item)" class="list-item" v-for="(item, index) in list" :key="index">
<view class="u-flex item">
<view class="item-text text-clip">
<text class="text-bold">{{ item.deviceName == null ? '暂无数据' : item.deviceName }}</text>
</view>
<view class="item-text">
<text class="text-muted">{{ item.details == null ? '暂无数据' : formatDetailText(item.details.data) }}</text>
</view>
<view class="item-text">
<text class="text-muted">
告警状态:{{
item.status == 'CLEARED_UNACK'
? '清除未确认'
: item.status == 'ACTIVE_UNACK'
? '激活未确认'
: item.status == 'CLEARED_ACK'
? '清除已确认'
: '激活已确认'
}}
</text>
</view>
<view class="item-text">
<text class="text-secondary">{{ item.createdTime }}</text>
</view>
</view>
<view class="item">
<view class="u-flex item-right">
<image class="right-image" :src="bindImageUrl(item.severity)"></image>
<view class="right-text">
<text
class="text-no-color"
:style="[
item.severity == 'CRITICAL'
? { color: '#DE4437' }
: item.severity == 'MAJOR'
? { color: '#DE7337' }
: item.severity == 'MINOR'
? { color: '#FFC107' }
: item.severity == 'WARNING'
? { color: '#DE4437' }
: { color: '#00C9A7' }
]"
>
{{
item.severity == 'CRITICAL'
? '危险'
: item.severity == 'MAJOR'
? '重要'
: item.severity == 'MINOR'
? '次要'
: item.severity == 'WARNING'
? '警告'
: '不确定'
}}
</text>
</view>
</view>
</view>
</view>
</view>
</mescroll-body>
<!-- 自带分页组件 -->
<view style="height: 20rpx"></view>
<!-- 告警筛选 -->
<u-popup @close="close" closeable bgColor="transparent" :overlay="true" :show="show" mode="bottom">
<view class="popup-page">
<view class="popup-text"><text class="text">筛选条件</text></view>
<view class="popup-alarm-page u-flex">
<view>
<view class="popup-alarm-text"><text class="text">告警状态</text></view>
<view class="u-flex popup-alarm-child">
<view
class="alarm-text"
@click="getAlertStatus(item, index)"
:style="[index == current1 ? { background: '#377DFF' } : { background: '#F6F6F6' }]"
v-for="(item, index) in alertStatus"
:key="index"
>
<text class="text">{{ item.name }}</text>
</view>
</view>
<view style="margin-top: 120rpx;">
<view class="popup-alarm-text"><text class="text">设备类型</text></view>
<view class="u-flex popup-alarm-child">
<view
class="alarm-text"
@click="getTypeStatus(item, index)"
:style="[index == current2 ? { background: '#377DFF' } : { background: '#F6F6F6' }]"
v-for="(item, index) in deviceType"
:key="index"
>
<text class="text">{{ item.name }}</text>
</view>
</view>
<view style="margin-top: 120rpx;">
<view class="popup-alarm-text"><text class="text">告警等级</text></view>
<view class="u-flex popup-alarm-child">
<view
class="alarm-text"
@click="getLevelStatus(item, index)"
:style="[index == current3 ? { background: '#377DFF' } : { background: '#F6F6F6' }]"
v-for="(item, index) in alertLevel"
:key="index"
>
<text class="text">{{ item.name }}</text>
</view>
</view>
<view style="margin-top: 120rpx;">
<view class="popup-alarm-text"><text class="text">选择时间</text></view>
<view class="u-flex popup-alarm-child">
<view
class="alarm-text"
@click="getTimeStatus(item, index)"
:style="[index == current4 ? { background: '#377DFF' } : { background: '#F6F6F6' }]"
v-for="(item, index) in timeArea"
:key="index"
>
<text class="text">{{ item.name }}</text>
</view>
</view>
<view style="margin-top: 120rpx;">
<view class="u-flex popup-alarm-child">
<view>
<u--form :label-style="{ 'font-size': '29rpx', 'margin-left': '10rpx' }" labelPosition="left" :model="timeData">
<u-form-item style="font-size: 14px" label="选择日期" prop="selectTime" labelWidth="80" borderBottom @click="openTime">
<u--input v-model="timeData.selectTime" placeholder="请选择日期" border="none"></u--input>
</u-form-item>
</u--form>
</view>
</view>
</view>
<view class="u-flex" style="flex-direction: row; margin-top: 128rpx; margin-left: 10rpx">
<view style="width: 300rpx"><u-button @click="resetData" type="info" shape="circle" text="重置"></u-button></view>
<view style="width: 300rpx; margin-left: 46rpx"><u-button @click="queryData" type="primary" shape="circle" text="确认"></u-button></view>
</view>
<view style="height: 30rpx;"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</u-popup>
<u-calendar
:show="showCalendar"
mode="range"
@confirm="calendarConfirm"
@close="calendarClose"
startText="开始时间"
endText="结束时间"
confirmDisabledText="请选择日期"
:formatter="formatter"
></u-calendar>
<f-tabbar></f-tabbar>
</view>
</template>
<script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import fNavbar from '@/components/module/f-navbar/f-navbar';
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import { pageNumber, pageSize } from '@/config/constant.js';
import { alertStatus, deviceType, alertLevel, timeArea } from './static/data.js';
export default {
mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
components: {
fTabbar,
fNavbar
},
data() {
return {
alertStatusVal: '',
deviceTypeVal: '',
alertLevelVal: '',
selectTimeVal: '',
startTime: '',
endTime: '',
current1: 0,
current2: 0,
current3: 0,
current4: 0,
page: {
num: 0,
size: 10
},
downOption: {
auto: false //是否在初始化后,自动执行downCallback; 默认true
},
upOption: {
auto: false // 不自动加载
},
timeData: {
selectTime: '',
getTimeGap: '',
getDateVal: ''
},
showCalendar: false,
show: false,
list: [],
alertStatus,
deviceType,
alertLevel,
timeArea,
ordId: '',
detailStatus: false,
alertTotal: 0
};
},
onShow() {
if (this.detailStatus) {
this.loadData(1, null, null, null, null, null, null);
}
if (this.ordId == '') {
} else {
this.loadData(1, null, null, null, null, null, this.ordId);
}
},
onHide() {
this.ordId = '';
this.detailStatus = false;
this.loadData(1, null, null, null, null, null, null);
},
onLoad(e) {
// 隐藏原生的tabbar
uni.hideTabBar();
if (e.type !== undefined) {
let params = JSON.parse(e.type);
let type;
if (Array.isArray(params)) {
// type = params.join(',');
type = params[0];
} else {
type = params;
}
this.loadData(1, type, null, null, null, null, null);
} else {
this.loadData(1, null, null, null, null, null, null);
}
},
methods: {
getAlertStatus(e, i) {
this.current1 = i;
this.alertStatusVal = e.value;
},
getTypeStatus(e, i) {
this.current2 = i;
this.deviceTypeVal = e.value;
},
getLevelStatus(e, i) {
this.current3 = i;
this.alertLevelVal = e.value;
},
getTimeStatus(e, i) {
this.current4 = i;
this.selectTimeVal = e.value;
},
queryData() {
let date1 = new Date(this.timeData.getDateVal[0]);
let date2 = new Date(this.timeData.getDateVal[this.timeData.getDateVal.length - 1]);
let startTimeVa, endTimeVa;
if (this.timeData.getDateVal.length == 0) {
startTimeVa = '';
endTimeVa = '';
} else {
startTimeVa = date1.getTime();
endTimeVa = date2.getTime();
}
this.loadData(1, this.alertStatusVal, startTimeVa, endTimeVa, this.alertLevelVal, this.deviceTypeVal);
this.show = false;
},
resetData() {
this.current1 = 0;
this.alertStatusVal = '';
this.current2 = 0;
this.deviceTypeVal = '';
this.current3 = 0;
this.alertLevelVal = '';
this.current4 = 0;
this.selectTimeVal = '';
this.timeData.getDateVal = '';
this.timeData.selectTime = '';
},
bindImageUrl(e) {
switch (e) {
case 'CRITICAL':
return '../../static/danger.png';
break;
case 'MAJOR':
return '../../static/major.png';
break;
case 'MINOR':
return '../../static/secondary.png';
break;
case 'WARNING':
return '../../static/danger.png';
break;
case 'INDETERMINATE':
return '../../static/noshue.png';
break;
default:
return '';
break;
}
},
/*下拉刷新的回调 */
downCallback() {
//联网加载数据
this.list.length = 0;
this.page.num = 1;
this.loadData(1);
},
/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
upCallback() {
//联网加载数据
this.page.num += 1;
this.loadData(this.page.num);
},
loadData(pageNo, statusV, startTimeV, endTimeV, severityV, deviceTypeV, organizationV) {
let httpData = {
page: pageNo,
pageSize: 10,
status: statusV,
startTime: startTimeV,
endTime: endTimeV,
severity: severityV,
deviceType: deviceTypeV,
organizationId: organizationV
};
uni.$u.http
.get('/yt/alarm', { params: httpData, custom: { load: false } })
.then(res => {
uni.stopPullDownRefresh();
this.mescroll.endByPage(res.items.length, res.total);
this.alertTotal = res.total;
if (pageNo == 1) {
this.list = res.items;
} else {
this.list = this.list.concat(res.items);
}
})
.catch(e => {
uni.$u.toast(e.data.message);
//联网失败, 结束加载
this.mescroll.endErr();
});
},
openOrg() {
uni.navigateTo({
url: './org/org'
});
},
open() {},
close() {
this.show = false;
},
openSearchDialog() {
this.show = true;
this.resetData();
},
openTime() {
this.showCalendar = true;
uni.hideKeyboard();
},
calendarConfirm(e) {
this.showCalendar = false;
this.timeData.selectTime = `${e[0]} / ${e[e.length - 1]}`;
this.timeData.getDateVal = e;
},
calendarClose() {
this.showCalendar = false;
},
//跳转告警详情
openAlertDetail(e) {
let obj = {
id: e.id,
deviceName: e.deviceName,
severity: e.severity,
originatorType: e.originatorType,
details: e.details,
createdTime: e.createdTime,
status: e.status
};
uni.navigateTo({
url: '/alarmSubPage/alarmDetailPage/alarmDetail?data=' + JSON.stringify(obj)
// url: '/' + JSON.stringify(obj)
});
},
formatDetailText(e) {
//去除字符串双引号
const jsonStr = JSON.stringify(e);
const str = jsonStr.substring(1, jsonStr.length - 1);
const newStr = str.replace(/\"/g, '');
return newStr;
}
}
};
</script>
<style lang="scss" scoped>
@import './static/alarm.scss';
</style>