fs-checkbox-cell.vue 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <fs-cell
  3. border
  4. justify="right"
  5. :title="label"
  6. @click="handleToggle">
  7. <template #title>
  8. <slot></slot>
  9. </template>
  10. <template #value>
  11. <fs-icon type="icon-right" :color="checkedColor" :colorType="checkedColorType" v-if="selected"></fs-icon>
  12. </template>
  13. </fs-cell>
  14. </template>
  15. <script setup>
  16. import { ref, watch, inject, toRefs } from 'vue'
  17. const props = defineProps({
  18. label: String,
  19. value: {
  20. type: null,
  21. required: true
  22. },
  23. checkedColor: String,
  24. checkedColorType: String,
  25. })
  26. const checkboxGroup = inject('checkboxGroup')
  27. const { reverse, inline, justify } = checkboxGroup
  28. const checkedColorType = props.checkedColorType || checkboxGroup.checkedColorType
  29. const checkedColor = props.checkedColor || checkboxGroup.checkedColor
  30. let selected = ref(false)
  31. checkboxGroup.updateChildren({
  32. selected,
  33. value: props.value
  34. })
  35. const handleToggle = () => {
  36. checkboxGroup.updateValue(props.value)
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. </style>