My_search.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="My_search" :style="{ background: bgColor }">
  3. <slot name="left" />
  4. <u-search v-model="value" :focus="focus" :showAction="false" @search="onSearch" @custom="onSearch" @clear="onSearch"
  5. :placeholder="placeholder" />
  6. <view v-if="isFilter" @click="startFilter" class="filtrate" hover-class="navigator-hover">
  7. <text class="iconfont icon-shaixuan" />筛选
  8. </view>
  9. <My_filter ref="filter" :filter1="filter" :dateRange="dateRange" @onConfirm="onConfirm" />
  10. </view>
  11. </template>
  12. <script>
  13. import My_filter from "./My_filter.vue";
  14. export default {
  15. name: 'My_search',
  16. components: { My_filter },
  17. props: {
  18. placeholder: {
  19. type: String,
  20. default: "请输入关键字"
  21. },
  22. isFilter: {
  23. type: Boolean,
  24. default: true
  25. },
  26. startSearch: Function,
  27. onFilter: Function,
  28. customFiltering: {
  29. type: Boolean,
  30. default: false
  31. },
  32. filter: {
  33. type: Array,
  34. default: () => []
  35. },
  36. dateRange: Boolean,
  37. heightReduction: {
  38. type: Number,
  39. default: 0
  40. },
  41. bgColor: {
  42. type: String,
  43. default: '#052E5D'
  44. },
  45. focus: Boolean
  46. },
  47. data() {
  48. return {
  49. value: ""
  50. };
  51. },
  52. methods: {
  53. onSearch(value) {
  54. this.$emit("startSearch", value)
  55. },
  56. startFilter() {
  57. if (this.customFiltering) return this.$emit("onFilter");
  58. this.$refs.filter.open(this.heightReduction);
  59. },
  60. onConfirm(res) {
  61. this.$emit("onFilter", res)
  62. },
  63. onFinish() {
  64. this.$refs.filter.close();
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .My_search {
  71. display: flex;
  72. align-items: center;
  73. width: 100vw;
  74. height: 45px;
  75. padding: 8px 10px;
  76. box-sizing: border-box;
  77. .filtrate {
  78. height: 30px;
  79. line-height: 30px;
  80. text-align: center;
  81. margin-left: 5px;
  82. font-size: 14px;
  83. color: #FFFFFF;
  84. border-radius: 4px;
  85. .iconfont {
  86. margin-right: 3px;
  87. font-size: 14px;
  88. }
  89. }
  90. /deep/ .u-search .u-search__content {
  91. height: 29px !important;
  92. }
  93. /deep/ .u-icon__icon {
  94. font-size: 22px !important;
  95. line-height: 22px !important;
  96. }
  97. }
  98. </style>