平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

110 lines
2.2 KiB

  1. <template>
  2. <view @touchmove.stop @touch.stop>
  3. <myCell v-show="cellVisible" :title="title_" isLink :border="false" :hasValue="value?true:false"
  4. @click="cellClick" :align="align"></myCell>
  5. <u-popup :show="show" mode="center" :round="10" @close="close" @open="open">
  6. <view style="max-height: 800rpx;overflow-y: auto;">
  7. <u-radio-group v-model="value_" iconPlacement="right" placement="column" @change="change" borderBottom>
  8. <u-radio v-for="(item,index) in options" :key="index" :label="item.label" :name="item.value"></u-radio>
  9. </u-radio-group>
  10. </view>
  11. </u-popup>
  12. </view>
  13. </template>
  14. <script>
  15. import myCell from "@/components/cell.vue"
  16. export default {
  17. name: "selectRadio",
  18. components: {
  19. myCell
  20. },
  21. props: {
  22. value: {
  23. default: "",
  24. },
  25. options: {
  26. default: [],
  27. type: Array
  28. },
  29. title: {
  30. default: "",
  31. },
  32. placeholder: {
  33. default: "请选择",
  34. },
  35. cellVisible: {
  36. default: true,
  37. },
  38. align: {
  39. default: "left",
  40. },
  41. },
  42. data() {
  43. return {
  44. show: false,
  45. title_: this.title || this.placeholder,
  46. value_: this.value,
  47. };
  48. },
  49. mounted() {
  50. if (this.value) {
  51. let obj = this.options.find(e1 => e1.value == this.value)
  52. if (obj) this.title_ = obj.label
  53. }
  54. },
  55. methods: {
  56. cellClick() {
  57. if (!this.options.length) {
  58. this.TOAST('暂无数据')
  59. return
  60. }
  61. this.show = true
  62. },
  63. close() {
  64. this.show = false
  65. },
  66. open() {
  67. let obj = this.options.find(e1 => e1.value == this.value)
  68. this.title_ = obj ? obj.label : this.placeholder
  69. this.value_ = this.value
  70. this.show = true
  71. },
  72. change(e) {
  73. this.$emit("input", e)
  74. this.$emit("change", e)
  75. let obj = this.options.find(e1 => e1.value == e)
  76. this.title_ = obj ? obj.label : this.placeholder
  77. this.close()
  78. },
  79. }
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .u-radio-group {
  84. width: 560rpx;
  85. overflow-y: auto;
  86. padding: 12rpx 32rpx 24rpx 32rpx;
  87. .u-cell {
  88. background-color: #fff;
  89. border-radius: 20rpx;
  90. padding: 24rpx 0;
  91. }
  92. }
  93. .u-border-bottom {
  94. border-color: #F6F6F6 !important;
  95. }
  96. .u-radio {
  97. margin-top: 26rpx;
  98. padding-bottom: 28rpx !important;
  99. }
  100. .u-radio:last-child {
  101. border-bottom: none;
  102. padding-bottom: 14rpx !important;
  103. }
  104. </style>