<template>
  <CheckBox
    :modelValue="checked"
    @update:modelValue="(v: boolean) => $emit('update:modelValue', v ? checkedValue : uncheckedValue)"
    :disabled="disabled"
    :text="text"
  />
</template>

<script setup lang="ts">
import CheckBox from "@/components/form/CheckBox.vue";
import { computed } from "vue";

const props = defineProps({
  checkedValue: {
    type: Number,
    default: 1
  },
  uncheckedValue: {
    type: Number,
    default: 0
  },
  disabled: {
    type: Boolean,
    default: false
  },
  text: {
    type: String,
    default: '启用',
  },
  modelValue: {
    default: null,
  }
});
const checked = computed(() => props.modelValue == props.checkedValue);
const emit = defineEmits([ 'update:modelValue' ]);
 
</script>