<template>
    <view class="container" v-if="showList.length">
        <navigator v-if="isShow('设备')" url="/pages/facility/index?page=设备中心&status=在线" hover-class="navigator-hover"
            class="item">
            <view class="label">在线设备</view>
            <view class="count u-line-1">{{ statistics.today_devices }}</view>
        </navigator>

        <navigator v-if="isShow('设备')" url="/pages/facility/index?page=设备中心&status=离线" hover-class="navigator-hover"
            class="item">
            <view class="label">离线设备</view>
            <view class="count u-line-1">{{ statistics.today_devices_off }}</view>
        </navigator>

        <navigator v-if="isShow('今日警告')" url="/pages/alerts/index?date=今天" hover-class="navigator-hover" class="item">
            <view class="label">今日警告</view>
            <view class="count u-line-1">{{ statistics.today_warns }}</view>
        </navigator>

        <navigator v-if="isShow('今日工单')" url="/packageA/workOrder/index?date=今天" hover-class="navigator-hover" class="item">
            <view class="label">今日工单</view>
            <view class="count u-line-1">{{ statistics.today_orders }}</view>
        </navigator>
    </view>
</template>

<script>
export default {
    name: 'spectaculars',
    data() {
        return {
            statistics: {
                today_devices: 0,
                today_warns: 0,
                today_orders: 0,
            },
            showList: []
        };
    },
    computed: {
        isShow() {
            return function (name) {
                return this.showList.includes(name)
            }
        }
    },
    created() {
        let auth = uni.getStorageSync('authList'),
            showList = [];
        typeof auth.设备中心 == 'object' && showList.push("设备");
        typeof auth.告警中心 == 'object' && showList.push("今日警告");
        typeof auth.工单 == 'object' && showList.push("今日工单");
        this.showList = showList;
    },
    methods: {
        getDetail() {
            this.$Http.basic({
                "id": 20230721153102,
                "content": {}
            }).then(res => {
                console.log("数据看板", res)
                if (this.cutoff(res.msg)) return;
                this.statistics = res.data;
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.container {
    display: flex;
    width: 355px;
    // height: 72px;
    height: 68px;
    margin: 0 auto;
    margin-top: 10px;

    .item {
        // width: 112px;
        // height: 72px;

        width: 81.5px;
        height: 68px;
        padding: 10px 8px;
        box-sizing: border-box;
        border-radius: 4px;
        background: #FFFFFF;
        margin-right: 9.5px;
        flex-shrink: 0;

        .label {
            line-height: 20px;
            font-size: 14px;
            font-family: PingFang SC-Regular, PingFang SC;
            color: #333333;
        }

        .count {
            line-height: 22px;
            font-size: 16px;
            font-family: PingFang SC-Medium, PingFang SC;
            font-weight: bold;
            color: #3874F6;
            margin-top: 10px;
        }
    }

    .item:last-child {
        margin-right: 0;
    }
}
</style>
