<template>
    <view id="securityAlertList">
        <scroll-view scroll-y @scrolltolower="scrollGet" class="for-max-box">
            <view class="for-box" v-for="(item,index) in infoList" :key="index">
                <view class="title-box">
					<view :style="'border:1rpx solid '+item.subDiyVo.fiedColor+';background:#fff;color:'+item.subDiyVo.fiedColor+';'">{{item.subDiyVo.levelName}}</view>
                    <view>{{item.subDiyVo.name}}</view>
                    <view v-if="item.groupStatus==1">进行中</view>
                </view>
                <view class="address-box"><span>{{item.subDiyVo.typeName}}</span>{{item.subDiyVo.deptName}}</view>
                <view class="address-box-two">
                    <img src="@/pages_manage/images/icon_14.png">
                    <view>{{item.subDiyVo.subAddrrStr}}</view>
                </view>
                <view class="time-box">
                    <img src="@/pages_manage/images/icon_aqbj_sj.png">
                    <view>{{item.beginDate}}</view>
                </view>
                <view class="for-img-box">
                    <view class="for-img-min-box" v-for="(minItem,index) in item.sensorSet" :key="index">
                        <img src="@/pages_manage/images/icon_15.png">
                        <view>{{minItem}}</view>
                    </view>
                </view>
            </view>
            <img class="null-img" v-if="!infoList[0]" src="@/pages_manage/images/null-data-1.png">
        </scroll-view>
    </view>
</template>

<script>
    import { getSafeWarnList,getSafeWarnCount,laboratoryInfo,getSubByRiskPlanDetail } from '@/api/index.js'
    export default {
        name: "securityAlertList",
        data() {
            return {
                todayNum:0,
                yesterdayNum:0,
                historyNum:0,
                infoList:[],
                //列表请求参数
                getData:{
                    page:1,
                    pageSize:20,
                    getType:true,
                    nullDataType:true,
                }
            }
        },
        onLoad(){

        },
        onShow(){
            this.getSafeWarnCount();
            this.clearData();
            this.getList();
        },
        methods:{
            async getSubByRiskPlanDetail(item){
                const {data} = await getSubByRiskPlanDetail(item.riskPlanLogId);
                if(data.code == 200){
                    let obj = data.rows[0];
                    obj.subClassVO = item.subDiyVo.subClassVO;
                    obj.name = item.subDiyVo.name;
                    obj.subTypeLable = item.subDiyVo.subTypeLable;
                    obj.deptName = item.subDiyVo.deptName;
                    obj.subAddrrStr = item.subDiyVo.subAddrrStr;
                    uni.navigateTo({
                        url: '/pages_manage/workbench/plan/planInfo?item='+encodeURIComponent(JSON.stringify(obj))
                    });
                }
            },
            async laboratoryInfo(item){
                const {data} = await laboratoryInfo(item.subDiyVo.id);
                if(data.code == 200){
                    let obj = data.data[0];
                    obj.subClassVO = item.subDiyVo.subClassVO;
                    obj.name = item.subDiyVo.name;
                    obj.subTypeLable = item.subDiyVo.subTypeLable;
                    obj.deptName = item.subDiyVo.deptName;
                    obj.subAddrrStr = item.subDiyVo.subAddrrStr;
                    uni.navigateTo({
                        url: '/pages_manage/workbench/laboratory/laboratoryInfo?item='+encodeURIComponent(JSON.stringify(obj))
                    });
                }
            },
            //获取报警信息数量
            async getSafeWarnCount(){
                const {data} = await getSafeWarnCount();
                if(data.code == 200){
                    this.historyNum = data.data.allday;
                    this.todayNum = data.data.today;
                    this.yesterdayNum = data.data.yesterday;
                }
            },
            //跳转页面
            goInfoPage(type){
                if(type == 1){
                    uni.navigateTo({
                        url: '/pages_manage/workbench/securityAlert/todayList',//今日报警
                    });
                }else if(type == 2){
                    uni.navigateTo({
                        url: '/pages_manage/workbench/securityAlert/yesterdayList',//昨日报警
                    });
                }else if(type == 3){
                    uni.navigateTo({
                        url: '/pages_manage/workbench/securityAlert/historyList',//历史报警
                    });
                }
            },
            //清除
            clearData(){
                this.infoList = [];
                this.getData.page = 1;
                this.getData.getType = true;
                this.getData.nullDataType = true;
            },
            //滚动事件
            scrollGet(){
                if(this.getData.getType){
                    this.getData.page += 1;
                    this.getList();
                }
            },
            //获取列表数据
            async getList(){
                let self = this;
                let obj = {
                    pageNum:this.getData.page,
                    pageSize:this.getData.pageSize,
                    count:-1,
                    groupStatus:"",
                };
                const {data} = await getSafeWarnList(obj);
                if(data.code==200){
                    if(self.page==1){
                        if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
                            self.infoList = data.rows;
                        }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
                            self.infoList = data.rows;
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }else{
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }
                    }else{
                        if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
                            self.infoList = self.infoList.concat(data.rows)
                        }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
                            self.infoList = self.infoList.concat(data.rows);
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }else{
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }
                    }
                }
            },
        },
    }
