alarm-history.vue
3.61 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
<template>
<view class="alert-page">
<!-- 告警头部 -->
<view class="filter-button" @click="openSearchDialog">
<text>{{ $t('common.screen') }}</text>
<image src="/static/shaixuan.png" />
</view>
<!-- 告警分页 -->
<mescroll-uni height="700rpx;" ref="mescrollRef" @init="mescrollInit" :up="upOption" :down="downOption"
@down="downCallback" @up="upCallback">
<alarm-item :list="list" @openAlertDetail="openAlertDetail"></alarm-item>
<mescroll-empty v-if="!list.length" />
</mescroll-uni>
<view style="height: 20rpx"></view>
<!-- 告警筛选 -->
<alarm-popup ref="alarmPopupRef" :show="show" @close="close" @queryCondition="getQueryCondition"></alarm-popup>
</view>
</template>
<script>
import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
import api from '@/api/index.js'
import alarmItem from '@/pages/alarm/components/alarm-item.vue'
import alarmPopup from '@/pages/alarm/components/alarm-popup.vue'
import {
useNavigateTo
} from '@/plugins/utils.js'
export default {
mixins: [MescrollMixin],
components: {
alarmItem,
alarmPopup
},
props: {
deviceId: {
type: String,
default: ''
}
},
data() {
return {
show: false,
list: [],
total: 0,
downOption: {
auto: true //是否在初始化后,自动执行downCallback; 默认true
},
upOption: {
auto: false // 不自动加载
},
page: {
num: 0,
size: 10
},
conditions: {},
};
},
methods: {
disabledScroll() {
return;
},
getQueryCondition(value) {
this.conditions = value
this.conditions.deviceId = this.deviceId
this.loadData(1, this.conditions);
this.close()
},
resetQuery() {
this.page.num = 1;
this.$nextTick(() => {
this.$refs.alarmPopupRef.resetQuery()
})
this.conditions = {}
},
downCallback() {
this.list = [];
this.page.num = 1;
this.resetQuery();
this.loadData(this.page.num, {
deviceId: this.deviceId
});
},
upCallback() {
const deviceId = {
deviceId: this.deviceId
}
const condition = Object.values(this.conditions)
if (condition.length === 0) {
this.page.num += 1;
this.loadData(this.page.num, {
...deviceId
});
} else if (condition.filter(Boolean).length > 0) {
this.page.num += 1;
this.loadData(this.page.num, {
...this.conditions,
...deviceId
});
} else {
this.page.num += 1;
this.loadData(this.page.num, {
...deviceId
});
}
},
async loadData(page, param) {
let that = this;
let params = {
page,
pageSize: 10,
...param
};
const res = await api.alarmApi.getAlarmApi({
params,
custom: {
load: false
}
})
if (!res) return
uni.stopPullDownRefresh();
that.mescroll.endByPage(res.items.length, res.total); //必传参数(当前页的数据个数, 总页数)
that.alarmTotal = res.total;
if (page == 1) {
that.list = res.items;
} else {
that.list = that.list.concat(res.items);
}
},
openSearchDialog() {
this.show = true;
this.resetQuery();
},
close() {
this.show = false;
},
openAlertDetail(e) {
useNavigateTo('/alarm-subpackage/alarm-detail/alarm-detail?data=', e)
}
}
};
</script>
<style lang="scss" scoped>
.filter-button {
margin: 0 20rpx;
font-size: 12px;
width: 160rpx;
height: 64rpx;
border-radius: 32rpx;
display: flex;
justify-content: center;
align-items: center;
background: #f0f1f2;
color: #666;
image {
width: 28rpx;
height: 28rpx;
margin-left: 4rpx;
}
}
</style>