<template>
    <view style="position: relative">
        <!-- 运行告警 -->

        <!-- 卡片 -->
        <view class="event-list" :style="{ height: 'calc(100vh - ' + (navHeight + 10) + 'px)', overflow: 'auto' }">
            <!-- 循环渲染事件项 -->
            <uni-card
                class="event-item"
                :class="item.type"
                v-for="(item, index) in this.store.data"
                :key="index"
                @click="jump(item)"
            >
                <!-- 头部：图标 + 信息 + 操作 -->
                <view class="event-header">
                    <view class="event-icon">
                        <!-- 动态图标：根据类型切换 -->
                        <uni-icons
                            custom-prefix="iconfont"
                            type="icon-terminal-box-fill"
                            size="22"
                            color="#FF0000"
                        ></uni-icons>
                        <view class="badge1" v-if="item.isRead == 0"> </view>
                    </view>
                    <view class="event-info">
                        <view class="event-title">
                            <text class="event-id">{{ item.date }}发生告警终端{{ item.warnNums }}台</text>
                        </view>
                    </view>
                    <view class="event-action"> 🔍 </view>
                </view>
            </uni-card>
            <uni-load-more
                v-if="store.status == 'loading' || (store.data && store.data.length > 0)"
                :status="store.status"
            ></uni-load-more>
            <Cn-empty v-else style="top: 20%"></Cn-empty>
        </view>
    </view>
</template>
<script>
import list from '@/common/js/list'
export default {
    components: {},
    props: {
        navHeight: {
            type: Number,
            default: 0,
        },
        selectValue: {
            type: Object,
            // default: () => {},
        },
    },
    mixins: [list],
    data() {
        return {
            status: 'noMore', //more加载前  loading加载中 noMore加载后
        }
    },
    mounted() {},

    methods: {
        init() {
            this.store = this.DataSource('/cs-harmonic-boot/csAlarm/queryAlarmList')
            this.store.params.pageSize = 10000
            this.store.params.engineerId = this.selectValue.engineeringId
            this.store.params.projectId = this.selectValue.projectId
            this.store.params.devId = this.selectValue.deviceId
            this.store.params.lineId = this.selectValue.lineId
            this.store.params.time = this.selectValue.date
            this.store.loadedCallback = () => {
                this.loading = false
            }
            this.store.reload()
        },
        jump(item) {
            let str = JSON.stringify(item).replace(/%/g, '百分比')
            item.status = '1'
            uni.navigateTo({ url: '/pages/message1/comp/alarmDetails?detail=' + encodeURIComponent(str) })
        },
    },

    computed: {},

    watch: {
        selectValue: {
            handler(val, oldVal) {
                if (Object.keys(val).length === 0) return
                this.init()
            },
            deep: true,
            immediate: true,
        },
    },
}
</script>

<style lang="scss" scoped>
@import './index.scss';
/* 列表容器 */
.event-list {
    margin-top: 20rpx;
    /* 头部：图标 + 信息 + 操作 */
    .event-header {
        margin-bottom: 0rpx;
    }
    .event-title {
        margin-bottom: 0rpx;
    }

    /* 图标区域（按类型区分背景色） */
    .event-icon {
        width: 70rpx;
        height: 70rpx;
        background-color: #ff000020;
    }

    /* 信息区域 */
    .event-info {
        flex: 1;
    }
}
</style>
