CommonList.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="common-list-v" v-if="show">
  3. <view class="common-list-contain">
  4. <view class="common-list-main u-p-20 u-flex-col">
  5. <view class="common-list-search" style=" ">
  6. <uni-search-bar radius="100" placeholder="请输入" clearButton="always" cancelButton="always"
  7. @cancel="cancel" v-model="searchValue" focus />
  8. </view>
  9. <view class="" style="flex: 1;margin-top: 10rpx; overflow-y: scroll;" v-if="columnList.length">
  10. <view class="u-line-1" style="width: 100%;height:68rpx;line-height: 68rpx;"
  11. v-for="(item,index) in columnList" :key="index" @click.stop="selectConfirm(item)">
  12. {{item.commonWordsText}}
  13. </view>
  14. </view>
  15. <JnpfEmpty v-else />
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. getSelector
  23. } from "@/api/commonWords.js";
  24. export default {
  25. data() {
  26. return {
  27. show: false,
  28. commonWordsList: [],
  29. searchValue: ''
  30. }
  31. },
  32. computed: {
  33. columnList() {
  34. return this.commonWordsList.filter((o) => (o.commonWordsText && o.commonWordsText.match(this.searchValue)))
  35. }
  36. },
  37. methods: {
  38. open() {
  39. this.show = true
  40. this.getCommonList()
  41. },
  42. cancel() {
  43. this.close()
  44. },
  45. close() {
  46. this.searchValue = ""
  47. this.show = false
  48. },
  49. selectConfirm(item) {
  50. this.$emit('confirm', item)
  51. this.close()
  52. },
  53. getCommonList() {
  54. getSelector().then((res) => {
  55. let list = JSON.parse(JSON.stringify(res.data.list)) || []
  56. this.commonWordsList = list
  57. });
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss">
  63. .common-list-v {
  64. z-index: 9000;
  65. position: fixed;
  66. left: 0;
  67. top: 0;
  68. width: 100%;
  69. height: 100vh !important;
  70. .common-list-contain {
  71. height: 100%;
  72. width: 100%;
  73. .common-list-main {
  74. background: white;
  75. height: 100%;
  76. .common-list-search {
  77. width: 100%;
  78. height: 70rpx;
  79. .uni-searchbar {
  80. width: 100%;
  81. padding: 0;
  82. .uni-searchbar__box {
  83. justify-content: flex-start !important;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. </style>