<template>
    <!-- 反应釜：温度、搅拌 -->
    <div class="tank_body" :style="getTankBodyStyle">
        <!-- 罐体 -->
        <!-- font-size大小可调节 ，根据传进来的值来控制图标的大小 -->
        <i class="icon iconfont-hnyz-colour icon-hnyz-colourreactor_hollowedOut tank " :style="getTankStyle">
            <!-- 标题 -->
            <div class="tank_title" v-if="title">{{ title }}</div>
        </i>
        <!-- 搅拌电机 -->
        <div class="mixer_machine">
            <i class="icon iconfont icon-fengshan" :class="{ 'fan_run': getFanStatus }"></i>
        </div>
        <!-- temp值组件 -->
        <TempSlider :tempValue="tempValue" class="temp_pos" />
    </div>
</template>

<script setup>
import TempSlider from '@/components/HnyzDcs/TempSliderComponent.vue'
import { computed } from 'vue'

const props = defineProps({
    tempValue: {//temp
        type: Number,
        default: null
    },
    fanStatus: {//风扇状态
        type: Boolean,
        default: false,
    },
    iconSize: {//图标大小
        type: Number,
        default: 200,
    },
    title: {//罐名
        type: String,
    },
    iconWidth: {//图标宽度
        type: Number,
    },
    iconHeight: {//图标高度
        type: Number,
    },
})


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


// 罐子样式
const getTankStyle = computed(() => {
    const style = {
        fontSize: props.iconSize + 'px',
        display: 'inline-block'
    }
    //根据传进来的iconWidth和iconHeight来控制图标的大小
    const scaleX = props.iconWidth ? props.iconWidth / props.iconSize : 1
    const scaleY = props.iconHeight ? props.iconHeight / props.iconSize : 1

    if (scaleX !== 1 || scaleY !== 1) {
        style.transform = `scale(${scaleX}, ${scaleY})`
    }

    return style
})


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

//风扇状态
const getFanStatus = computed(() => {
    return props.fanStatus
})

</script>

<style scoped lang="scss">
.tank_body {
    text-align: center;
    position: relative;

    .tank {
        position: relative;
        z-index: 10;

        //罐子名称
        .tank_title {
            position: absolute;
            top: 75%;
            left: 49%;
            transform: translate(-50%, -50%);
            font-size: 30px;
            color: #e65100;
            font-weight: bold;
        }
    }

    .temp_pos {
        position: absolute;
        top: 40%;
        left: 64%;
        z-index: 100;
    }

    //搅拌电机
    .mixer_machine {
        position: absolute;
        top: 37%;
        left: 50%;
        transform: translate(-50%, -50%);

        .icon-fengshan {
            color: aliceblue;
            font-size: 50px;
            display: inline-block; 
        }

        //旋转动画
        @keyframes rotate-clockwise {
            from {
                transform: rotate(0deg);
            }

            to {
                transform: rotate(360deg);
            }
        }

        .fan_run {
            animation: rotate-clockwise 1s linear infinite;
        }
    }

}
</style>