<template>
    <div class="tank_valves" :style="getTankBodyStyle">
        <!-- 换热器水箱 泵-->
        <HeatExchangeWaterTank :title="title" :tempValue="tempValue" :fanStatus="fanStatus" :iconWidth="iconWidth"
            :iconHeight="iconHeight" :iconSize="iconSize" />
        <!-- 阀门进度 -->
        <div class="valve_progress">
            <!-- 左1 -->
            <ValveProgress :iconSize="valveIconSize" :title="valveNames[0]" :pipeLength="240" :pipeLeftOffset="-50"
                :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus"
                class="valve_progress1" />
            <!-- 下 -->
            <ValveProgress :iconSize="valveIconSize" :title="valveNames[1]" :pipeLength="400" :pipeLeftOffset="-50"
                :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" :rotateAngle="90"
                :pipeReverse="true" class="valve_progress2 rotate_90" />
            <!-- 右1  -->
            <ValveProgress :iconSize="valveIconSize" :title="valveNames[2]" :pipeLength="200" :pipeLeftOffset="-50"
                :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus"
                class="valve_progress3" />
            <!-- 泵上阀门 -->
            <ValveProgress :iconSize="valveIconSize" :title="valveNames[3]" :rotateAngle="90" :pipeLength="200"
                :pipeLeftOffset="-50" :valveStatusArr="initValveStatusArr" progressType="steam"
                :pipeStatus="initPipeStatus" :pipeReverse="true" class="valve_progress4 rotate_90" />
        </div>
        <!-- 泵进度 -->
        <div class="pump_progress">
            <PumpProgress :title="pumpNames[0]" :pumpDataArr="[1, 10]" :iconSize="pumpIconSize" :pipeType="steam"
                pumpDirection="L" class="pump_progress1" />
        </div>
        <!-- 拓展管道 -->
        <div class="pipes">
            <!-- 上 -->
            <Pipe :pipeStatus="initPipeStatus" :strokeWidth="pipeWidth"
                class="progress_steam progress_pos1 rotate_90" />
            <!-- 左  -->
            <Pipe :pipeStatus="initPipeStatus" :strokeWidth="pipeWidth"
                class="progress_steam progress_pos2 rotate_270" />
            <!-- 右上阀门拓展管道 -->
            <Pipe :pipeStatus="initPipeStatus" :strokeWidth="pipeWidth"
                class="progress_steam progress_pos3 rotate_180" />
            <Pipe :pipeStatus="initPipeStatus" :strokeWidth="pipeWidth"
                class="progress_steam progress_pos4 rotate_270" />

        </div>
    </div>
</template>

<script setup>
import HeatExchangeWaterTank from '@/components/HnyzDcs/HeatExchangeWaterTankComponent.vue';
import ValveProgress from '@/components/DCS/ValveProgressComponent.vue';
import Pipe from '@/components/HnyzDcs/PipeComponent.vue';
import PumpProgress from '@/components/DCS/PumpComponent.vue';
import { computed } from 'vue'
const initValveStatusArr = [true]
const initPipeStatus = true
const props = defineProps({
    iconSize: {//图标大小
        type: Number,
        default: 200,
    },
    title: {//罐名
        type: String,
    },
    iconWidth: {//图标宽度
        type: Number,
    },
    iconHeight: {//图标高度
        type: Number,
    },
    tempValue: {//temp
        type: Number,
        default: null
    },
    fanStatus: {//风扇状态
        type: Boolean,
        default: undefined,
    },
})

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

// 阀门名称映射表
const valveNameArr = {
    'V6102': ['ACV6111', 'ACV6112', 'ACV6115', 'ACV6116'],
    'V6103': ['ACV6121', 'ACV6122', 'ACV6124', 'ACV6125'],
    'V6106': ['ACV6130', 'ACV6131', 'ACV6133', 'ACV6134'],
}
//泵名称映射表
const pumpNameArr = {
    'V6102': ['P6105'],
    'V6103': ['P6108'],
    'V6106': ['P6111'],
}

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

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

//阀门icon大小（罐子100-阀门37.5）
const valveIconSize = computed(() => {
    return (props.iconWidth ?? props.iconSize) * 0.375;
});

//泵icon大小（罐子100-泵60）
const pumpIconSize = computed(() => {
    return (props.iconWidth ?? props.iconSize) * 0.6;
});

//管道宽度
const pipeWidth = computed(() => {
    return (props.iconWidth ?? props.iconSize) * 0.06;
});

</script>

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

    .valve_progress {
        .valve_progress1 {
            position: absolute;
            top: 35%;
            left: -42%;
        }

        .valve_progress2 {
            position: absolute;
            top: 120%;
            left: 60%;
        }

        .valve_progress3 {
            position: absolute;
            top: 60%;
            left: 107%;
        }

        .valve_progress4 {
            position: absolute;
            top: 24%;
            left: 185%;
        }

    }

    .pump_progress {
        .pump_progress1 {
            position: absolute;
            top: 83%;
            left: 184%;
            transform: translate(-50%, -50%);
        }
    }

    .pipes {
        .progress_pos1 {
            position: absolute;
            top: -18%;
            left: 52%;
            width: 200%;
        }

        .progress_pos2 {
            position: absolute;
            top: 184%;
            left: -58%;
            width: 254%;
        }

        .progress_pos3 {
            position: absolute;
            top: -14%;
            left: 65%;
            width: 116%;
        }

        .progress_pos4 {
            position: absolute;
            top: -63%;
            left: 68%;
            width: 110%;
        }
    }

}
</style>