myRadio.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="my-radio">
  3. <div style="display: flex;flex-direction: column;min-width: 150px;">
  4. <span :style="[{'color':textColor},{'marginBottom':'5px'}]">{{ title }}</span>
  5. <a-radio-group v-bind="$attrs" :style="[{'--textColor':textColor}]" :disabled="disabled" @change="change">
  6. <a-radio :style="radioStyle" :value="item.value" v-for="item in options">{{ item.label }}</a-radio>
  7. </a-radio-group>
  8. <customBtn
  9. style="text-align:right;margin-top: 10px;" btnColor="rgb(22,255,246)"
  10. textColor="#000000"
  11. :btnOptions="[{label:'更新',value:'timeshared'}]"
  12. @clickBtn="emitData()"
  13. ></customBtn>
  14. </div>
  15. <slot></slot>
  16. </div>
  17. </template>
  18. <script setup>
  19. import {Modal} from 'ant-design-vue'
  20. import {ref, defineProps, defineEmits} from 'vue'
  21. import customBtn from './customBtn.vue'
  22. import Api from '@/api/api'
  23. import utils from '@/utils/utils'
  24. let emit = defineEmits(['Change'])
  25. let currentData = ref('')
  26. let props = defineProps({
  27. title: {
  28. type:String
  29. },
  30. data: {
  31. type:[Number,String],
  32. default:() => ''
  33. },
  34. options: {
  35. type:Array,
  36. default:() => []
  37. },
  38. textColor: {
  39. type:String,
  40. default:() => '#ffffff'
  41. },
  42. disabled:{
  43. type:Boolean,
  44. default:() => false
  45. }
  46. })
  47. const radioStyle = ref({
  48. color:'#ffffff',
  49. marginBottom:'10px',
  50. fontSize:'12px'
  51. });
  52. let emitData = () => {
  53. currentData.value = props.data
  54. if (currentData.value === '') return
  55. emit('Change',currentData.value)
  56. }
  57. let change = (data) => {
  58. currentData.value = data
  59. }
  60. </script>
  61. <style scoped>
  62. /deep/.ant-radio-group {
  63. display: flex;
  64. flex-wrap: wrap;
  65. justify-content: space-between;
  66. }
  67. /deep/.ant-radio-checked .ant-radio-inner {
  68. border-color: #16FFF6 !important;
  69. }
  70. /deep/.ant-radio-inner:after {
  71. background-color: #16FFF6 !important;
  72. }
  73. /deep/.ant-radio-inner {
  74. background: none;
  75. }
  76. /deep/.ant-radio-wrapper {
  77. color: var(--textColor) !important;
  78. }
  79. /deep/.ant-radio-disabled+span {
  80. color: #ffffff !important;
  81. }
  82. .my-radio {
  83. display: flex;
  84. justify-content: space-between;
  85. }
  86. /deep/.ant-radio-wrapper {
  87. margin: 0 !important;
  88. }
  89. </style>