<template>
    <div class="flex_home">
        <HeadlineTag type="right" :value="waterData.deviceName"></HeadlineTag>
        <div class="box_arch">
            <div class="left_content">
                <div class="item_water_supply" v-for="(item, index) in leftData" :key="index">
                    <div class="left_supply_value">{{ item.value || 0 }}{{ item.configUnit }}</div>
                    <div class="left_supply">{{ item.title }}</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import HeadlineTag from '@/components/HeadlineTag'
const props = defineProps({
    waterData: {
        type: Object,
        default: {}
    }
})
const leftData = ref([{
    title: '累计流量',
    pointId: '0103001CO0',
    value: '',
    configUnit: 'm³',
}, {
    title: '瞬时流量',
    pointId: '0103001AW0',
    value: '',
    configUnit: 'm³/h',
}, {
    title: '高液位限值小端',
    pointId: '01030021Y0',
    value: '',
    configUnit: '',
}, {
    title: '低液位限值小端',
    pointId: '0103001FY0',
    value: '',
    configUnit: '',
}])
watch(() => props.waterData, (newVal) => {
    if (newVal) {
        leftData.value[0].value = newVal['累计流量']
        leftData.value[1].value = newVal['瞬时流量']
        leftData.value[2].value = newVal['高液位限值小端']
        leftData.value[3].value = newVal['低液位限值小端']
    }
    // if (newVal && Array.isArray(newVal.points)) {
    //     leftData.value.forEach(item => {
    //         const point = newVal.points.find(p => p.pointId === item.pointId);
    //         if (point) {
    //             if (item.pointId === "0103001CO0" || item.pointId === '01030008K0') {
    //                 item.value = point.calculatedValue;
    //                 item.configUnit = point.configUnit;
    //             } else {
    //                 item.value = point.value;
    //                 item.configUnit = point.configUnit;
    //             }
    //         }
    //     });
    // }
}, { deep: true, immediate: true })
</script>

<style scoped lang="scss">
.flex_home {
    width: 100%;
    height: auto;
    color: #fff;
    margin-bottom: 10px;
}

.box_arch {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
}

.left_content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
}

.item_water_supply {
    width: calc(50% - 20px);
    height: 25%;
    margin-right: 30px;
    background: url("@/assets/images/tjimage.png");
    background-size: 100% 100%;
    background-position: right;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    flex-direction: column;
    padding: 15px 30px;
    margin: 15px 10px 0px 10px;
}

.left_supply {
    margin-top: 4px;
    font-size: 20px;
}

.left_supply_value {
    font-size: 20px;
    color: #f0e064;
}
</style>