123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <template>
- <view class="content">
- <view class="msg-box">
- <view style="margin-bottom:10rpx;position:relative" v-for="item in msgList" :key="item.id">
- <view class="msg-item">
- <view class="msg-row">
- <image src="@/static/image/bj1.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
- alt="">
- <view class="msg-content">
- 名称 :{{item.itemReadName}}
- </view>
- </view>
- <view class="msg-row">
- <image src="@/static/image/bj4.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
- alt="">
- <view class="msg-content">
- 类型 :{{item.alarmType}}
- </view>
- </view>
- <view class="msg-row">
- <image src="@/static/image/bj3.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
- alt="">
- <view class="msg-content">
- 时间 :{{item.alarmTime}}
- </view>
- </view>
- <view class="msg-row">
- <image src="@/static/image/bj2.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
- alt="">
- <view class="msg-content">
- 报警描述 :<text style="font-weight: normal;">{{item.alarmText}}</text>
- </view>
- </view>
- <view class="msg-row" v-if="item.itemId!=0">
- <image src="@/static/image/bj5.png" style="margin-right:20rpx;width: 40rpx;height:40rpx;"
- alt="">
- <view class="msg-content">
- 报警值 :<text style="font-weight: normal;">{{item.alarmValue}}</text>
- </view>
- </view>
- <view class="msg-row">
- <u-button type="primary" size="small" class="cl" @click="handleMsg(item)">查看详情</u-button>
- </view>
- </view>
- <!-- <view class="msg-btn">
- <u-button type="primary" size="small" class="cl" @click="handleMsg(item.id)">查看详情</u-button>
- </view> -->
- <!-- <view class="emergent" v-if="item.readState!==0">
- <image src="@/static/image/jjbq.png" alt="" style="width:95rpx;height:80rpx">
- </view> -->
- </view>
- <view v-if="queryForm" class="query-screen">
- <view>
- 关键字
- </view>
- <div style="margin: 20px 0;">
- <input v-model="queryParams.queryKey" placeholder="请输入点位名称查询"/>
- </div>
- <view>
- 报警类型
- </view>
- <div style="margin: 20px 0;">
- <uni-data-select v-model="queryParams.alarmType" :localdata="alarmTypeList"></uni-data-select>
- </div>
- <view>
- 报警时间
- </view>
- <uni-datetime-picker v-model="range" type="datetimerange" start-placeholder="起始时间"
- end-placeholder="终止时间" @change="handelDate" return-type="timestamp" />
- <view class="month-btn">
- <u-button class="reset" style="width:200rpx" @click="reset">重置</u-button>
- <u-button type="primary" style="width:200rpx" @click="handelQuery">确认</u-button>
- </view>
- </view>
- </view>
- <u-empty v-if="!msgList.length" class="empty" icon="../../static/data.png" text="暂无数据">
- </u-empty>
- </view>
- </template>
- <script>
- import {
- getDayTime,
- timeToDate
- } from '@/utils/date.js'
- export default {
- data() {
- return {
- queryForm:false,
- // 日期选择
- range: [],
- //报警类型
- alarmTypeList:[
- {
- text:'数据源报警',
- value:'数据源',
- },
- {
- text:'点位报警',
- value:'点位'
- }
- ],
- // 查询参数
- queryParams: {
- queryKey:null,
- startDate:null,
- endDate:null,
- alarmType:null,
- page: 1,
- limit: 20
- },
- // 列表数据
- msgList: [],
- isload:false,
- pageCounts:0,
- };
- },
- onShow() {
- this.queryParams.limit = 20
- //this.loadAllAlarmData()
- this.getMsgList(true)
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 0
- })
- },
- onPullDownRefresh() {
- //console.log('onPullDownRefresh')
- this.queryParams.page = 1
- this.getMsgList(true)
- },
- onReachBottom() {
- //console.log('onReachBottom')
- if(this.queryParams.page > this.pageCounts){
- this.isload = true
- }else{
- this.queryParams.page = this.queryParams.page + 1
- this.getMsgList(false)
- this.isload = false
- }
- },
- methods: {
- // 获取消息数据
- getMsgList(isCover) {
- if((this.queryParams.startDate==null) || (this.queryParams.endDate==null)){
- let dDate = getDayTime();
- this.queryParams.startDate = timeToDate(dDate[0])
- this.queryParams.endDate = timeToDate(dDate[1])
- }
- uni.$http.get('/mobileAlarm/queryUserAlarmData', this.queryParams).then(res => {
- const data = res.data
- if (data.code === 200) {
- this.pageCounts = data.data.count / this.queryForm.limit
- if(isCover){
- this.msgList = data.data.userAlarmLogList
- }else{
- this.msgList = this.msgList.concat(data.data.userAlarmLogList)
- }
- uni.stopPullDownRefresh()
- }
- })
- },
- //立即处理
- handleMsg(item) {
- uni.navigateTo({
- url: "/pages/message/msg-detail/index?data=" + JSON.stringify(item),
- })
- },
- onNavigationBarButtonTap(e){
- this.queryForm = !this.queryForm;
- if(this.queryForm){
- this.range = getDayTime()
- this.handelDate(this.range)
- }
- },
- resolvingDate(date) {
- if (!date) {
- return;
- }
- //date是传入的时间
- let d = new Date(date);
-
- let month = (d.getMonth() + 1) < 10 ? '0' + (d.getMonth() + 1) : (d.getMonth() + 1);
- let day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate();
- let hours = d.getHours() < 10 ? '0' + d.getHours() : d.getHours();
- let min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes();
- let sec = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds();
-
- let times;
- times = d.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + sec;
- return times
- },
- //选择日期
- handelDate(date) {
- this.queryParams.startDate = this.resolvingDate(date[0])
- this.queryParams.endDate = this.resolvingDate(date[1])
- },
- //重置按钮
- reset() {
- this.queryParams = {
- queryKey:null,
- startDate:null,
- endDate:null,
- alarmType:null,
- page: 1,
- limit: 20
- }
- },
- //确认按钮查询
- handelQuery() {
- //如果没有选择时间,默认当天的起止时间
- this.queryParams.page = 1
- this.queryForm = false;
- this.getMsgList(true);
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- //padding: 20rpx 45rpx 20rpx 45rpx;
- background: #EEEDF2;
- }
- .empty {
- width: 400rpx;
- height: 400rpx;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-top: -280rpx !important;
- margin-left: -200rpx;
- }
- .msg-box {
- .msg-item {
- background: #ffffff;
- padding: 25rpx;
- margin-bottom: 4rpx;
- .msg-row {
- display: flex;
- align-items: center;
- margin-bottom: 20rpx;
- .msg-content {
- width: 500rpx;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
- font-size: 14px;
- }
- }
- }
- .msg-btn {
- background: #ffffff;
- padding: 25rpx;
- .cl {
- width: 180rpx;
- margin-right: 0
- }
- }
- .emergent {
- position: absolute;
- right: 30rpx;
- top: 0;
- }
- .query-screen {
- width: 96vw;
- padding: 0 20rpx;
- background: #ffffff;
- position: absolute;
- top: 0;
- z-index: 999;
-
- .month {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 28rpx;
- margin: 40rpx 0;
-
- .month-item {
- padding: 10rpx 20rpx;
- background: #ECECEC;
- color: #000000;
- border-radius: 12rpx;
- }
-
- .month-select {
- padding: 10rpx 20rpx;
- border-radius: 12rpx;
- background: #289BFF;
- color: #ffffff;
- }
- }
-
- .month-btn {
- display: flex;
- justify-content: space-around;
- margin-top: 40rpx;
- margin-bottom: 40rpx;
-
- .reset {
- background: #EAF4FF;
- color: #469DED;
- border: 1px solid #A3B8CB;
- }
- }
- }
- }
- </style>
|