<template>
    <div>
        <div class="communication">
            <div class="battery_title">
                <span class="first"><img src="../assets/cangwei.png" /><p> {{chargerCode}}号充电机</p></span>
            </div>
            <div :class="statustext[1]">{{statustext[0]}}</div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "BatteryCharger",
        props:['chargerCode','comState','chgState',"sn","storeState"],
        data(){
            return{
                loading:false,
            }
        },
        computed:{
            statustext(){
                if(this.comState===1){
                    return ['通讯正常','success']
                }else{
                    return ['通讯异常','warning']
                }
            },
            buttonState(){
                if((this.chgState === 0 || this.chgState === 3) && this.storeState === 1){
                    return ['btnState','充电']
                }else if(this.chgState === 2  && this.storeState === 1){
                    return ['purple','断电']
                }else{
                    return 1
                }
            }
        },
    }
</script>

<style lang="scss" scoped>
.communication {
    display: flex;
    margin-bottom: 2.6vh;
    div {
        line-height: 36px;
        font-size: 16px;
        font-weight: 600;
        height: 36px;
        width: 136px;
        text-align: center;
    }

    .battery_title{
        background-color: #1b263a;
        border: #25334d solid 1px;
        color: white;
        line-height: 34px;
        display: flex;
        justify-content: space-between;
        padding: 0 5px;
        .is-disabled{
            width:90px;
            height: 28px;
            padding: 0 0 0 18px;
            border-radius: 15px;
            color: #5f6571;
            border-color:#353c4c;
            background: url('../assets/d3.png') #353c4c no-repeat 6px center;
        }
        .first{
            display: flex;
            p{
                flex: 1;
                margin: 0;
                padding: 0;
            }
        }
        .btnState{
            width:70px;
            height: 28px;
            padding: 0 0 0 15px;
            font-size: 14px;
            color: #fff;
            border-radius: 15px;
            margin-top: 2px;
            cursor: pointer;
            border: none;
            letter-spacing: 1px;
            background: url('../assets/d1.png') rgb(105, 184, 137) no-repeat 10px center;
        }
        .btnState:hover{
            background-color:rgb(105, 184, 137,0.8);
        }
        .purple{
            width:70px;
            height: 28px;
            padding: 0 0 0 15px;
            font-size: 14px;
            color: #fff;
            border-radius: 15px;
            margin-top: 2px;
            cursor: pointer;
            border: none;
            letter-spacing: 1px;
            background: url('../assets/d2.png') rgb(224, 125, 68) no-repeat 10px center;
        }
        .purple:hover{
            background-color:rgb(224, 125, 68,0.8);
        }
        img {
            vertical-align: middle;
        }
    }

    .success {
        color: #92fdb9;
        text-align: right;
    }
    .warning {
        color: #c85e60;
        text-align: right;
    }
}
</style>