<template>
  <el-checkbox :value="checked" @change="onChange"><span v-if="label">{{ label }}</span></el-checkbox>
</template>

<script>
export default {
  name: "Checkbox",
  model: {
    prop: 'value',
    event: 'change',
  },
  props: {
    value: {
      type: [Number, String],
      require: true
    },
    label: {
      type: [Number, String],
      default: undefined
    },
  },
  computed: {
    checked() {
      return Number(this.value) === 1;
    }
  },
  methods: {
    onChange(value) {
      this.$emit("change", value ? 1 : 2);
    }
  }
}
</script>

<style scoped>

</style>
