radio-group.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="radio-group-view">
  3. <view v-if="label" class="label-view">
  4. <text>{{ label }}</text>
  5. </view>
  6. <view class="radio-group">
  7. <template v-for="(item, i) in list">
  8. <view class="radio-item" :key="i" @click="toggleSelect(item, i)">
  9. <text class="text">{{ item[setting.name] }}</text>
  10. <image class="icon"
  11. :src="`/static/${item[setting.value] === defaultValue ? 'check-radio' : 'check-no'}.png`"></image>
  12. </view>
  13. </template>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. /**
  19. * 单选列表组合
  20. * 芦荟
  21. * 2021.2.2
  22. * props:属性说明看tm-radio-gruop.vue
  23. */
  24. export default {
  25. props: ['list', 'defaultValue', 'label', 'setting', 'pIndex'],
  26. methods: {
  27. /**
  28. * 选中变化调用
  29. * @param {Object} selectData 当前选中的对象
  30. * @param {Object} index 当前选中下标
  31. *
  32. * 返回的参数
  33. * selectData[this.setting.value]: 当前选中的值
  34. * selectData: 当前选中的整条数据
  35. * index: 当前选中的下标
  36. */
  37. toggleSelect(selectData, index){
  38. this.$emit(
  39. 'change',
  40. selectData ? selectData[this.setting.value] : '',
  41. selectData,
  42. index,
  43. this.pIndex
  44. );
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="less">
  50. .radio-group-view {
  51. .label-view {
  52. height: 47.5rpx;
  53. line-height: 45rpx;
  54. padding-left: 25rpx;
  55. >text {
  56. font-size: 22.5rpx;
  57. color: #666F80;
  58. }
  59. }
  60. .radio-group {
  61. padding-left: 25rpx;
  62. background-color: #fff;
  63. .radio-item {
  64. display: flex;
  65. align-items: center;
  66. justify-content: space-between;
  67. height: 87.5rpx;
  68. border-bottom: 0.62rpx solid #DADEE6;
  69. padding-right: 25rpx;
  70. .text {
  71. font-size: 22.5rpx;
  72. color: #292C33;
  73. }
  74. .icon {
  75. width: 25rpx;
  76. height: 25rpx;
  77. }
  78. }
  79. }
  80. }
  81. </style>