<template>
    <div id="digital-flop">
        <div class="digital-flop-item" v-for="item in digitalFlopData" :key="item.title">
            <div class="digital-flop-title">{{ item.title }}</div>
            <div class="digital-flop">
                <dv-digital-flop :config="item.number" style="width:100px;height:50px;" />
                <div class="unit">{{ item.unit }}</div>
            </div>
        </div>

        <dv-decoration-10 />
    </div>
</template>
  
<script setup name='digitalFlop' lang="ts">
import { Ref, ref, nextTick, watch } from 'vue'

const props = defineProps({
    digitalFlop: {
        type: Object,
        default: {}
    }
})

interface dataInfo {
    reportName: string,
    overview: any,
    unit: string,
}

interface arrInfo {
    title: string,
    number: object,
    unit: string,
}

let digitalFlopData: Ref<Array<arrInfo>> = ref([])

watch(() => props.digitalFlop, () => {
    digitalFlopData.value = []

    nextTick(() => {
        props.digitalFlop.forEach((e: dataInfo) => {
            let v: number = parseFloat(e.overview)
            let d = {
                title: e.reportName,
                number: {
                    number: [v],
                    content: '{nt}',
                    style: {
                        fill: '#4d99fc',
                        fontWeight: 'bold'
                    }
                },
                unit: e.unit
            }
            digitalFlopData.value.push(d)
        })
    })
},{deep: true, immediate: true})

</script>
  
<style lang="scss">
#digital-flop {
    position: relative;
    height: 15%;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(6, 30, 93, 0.5);

    .dv-decoration-10 {
        position: absolute;
        width: 95%;
        left: 2.5%;
        height: 5px;
        bottom: 0px;
    }

    .digital-flop-item {
        width: 11%;
        height: 80%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        border-left: 3px solid rgb(6, 30, 93);
        border-right: 3px solid rgb(6, 30, 93);
    }

    .digital-flop-title {
        font-size: 20px;
        margin-bottom: 20px;
        text-align: center;
    }

    .digital-flop {
        display: flex;
    }

    .unit {
        margin-left: 10px;
        display: flex;
        align-items: flex-end;
        box-sizing: border-box;
        padding-bottom: 13px;
    }
}
</style>