search.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <view class="px3 py2 p-fixed left0 right0 bg-color-white ">
  4. <u-search placeholder="请输入名称或设备编号" v-model="keyword" @search="search" @custom="search">
  5. </u-search>
  6. </view>
  7. <view style="padding-top: 104rpx;">
  8. <template v-if="listData.length > 0">
  9. <view class="py2 px3 border-bottom" v-for="(item, index) in listData" :key="index"
  10. @click="handleBack(item)">
  11. <view class="one-ellipsis f-size-30 text-color-3">{{ item.name }}{{ item.model ? '(' + item.model +
  12. ')' : '' }}</view>
  13. <view class="f-size-26 text-color-6 mt-1">编号:{{ item.no || '无' }} 位置:{{ item.cph || '无' }}</view>
  14. </view>
  15. <view class="py3">
  16. <u-loadmore :status="status" />
  17. </view>
  18. </template>
  19. <template v-else>
  20. <view class="empty">
  21. <u-empty text="暂无数据" mode="list"></u-empty>
  22. </view>
  23. </template>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. keyword: '',
  32. listData: [],
  33. status: 'loadmore',
  34. page: 1,
  35. limit: 20,
  36. loadMore: true
  37. }
  38. },
  39. onLoad() {
  40. this.initData()
  41. },
  42. onPullDownRefresh() {
  43. // 请求结束取消刷新
  44. this.page = 1;
  45. this.loadMore = true;
  46. this.listData = [];
  47. this.initData();
  48. uni.stopPullDownRefresh();
  49. },
  50. onReachBottom() {
  51. if (this.loadMore) {
  52. this.page++;
  53. this.initData();
  54. }
  55. },
  56. methods: {
  57. handleBack(item) {
  58. const pages = getCurrentPages();
  59. const prevPage = pages[pages.length - 2];
  60. prevPage.sbBackId = item.id
  61. // prevPage.setData({
  62. // "ceshiId":item.id,
  63. // })
  64. // console.log(prevPage);
  65. uni.navigateBack();
  66. },
  67. search(value) {
  68. console.log(value);
  69. this.page = 1;
  70. this.loadMore = true;
  71. this.listData = [];
  72. this.initData();
  73. },
  74. initData() {
  75. const that = this
  76. that.status = 'loading';
  77. this.$Http
  78. .getSbInfoPage({
  79. pageNum: that.page,
  80. pageSize: that.limit,
  81. filter: -1,
  82. keyword: that.keyword
  83. })
  84. .then((res) => {
  85. const data = res.data.rows;
  86. if (data && data.length > 0 && data.length < that.limit) {
  87. that.status = 'nomore';
  88. that.loadMore = false;
  89. } else if (data.length == that.limit) {
  90. that.status = 'loadmore';
  91. } else {
  92. that.status = 'nomore';
  93. }
  94. that.listData = [...that.listData, ...data];
  95. console.log(that.listData);
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. page {
  103. background-color: #FFFFFF;
  104. }
  105. </style>