<template>
    <view class="index-zhuyonghu">
        <view class="canneng-index-title mb20">所有工程统计信息</view>
        <view class="header">
            <view class="header-item">
                <view class="header-item-value">{{ devCount.onLineDevCount + devCount.offLineDevCount || 0 }}</view>
                <view class="header-item-label">设备总数</view>
            </view>
            <view class="header-item" @click="jump('onLineDevs')">
                <view class="header-item-value">{{ devCount.onLineDevCount || 0 }}</view>
                <view class="header-item-label">在线设备</view>
            </view>
            <view class="header-item" @click="jump('offLineDevs')">
                <view class="header-item-value">{{ devCount.offLineDevCount || 0 }}</view>
                <view class="header-item-label">离线设备</view>
            </view>
        </view>
        <view class="canneng-index-title mb20 mt20">当前工程统计信息</view>
        <view class="header">
            <view class="header-item">
                <view class="header-item-value">{{
                    devCount.currentOnLineDevCount + devCount.currentOffLineDevCount || 0
                }}</view>
                <view class="header-item-label">设备总数</view>
            </view>
            <view class="header-item" @click="jump('currentOnLineDevs')">
                <view class="header-item-value">{{ devCount.currentOnLineDevCount || 0 }}</view>
                <view class="header-item-label">在线设备</view>
            </view>
            <view class="header-item" @click="jump('currentOffLineDevs')">
                <view class="header-item-value">{{ devCount.currentOffLineDevCount || 0 }}</view>
                <view class="header-item-label">离线设备</view>
            </view>
        </view>
    </view>
</template>
<script>
export default {
    props: {
        devCount: {
            type: Object,
            default: {},
        },
    },
    methods:{
        jump(type) {
            switch (type) {
                default:
                    uni.navigateTo({
                        url:
                            '/pages/device/list?type=' +
                            type +
                            '&projectList=' +
                            encodeURIComponent(JSON.stringify(this.devCount[type])),
                    })
                    break
            }
        },
    }
}
</script>
<style lang="scss"></style>
