<template>
    <div class="provider_list">
        <div class="provider_title">
            <div class="sub_title" @click="subTab('provider')" :class="{
                'activeSub': subActive == 'provider'
            }">
                热门出租方
            </div>
            <div class="sub_title" @click="subTab('hotEquipment')" :class="{
                'activeSub': subActive == 'hotEquipment'
            }">
                热门装备
            </div>
        </div>
        <div class="provider_content" v-if="subActive == 'provider'">
            <div class="provider_item" v-for="(item, index) in providerInfo.list" :key="index">
                <div class="provider_item_left">
                    <div class="pro_item_icon" :class="{ 'inThree': index + 1 <= 3, 'afterThree': index + 1 > 3 }">
                        <!-- <img :src="`/src/assets/img/index${index + 1 <= 3 ? index + 1 : 4}.png`" alt="" -->
                        <img v-if="index == 0" src="/src/assets/img/index1.png" alt="">
                        <img v-else-if="index == 1" src="/src/assets/img/index2.png" alt="">
                        <img v-else-if="index == 2" src="/src/assets/img/index3.png" alt="">
                        <img v-else src="/src/assets/img/index4.png" alt="">
                    </div>
                    <div class="pro_item_title overflow">
                        {{ item.organizeName }}
                    </div>
                </div>
                <div class="device_count">
                    设备数:{{ item.count }}
                </div>
            </div>
        </div>
        <div class="cloud_words_out" v-else>
            <CloudWords :data="data"></CloudWords>
        </div>
    </div>
</template>
<script setup lang="ts">
import CloudWords from "components/echartsCom/CloudWords.vue"
import { apiMaDevInfoHotList } from "http/api/echartApi"


const data: any = ref([])
const providerInfo: any = reactive({
    list: [
        // {
        //     ownCo: "中铁一局",
        //     count: 1
        // },
        // {
        //     ownCo: "中铁二局",
        //     count: 2
        // },
        // {
        //     ownCo: "中铁三局",
        //     count: 3
        // },
        // {
        //     ownCo: "中铁四局",
        //     count: 4
        // },
        // {
        //     ownCo: "中铁五局",
        //     count: 5
        // },
        // {
        //     ownCo: "中铁十一局",
        //     count: 10
        // },
        // {
        //     ownCo: "中铁十一局",
        //     count: 10
        // },
    ]
})

const subActive = ref("provider")
//  provider hotEquipment
const subTab = (type: any) => {
    subActive.value = type
}

const InitApiMaDevInfoHotList = async () => {
    // 根据求出租信息查询对应的数量:    
    try {
        const res: any = await apiMaDevInfoHotList()
        console.log("apiMaDevInfoHotList", res)
        providerInfo.list = res
        res[0].itemNames.map((item: any) => {
            data.value.push({
                name: item,
                value: Math.floor(Math.random() * (519 - 199 + 1) + 169)
            })
        })
    } catch (error) {
        console.log(error)
    }
}

onBeforeMount(() => {
    InitApiMaDevInfoHotList()
})



</script>
<style scoped lang="scss">
.provider_list {
    width: 332px;
    height: 456px;
    background-color: rgba($color: #011B37, $alpha: 0.6);
    padding: 0 22px;
    box-sizing: border-box;
}

.provider_title {
    display: flex;
    justify-content: flex-start;
    align-items: center;


    .sub_title {
        font-size: 12px;
        color: $main-color;
        padding-top: 24px;
        padding-left: 26px;

    }

    .activeSub {
        font-size: 18px;
        color: $main-color;
        padding-top: 20px;
    }
}

.provider_content {
    padding-top: 12px;
    overflow-y: auto;
    height: 396px;

    .provider_item {
        width: 280px;
        height: 40px;
        padding: 0 12px;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: rgba(20, 50, 67, 0.7);
        margin-bottom: 8px;

        .provider_item_left {
            display: flex;
            justify-content: flex-start;
            align-items: center;

            .pro_item_icon {
                width: 42px;
                height: 42px;
                margin-top: 12px;
            }

            .inThree {
                margin-left: -6px;
            }

            .afterThree {}

            .pro_item_title {
                font-size: 14px;
                width: 147px;
                color: #fff;
            }
        }

        .device_count {
            color: rgba($color: #fff, $alpha: 0.7);
            font-size: 12px;
        }
    }

    &::-webkit-scrollbar {
        display: none;
    }

}

.cloud_words_out {
    width: 292px;
    height: 340px;
    margin-top: 12px;
    background-color: rgba($color: #011B37, $alpha: 0.6);
}</style>
