chooseBulk.vue 4.2 KB

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