<template>
  <el-switch
    v-model="val"
    active-color="#13ce66"
    inactive-color="#ff4949"
    :disabled="disabled"
    :active-text="active_text"
    :inactive-text="inactive_text"
  ></el-switch>
</template>

<script>
export default {
  name: 'PsSwitch',
  data() {
    return {
      val: false,
    }
  },
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    active_text: {
      type: String,
      default: '',
    },
    inactive_text: {
      type: String,
      default: '',
    },
  },
  watch: {
    value: {
      handler(newName) {
        this.val = newName
      },
      immediate: true,
    },
  },
  created() {
    this.val = this.value
  },
  methods: {
    change() {
      console.log(this.val)
      this.$emit('change', this.val)
    },
  },
}
</script>
