lzc-picker.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view>
  3. <wyb-popup ref="popup" type="bottom" height="600" :maskClickClose="false" radius="12" :showCloseIcon="false">
  4. <view class="popup-content">
  5. <view class="popup_content_title">
  6. {{ pickerTittle }}
  7. <view class="iconfont icon-close icon_top" @tap="handleHide()"></view>
  8. </view>
  9. <view class="dialog_search_box">
  10. <view class="cuIcon-search text-grey dialog_search_text"></view>
  11. <input type="text" @input="inputValue" v-model="input_value" placeholder="输入关键词进行搜索" class="dialog_search_inp" />
  12. </view>
  13. <scroll-view scroll-y="true" class="select_item_box">
  14. <view class="select_item" hover-class="select_item_hover" @click="handleSelect(data)" v-for="(data, index) in options" :key="index">
  15. {{ data }}
  16. </view>
  17. </scroll-view>
  18. </view>
  19. </wyb-popup>
  20. </view>
  21. </template>
  22. <script>
  23. import wybPopup from "./wyb-popup.vue";
  24. export default {
  25. components: {
  26. wybPopup,
  27. },
  28. props: {
  29. pickerList: {
  30. type: Array,
  31. default: () => [],
  32. },
  33. pickerTittle: {
  34. type: String,
  35. default: "选择",
  36. },
  37. },
  38. watch: {
  39. pickerList: {
  40. handler: function (val, oldVal) {
  41. this.list = val;
  42. this.options = val;
  43. },
  44. immediate: true,
  45. deep: true, // 深度监听
  46. },
  47. },
  48. data() {
  49. return {
  50. input_value: "",
  51. list: [],
  52. options: [],
  53. };
  54. },
  55. onLoad() {},
  56. created() {
  57. this.options = this.list;
  58. },
  59. methods: {
  60. handleHide() {
  61. this.$refs.popup.hide();
  62. var a = this;
  63. setTimeout(() => {
  64. a.input_value = "";
  65. a.options = a.list;
  66. }, 100);
  67. },
  68. handleShow() {
  69. this.$refs.popup.show();
  70. },
  71. handleSelect(item) {
  72. console.log(item);
  73. var a = this;
  74. a.$emit("change", item);
  75. a.$refs.popup.hide();
  76. setTimeout(() => {
  77. a.input_value = "";
  78. a.options = a.list;
  79. }, 100);
  80. },
  81. inputValue(e) {
  82. var a = this;
  83. var inputTxt = e.detail.value;
  84. a.options = [];
  85. if (inputTxt.length == 0) {
  86. a.options = a.list;
  87. } else {
  88. a.options = a.list.filter((o) => {
  89. return String(o).indexOf(e.detail.value) >= 0;
  90. });
  91. }
  92. },
  93. },
  94. };
  95. </script>
  96. <style lang="scss">
  97. @import "./iconfont.css";
  98. .popup_content_title {
  99. padding-top: 30rpx;
  100. text-align: center;
  101. margin-bottom: 30rpx;
  102. position: relative;
  103. font-size: 36rpx;
  104. .icon_top {
  105. font-size: 50rpx;
  106. position: absolute;
  107. top: 20rpx;
  108. right: 20rpx;
  109. }
  110. }
  111. .dialog_search_box {
  112. width: 680rpx;
  113. height: 80rpx;
  114. background-color: #f8f8f8;
  115. border-radius: 12rpx;
  116. margin: 0 auto;
  117. display: flex;
  118. align-items: center;
  119. margin-bottom: 20rpx;
  120. .dialog_search_text {
  121. margin-left: 30rpx;
  122. font-size: 30rpx;
  123. }
  124. .dialog_search_inp {
  125. height: 76rpx;
  126. line-height: 76rpx;
  127. text-align: left;
  128. padding-left: 20rpx;
  129. width: 590rpx;
  130. }
  131. }
  132. .select_item_box {
  133. width: 750rpx;
  134. height: 480rpx;
  135. color: #333;
  136. .select_item {
  137. width: 680rpx;
  138. margin: 0 auto;
  139. padding: 16rpx 0;
  140. font-size: 30rpx;
  141. text-align: center;
  142. }
  143. .select_item_hover {
  144. background-color: #f8f8f8;
  145. }
  146. }
  147. </style>