</script>

<style lang="stylus" scoped>
    #securityAlertList{
        height:100%;
        flex:1;
        display flex
        flex-direction column
        overflow: hidden
        .top-num-box{
            background #fff
            height:80rpx;
            border-bottom:1rpx solid #e0e0e0;
            display: flex;
            view{
                flex:1;
                color:#0183FA;
                text-align center
                line-height:80rpx;
                font-size:28rpx;
            }
        }
        .for-max-box{
            flex:1;
            overflow-y scroll
            .for-box{
                background #fff
                margin-bottom:20rpx;
                overflow: hidden
                .title-box{
                    margin:20rpx 20rpx 0;
                    display flex
                    view:nth-child(1){
                        height:40rpx;
                        line-height:40rpx;
                        font-size:20rpx;
                        border-radius:10rpx;
                        padding:0 20rpx;
                        color:#fff;
                        margin-right:20rpx;
                    }
                    view:nth-child(2){
                        line-height:42rpx;
                        font-size:30rpx;
                        color:#333;
                        max-width:600rpx;
                        flex:1;
                    }
                    view:nth-child(3){
                        line-height:42rpx;
                        font-size:24rpx;
                        color:#EE3A3A;
                        margin-right:10px;
                    }
                    img{
                        width:12rpx;
                        height:20rpx;
                        margin-top:11rpx;
                    }
                    .colorA{
                        background:#aa2315;
                    }
                    .colorB{
                        background:#ff9b09;
                    }
                    .colorC{
                        background:#3ea3e9;
                    }
                    .colorD{
                        background:#3ea34c;
                    }

                }
                .address-box{
                    margin:20rpx 20rpx;
                    font-size:26rpx;
                    color:#999999;
                    span{
                        margin-right:60rpx;
                    }
                }
                .address-box-two{
                    display flex
                    margin:0 20rpx 20rpx 20rpx;
                    border-bottom:1rpx solid #e0e0e0;
                    padding-bottom:20rpx;
                    img{
                        width:28rpx;
                        height:30rpx;
                        margin-right:18rpx;
                    }
                    view{
                        line-height:30rpx;
                        font-size:24rpx;
                        color:#999999;
                    }
                }
                .time-box{
                    display flex
                    margin:0 20rpx;
                    img{
                        width:30rpx;
                        height:30rpx;
                        margin-top:12rpx;
                        margin-right:18rpx;
                    }
                    view{
                        line-height:50rpx;
                        font-size:28rpx;
                        color:#999999;
                    }
                }
                .for-img-box{
                    margin:0 20rpx;
                    padding-bottom:20rpx;
                    .for-img-min-box{
                        display flex
                        img{
                            width:30rpx;
                            height:27rpx;
                            margin-top:24rpx;
                            margin-right:10rpx;
                        }
                        view{
                            line-height:74rpx;
                            text-align center
                            font-size:28rpx;
                            color:#EE3A3A;
                        }
                    }
                }
            }
            .null-img{
                display block
                width:276rpx;
                height:321rpx;
                position absolute
                top:100rpx;
                left:274rpx;
            }
        }
    }
</style>
