<template>
    <view v-show="show">
        <!-- <view class="head">
            <view class="left" hover-class="navigator-hover" @click="actionShow = true">
                告警记录
            </view>
            <time-horizon @onConfirm="dateRange" />
        </view> -->
        <!-- <navigator v-for="item in list" :key="item.w_event_logid" class="item" url="#">
            <view class="title">
                {{ item.eventname || ' --' }}
            </view>
            <view class="">
                
            </view>
        </navigator> -->
        <view style="height: 20px;" />
        <List :list="list" :isShowProdname="false" />
        <view v-if="!list.length" style="position: relative; z-index: 1 !important;">
            <view style="height: 40px;" />
            <u-empty mode="data" />
        </view>
    </view>
</template>

<script>
let paging = {
    pageNumber: 1,
    pageTotal: 1,
    pageSize: 20,
};
import List from "../../alerts/modules/list.vue";
export default {
    components: { List },
    name: "alerts",
    props: {
        w_deviceid: String
    },
    data() {
        return {
            show: false,
            uninitialized: true,
            list: [],
            "where": {
                "begindate": "",
                "enddate": ""
            },
        }
    },
    methods: {
        initialize(init = false) {
            this.getList(init)
        },
        getList(init = false) {
            if (init) paging = {
                pageNumber: 1,
                pageTotal: 1,
            };
            if (paging.pageNumber > paging.pageTotal) return;
            this.$Http.basic({
                "id": 20230817084702,
                "content": {
                    "w_deviceid": this.w_deviceid,
                    ...paging,
                    "where": this.where
                }
            }).then(res => {
                console.log("告警记录", res)
                if (this.cutoff(res.msg)) return;
                if (init) this.uninitialized = false;
                paging.pageNumber = res.pageNumber + 1;
                paging.pageTotal = res.pageTotal;
                this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data)
            })
        },
        dateRange(range, fun) {
            let where = this.where;
            if (where.begindate == range[0] && where.enddate == range[1]) return fun();
            where.begindate = range[0]
            where.enddate = range[1];
            console.log("where", where)
            this.getList(true);
        }
    },
}
</script>

<style lang="scss" scoped>
.head {
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 355px;
    box-sizing: border-box;
    padding: 0 10px;
    margin: 0 auto 10px;

    .left {
        color: #fff;
        font-weight: bold;
    }
}

.item {
    width: 355px;
    margin: 10px auto 0;
    background: #fff;
    box-sizing: border-box;
    border-radius: 4px;
    padding: 10px;

    .title {
        color: #004684;
        font-weight: bold;
        line-height: 20px;
    }
}
</style>