<template>
    <div class="tank_valves" :style="getTankBodyStyle">
        <Separator :title="title" :iconWidth="iconWidth" :iconHeight="iconHeight" :iconSize="iconSize"></Separator>

        <!-- 阀门进度 -->
        <div class="valve_progress">
            <div :style="valveProgressStyle" class="valve_progress1" v-if="valveNames[0]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[0]" :pipeLength="474" :pipeLeftOffset="-229"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress2" v-if="valveNames[1]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[1]" :pipeLength="324" :pipeLeftOffset="-54"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress3" v-if="valveNames[2]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[2]" :pipeLength="430" :pipeLeftOffset="-267"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress4" v-if="valveNames[3]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[3]" :pipeLength="324" :pipeLeftOffset="-162"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress5" v-if="valveNames[4]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[4]" :pipeLength="324" :pipeLeftOffset="-136"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress6 rotate_90" v-if="valveNames[5]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[5]" :rotateAngle="90" :pipeLength="380"
                    :pipeLeftOffset="-55" :valveStatusArr="initValveStatusArr" progressType="steam"
                    :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress7 rotate_270" v-if="valveNames[6]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[6]" :rotateAngle="270" :pipeLength="517"
                    :pipeLeftOffset="-363" :valveStatusArr="initValveStatusArr" progressType="steam"
                    :pipeStatus="initPipeStatus" :pipeReverse="true" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress8" v-if="valveNames[7]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[7]" :pipeLength="352" :pipeLeftOffset="-153"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
            <div :style="valveProgressStyle" class="valve_progress9" v-if="valveNames[8]">
                <ValveProgress :iconSize="valveIconSize" :title="valveNames[8]" :pipeLength="502" :pipeLeftOffset="-182"
                    :valveStatusArr="initValveStatusArr" progressType="steam" :pipeStatus="initPipeStatus" />
            </div>
        </div>

        <!-- 运输器及管道 -->
        <div class="transport_progress">
            <div :style="ConveyorStyle" class="transport_progress1 zIndex10" v-if="initHasValve">
                <Conveyor title="PD2005" iconSize="60" />
            </div>
        </div>
        <!-- 料仓 -->
        <div class="stock_bins">
            <div class="stock_bin_pos1 zIndex10">
                <i class="icon iconfont-hnyz-colour icon-hnyz-colourstockBin"></i>
                <div class="stock_bin_text">料仓LC2002</div>
            </div>
        </div>
        <!-- 拓展管道 -->
        <div class="pipes">
            <Pipe :pipeStatus="true" class="progress_steam progress_pos1 rotate_90"></Pipe>
        </div>
    </div>
</template>

<script setup>
import Pipe from '@/components/HnyzDcs/PipeComponent.vue';
import Separator from '@/components/HnyzDcs/SeparatorComponent.vue';
import ValveProgress from '@/components/DCS/ValveProgressComponent.vue';
import Conveyor from '@/components/HnyzDcs/ConveyorComponent.vue';
import { computed } from 'vue'
const initHasValve = true
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(9).fill('ACV_default')
// 阀门名称映射表
const valveNameArr = {
    'S2001': ['ACV2013', 'ACV2014', 'ACV2016', 'ACV2017', 'ACV2015', 'ACV2018', 'ACV2019', 'ACV2029', 'ACV2030'],
}
//阀门名称数组,根据罐名来匹配
const valveNames = computed(() => {
    return valveNameArr[props.title] || defaultValveNames
})

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

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

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

//泵icon大小（罐子200-泵60）
const transportIconSize = computed(() => {
    return props.iconSize * 0.3;
});

//泵进度样式
const ConveyorStyle = computed(() => {
    return {
        width: `${transportIconSize.value}px`,
        height: `${transportIconSize.value}px`,
    }
});

</script>

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

    .valve_progress {
        .valve_progress1 {
            position: absolute;
            top: 10%;
            left: -33%;
        }

        .valve_progress2 {
            position: absolute;
            top: 48%;
            left: -33%;
        }

        .valve_progress3 {
            position: absolute;
            top: 2%;
            left: 120%;
        }

        .valve_progress4 {
            position: absolute;
            top: 37%;
            left: 120%;
        }

        .valve_progress5 {
            position: absolute;
            top: 72%;
            left: 94%;
        }

        .valve_progress6 {
            position: absolute;
            top: -50%;
            left: 78%;
        }

        .valve_progress7 {
            position: absolute;
            top: -50%;
            left: 106%;
        }

        .valve_progress8 {
            position: absolute;
            top: -20%;
            left: 150%;
        }

        .valve_progress9 {
            position: absolute;
            top: -44%;
            left: 120%;
        }
    }

    .transport_progress {
        .transport_progress1 {
            position: absolute;
            top: 158%;
            left: 48%;
            transform: translate(-50%, -50%);
        }
    }

    .stock_bins {
        .stock_bin_pos1 {
            position: absolute;
            top: 98%;
            left: 23%;
            display: flex;
            align-items: center;

            i {
                font-size: 75px;
            }

            .stock_bin_text {
                font-size: 16px;
                color: aliceblue;
            }
        }
    }

    .pipes {
        .progress_pos1 {
            position: absolute;
            top: 110%;
            left: 40%;
            width: 80%;
        }
    }

}
</style>