index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- <div :style="`width: ${item.width || 120}px;`">{{ item.label }}</div> -->
  3. <v-radio-group
  4. v-model="value"
  5. :disabled="item.disabled"
  6. mandatory
  7. inline
  8. :hide-details="item.hideDetails || false"
  9. class="mr-8"
  10. @update:modelValue="modelValueUpDate"
  11. >
  12. <template v-slot:label>
  13. <div :style="`width: ${item.width || 120}px;`">{{ item.label }}</div>
  14. </template>
  15. <v-radio
  16. v-for="radio in item.items"
  17. :key="`${item.key}_radio_${radio.label}`"
  18. :readonly="radio.readonly"
  19. :label="radio.label"
  20. class="mr-3"
  21. :value="radio.value"
  22. :color="item.color || 'primary'"
  23. ></v-radio>
  24. </v-radio-group>
  25. </template>
  26. <script setup>
  27. import { ref, watch } from 'vue';
  28. defineOptions({ name:'FormUI-v-radio-group'})
  29. const props = defineProps({item: Object, modelValue: [String, Number, Boolean]})
  30. const emit = defineEmits(['update:modelValue', 'change'])
  31. const item = props.item
  32. const value = ref(props.modelValue)
  33. const modelValueUpDate = (val) => {
  34. value.value = val
  35. emit('update:modelValue', value.value)
  36. emit('change', value.value)
  37. }
  38. watch(
  39. () => props.modelValue,
  40. (val) => {
  41. value.value = val
  42. }
  43. )
  44. </script>
  45. <style lang="scss" scoped>
  46. :deep(.v-input__control) {
  47. flex-direction: row !important;
  48. }
  49. :deep(.v-selection-control-group) {
  50. margin-top: 0 !important;
  51. }
  52. :deep(.v-label) {
  53. margin-left: 0 !important;
  54. }
  55. </style>