平安校园
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

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