平安校园
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

123 lignes
2.6 KiB

  1. <template>
  2. <view>
  3. <myCell :title="title_" isLink :border="false" @click="show = true"></myCell>
  4. <u-popup :show="show" mode="bottom" :closeable="true" :round="10" @close="close" @open="open">
  5. <view>
  6. <view class="title">
  7. {{'请选择' + popupTitle}}
  8. </view>
  9. <view style="padding: 0 30rpx 30rpx 30rpx">
  10. <u-search v-model="searchText" :placeholder="'请输入'+(searchPlaceHolder||popupTitle)" shape="round"
  11. :showAction="false"></u-search>
  12. </view>
  13. <u-radio-group :value="value_" iconPlacement="right" placement="column" @change="change" borderBottom>
  14. <u-radio v-show="item.label.includes(searchText)" v-for="(item,index) in options" :key="index" :label="item.label"
  15. :name="item.value"></u-radio>
  16. </u-radio-group>
  17. <view style="padding: 36rpx 50rpx">
  18. <u-button @click="cofirm" type="primary" style="border-radius: 36rpx;height: 72rpx;"
  19. text="确定"></u-button>
  20. </view>
  21. </view>
  22. </u-popup>
  23. </view>
  24. </template>
  25. <script>
  26. import myCell from "@/components/cell.vue"
  27. export default {
  28. name: "selectRadio",
  29. components: {
  30. myCell
  31. },
  32. props: {
  33. value: {
  34. default: "",
  35. type: String | Number
  36. },
  37. options: {
  38. default: [],
  39. type: Array
  40. },
  41. title: {
  42. default: "",
  43. type: String
  44. },
  45. popupTitle: {
  46. default: "",
  47. type: String
  48. },
  49. searchPlaceHolder: {
  50. default: "",
  51. type: String
  52. },
  53. },
  54. data() {
  55. return {
  56. show: false,
  57. title_: this.title,
  58. value_: this.value,
  59. radioValue: '',
  60. searchText: ''
  61. };
  62. },
  63. mounted() {
  64. if (this.value) {
  65. let obj = this.options.find(e1 => e1.value == this.value)
  66. if (obj) this.title_ = obj.label
  67. }
  68. },
  69. methods: {
  70. close() {
  71. this.show = false
  72. },
  73. open() {
  74. let obj = this.options.find(e1 => e1.value == this.value)
  75. if (obj) this.title_ = obj.label
  76. this.title_ = obj ? obj.label : (this.popupTitle || this.title)
  77. this.value_ = this.value
  78. this.searchText = ''
  79. },
  80. change(e) {
  81. this.radioValue = e
  82. },
  83. cofirm() {
  84. this.$emit("update:value", this.radioValue)
  85. this.$emit("change", this.radioValue)
  86. let obj = this.options.find(e1 => e1.value == this.radioValue)
  87. if (obj) this.title_ = obj.label
  88. this.close()
  89. },
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .title {
  95. color: #000000;
  96. font-size: 32rpx;
  97. text-align: center;
  98. line-height: 100rpx;
  99. }
  100. .u-radio-group {
  101. width: 92%;
  102. max-height: 680rpx;
  103. overflow-y: auto;
  104. padding: 0 30rpx;
  105. .u-cell {
  106. background-color: #fff;
  107. border-radius: 20rpx 20rpx 0 0;
  108. padding: 24rpx 0;
  109. }
  110. }
  111. .u-border-bottom {
  112. border-color: #F6F6F6 !important;
  113. }
  114. .u-radio {
  115. margin-top: 18rpx;
  116. }
  117. </style>