chooseBulk.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货柜名称搜索"
  6. v-model="queryWord"
  7. :show-action="isGobleSearch"
  8. @focus="isGobleSearch=true"
  9. @custom="searchPart"
  10. @search="searchPart"
  11. @clear="searchPart"
  12. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  13. </u-search>
  14. </view>
  15. <view class="moreShelfPart-body">
  16. <scroll-view
  17. class="nav-right"
  18. scroll-y
  19. @scrolltolower="onreachBottom">
  20. <view class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id">
  21. <view class="item-info uni-col-10">
  22. <view class="item-name">
  23. <text>{{item.shelfName}}</text>
  24. </view>
  25. <view class="item-detail">
  26. <text class="item-detail-text">西安市未央区常青二路与贞观路交叉口向东100米</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view v-if="shelfList&&shelfList.length==0">
  31. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="240" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  32. </view>
  33. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  34. <u-loadmore :status="status" />
  35. </view>
  36. </scroll-view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { getShelfList } from '@/api/shelf'
  42. export default {
  43. data() {
  44. return {
  45. queryWord: '',
  46. isGobleSearch: false,
  47. shelfList: [],
  48. pageNo:1,
  49. pageSize: 10,
  50. total: 0, // 列表总数
  51. noDataText: '暂无货架',
  52. status: 'loading',
  53. vinstatus: 'loading'
  54. }
  55. },
  56. onLoad(opts) {
  57. this.getShelfList()
  58. },
  59. methods: {
  60. clearSearch(){
  61. this.queryWord = ''
  62. this.pageNo = 1
  63. this.shelfList = []
  64. },
  65. // 搜索配件
  66. searchPart(){
  67. if(this.queryWord != ''){
  68. this.clearSearch()
  69. this.getShelfList()
  70. }
  71. },
  72. // 获取数字货架列表
  73. getShelfList(){
  74. const _this = this
  75. let params = {
  76. pageNo: this.pageNo,
  77. pageSize: this.pageSize,
  78. queryWord: this.queryWord
  79. }
  80. _this.status = 'loading'
  81. getShelfList(params).then(res => {
  82. uni.hideLoading()
  83. if(res.status == 200){
  84. let list = res.data.list
  85. if (list && list.length){
  86. // 分页 拼接数据
  87. if (_this.pageNo != 1) {
  88. _this.shelfList = _this.shelfList ? _this.shelfList.concat(list) : list
  89. } else {
  90. _this.shelfList = list
  91. }
  92. this.total = res.data.count
  93. if (_this.shelfList.length == res.data.count) {
  94. _this.status = 'nomore'
  95. } else {
  96. _this.status = 'loadmore'
  97. }
  98. } else {
  99. _this.shelfList = list || []
  100. this.total = 0
  101. _this.status = 'nomore'
  102. }
  103. _this.noDataText = '暂无配件'
  104. }else{
  105. _this.status = 'loadmore'
  106. _this.shelfList = []
  107. _this.total = 0
  108. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  109. }
  110. })
  111. },
  112. // 加载更多
  113. onreachBottom () {
  114. if(this.shelfList.length < this.total ){
  115. if(this.isGobleSearch&&this.queryWord==''){
  116. return
  117. }
  118. this.pageNo++
  119. this.getShelfList()
  120. }else{
  121. this.status = "nomore"
  122. }
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="less">
  128. .moreShelfPart{
  129. width: 100%;
  130. height: 100vh;
  131. .moreShelfPart-search{
  132. padding: 20rpx;
  133. background-color: #FFFFFF;
  134. }
  135. .moreShelfPart-body{
  136. flex-grow: 1;
  137. background-color: #fff;
  138. }
  139. .nav-right{
  140. padding: 0 30upx;
  141. height: calc(100vh - 180rpx);
  142. box-sizing: border-box;
  143. .nav-right-item{
  144. padding:20upx 10upx;
  145. border-bottom: 2rpx solid #f5f5f5;
  146. display: flex;
  147. .item-info{
  148. .item-name{
  149. font-size: 36upx;
  150. display: flex;
  151. align-items: center;
  152. }
  153. .item-detail{
  154. margin-top: 10rpx;
  155. .item-detail-text{
  156. font-size: 30upx;
  157. color: #9DA8B5;
  158. word-break: break-all;
  159. }
  160. }
  161. }
  162. }
  163. }
  164. }
  165. </style>