<template>
    <div class="flex_home">
        <HeadlineTag type="left" :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">{{ item.title }}</div>
                    <div class="left_supply_value">{{ item.value || 0 }}{{ item.configUnit }}</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: '01030016W0',
    value: '',
    configUnit: 'm',
}, {
    title: '压力',
    pointId: '03030002W0',
    value: '',
    configUnit: 'MPa',
}, {
    title: '温度',
    pointId: '01030009K0',
    value: '',
    configUnit: '℃',
}, {
    title: '湿度',
    pointId: '01030008K0',
    value: '',
    configUnit: '%RH',
}])

watch(() => props.waterData, (newVal) => {
    if (newVal) {
        leftData.value[0].value = newVal.liquid_level
        leftData.value[1].value = newVal.pressure
        leftData.value[2].value = newVal.temperature
        leftData.value[3].value = newVal.humidity
    }
}, { 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;
}

.arch_icon {
    width: 45%;
    height: 45%;
    margin-bottom: 5%;
}

.left_content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.item_water_supply {
    width: calc(100% - 20px);
    height: 45px;
    background: url("@/assets/images/table_row_bg.png");
    background-size: 100% 100%;
    background-position: right;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0px 30px;
    margin: 10px 10px 0px 10px;
}

.left_supply {
    font-size: 18px;
    font-weight: bold;
}

.left_supply_value {
    font-size: 18px;
    color: #9bf06f;
    padding-left: 10px;
}

.right_content {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
}

.title_row {
    display: flex;
    align-items: center;
}
</style>