<template>
    <span :class="label?'sel-span':''" v-if="!hideCK">
        <span v-if="label">{{$dict.tranByPubMap(label)}} :</span>
        <el-switch active-color="#13ce66" v-model="isSel"  v-bind="$attrs" @change="onchange" :style="$attrs.elstyle" > </el-switch>
    </span>
    
</template>


<script>


export default {
    props:["label","type","value"],
    data() {
        return {
            isSel : (this.value==1 || this.value===true)
        }
    },

    mounted() {
    },
    computed: {
        hideCK(){ // 暂时处理ck功能 目前仅88u支持，且默认1
            if(this.label ==='ck' && ['bet88u','17br'].includes(this.$store.state.envCfg.envFlag)){
                this.isSel=true;
                this.$emit('input',1);
                this.$emit('change',1);
            }
            return this.label ==='ck' && !['bet88u','17br'].includes(this.$store.state.envCfg.envFlag);
        },
    },
    watch:{
        value(newval){
            this.isSel = (newval==1 || newval===true)
        }
    },
    methods: {
        onchange(){
            var val = null;
            if(this.type=="number"){
                val = this.isSel ? 1 : 0
            }else{
                val = this.isSel ? true : false
            }
            this.$emit('input',val);
            this.$emit('change',val);
        }
    }
}
</script>

<style lang="less" scoped>
    .sel-span{
        display: inline-block;
        margin-left: 10px;
        margin-right: 10px;
        >span{
            display: inline-block;
            white-space: nowrap;
            color:gray;
            font-size: 15px;
        }
    }
</style>