index.vue 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <a-checkbox-group v-model="value" :direction="props.direction" :disabled="props.disabled" @change="handleChangeEvent($event)">
  3. <template v-for="(item, index) in dictList[props.dict] ?? []">
  4. <a-checkbox :value="item.value">{{ item.label }}</a-checkbox>
  5. </template>
  6. </a-checkbox-group>
  7. </template>
  8. <script setup>
  9. import { ref, watch } from 'vue'
  10. import { useDictStore } from '@/store'
  11. const dictList = useDictStore().data
  12. const emit = defineEmits(['update:modelValue', 'change'])
  13. const value = ref()
  14. const props = defineProps({
  15. modelValue: { type: Array, default: () => [] },
  16. dict: { type: String, default: '' },
  17. disabled: { type: Boolean, default: false },
  18. direction: { type: String, default: 'horizontal' },
  19. })
  20. watch(
  21. () => props.modelValue,
  22. (vl) => {
  23. value.value = vl
  24. },
  25. { immediate: true }
  26. )
  27. watch(
  28. () => value.value,
  29. (v) => {
  30. emit('update:modelValue', value.value)
  31. }
  32. )
  33. const handleChangeEvent = async (value) => {
  34. emit('change', value)
  35. }
  36. </script>