<template>
    <div class="tank_valves" :style="getTankBodyStyle">
        <STypeTank :title="title" :waterLevelValue="waterLevelValue" :iconWidth="iconWidth" :iconHeight="iconHeight"
            :iconSize="iconSize" :tempValue="tempValue" :fanStatus="fanStatus"></STypeTank>
        <!-- 阀门进度 -->
        <div class="valve_progress">
            <div :style="valveProgressStyle" class="valve_progress1" v-if="valveNames[0]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[0]" :pipeLength="200" :pipeLeftOffset="-38"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress2" v-if="valveNames[1]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[1]" :pipeLength="200" :pipeLeftOffset="-60"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress3" v-if="valveNames[2]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[2]" :pipeLength="250" :pipeLeftOffset="-60"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress4 rotate_90" v-if="valveNames[3]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[3]" :rotateAngle="90" :pipeLength="400"
                    :pipeLeftOffset="-121" :valveStatusArr="initValveStatusArr" progressType="steam"
                    :pipeStatus="initPipeStatus" />
            </div>
        </div>
    </div>
</template>

<script setup>
import STypeTank from '@/components/HnyzDcs/STypeTankComponent.vue';
import ValveProgress from '@/components/DCS/ValveProgressComponent.vue';
import { computed } from 'vue'
const initValveStatusArr = [true]
const initPipeStatus = true
const props = defineProps({
    tempValue: {//temp
        type: Number,
        default: null
    },
    waterLevelValue: {// 水位值
        type: Number,
        default: -1,// -1表示未传水位值
    },
    fanStatus: {//风扇状态
        type: Boolean,
        default: false,
    },
    iconSize: {//图标大小
        type: Number,
        default: 200,
    },
    title: {//罐名
        type: String,
    },
    iconWidth: {//图标宽度
        type: Number,
    },
    iconHeight: {//图标高度
        type: Number,
    },
})


//默认阀门名称数组
const defaultValveNames = new Array(4).fill('ACV_default')

// 阀门名称映射表
const valveNameArr = {
    'S2002': ['ACV2032', 'ACV2033', 'ACV2034', 'ACV2044'],
    'S2004': ['ACV2039', '', 'ACV2040', ''],
}

//阀门名称数组,根据罐名来匹配
const valveNames = computed(() => {
    return valveNameArr[props.title] || defaultValveNames
})

//罐体样式
const getTankBodyStyle = computed(() => ({
    width: `${props.iconWidth ?? props.iconSize}px`,
    height: `${props.iconHeight ?? props.iconSize}px`,
}))

//temp值
const tempValue = computed({
    get() {
        return props.tempValue
    },
})

//阀门icon大小（罐子200-阀门50）
const valveIconSize = computed(() => {
    return props.iconSize * 0.25;
});

//阀门进度样式
const valveProgressStyle = computed(() => {
    return {
        width: `${valveIconSize.value}px`,
        height: `${valveIconSize.value}px`,
    }
});

</script>

<style scoped lang="scss">
.tank_valves {
    position: relative;
    z-index: 10;

    .valve_progress {
        .valve_progress1 {
            position: absolute;
            top: 16%;
            left: -12%;
        }

        .valve_progress2 {
            position: absolute;
            top: 76%;
            left: -7%;
        }

        .valve_progress3 {
            position: absolute;
            top: 16%;
            left: 91%;
        }

        .valve_progress4 {
            position: absolute;
            top: 170%;
            left: 54%;
        }
    }
}
</style>