shelfList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货架名称搜索"
  6. v-model="shelfName"
  7. :show-action="isGobleSearch"
  8. @focus="isGobleSearch=true"
  9. @blur="isGobleSearch=false"
  10. @custom="getShelfList"
  11. @search="getShelfList"
  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">
  23. <view class="item-name">
  24. <text>{{item.shelfName}}</text>
  25. </view>
  26. <view class="item-detail">
  27. <text class="item-detail-text">
  28. 货位数量:3
  29. </text>
  30. <text class="item-detail-text">
  31. 已绑定产品款数:3
  32. </text>
  33. <text class="item-detail-text">
  34. 设置完成:是
  35. </text>
  36. </view>
  37. </view>
  38. <view class="arrow">
  39. <u-icon name="arrow-right" color="#969da3" size="28"></u-icon>
  40. </view>
  41. </view>
  42. <view v-if="shelfList&&shelfList.length==0">
  43. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  44. </view>
  45. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  46. <u-loadmore :status="status" />
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { getShelfList } from '@/api/shelf'
  54. export default {
  55. data() {
  56. return {
  57. shelfName: '',
  58. isGobleSearch: false,
  59. shelfList: [],
  60. pageNo:1,
  61. pageSize: 10,
  62. total: 0, // 列表总数
  63. noDataText: '暂无货架',
  64. status: 'loading',
  65. vinstatus: 'loading'
  66. }
  67. },
  68. onLoad(opts) {
  69. this.getShelfList()
  70. },
  71. methods: {
  72. clearSearch(){
  73. this.shelfName = ''
  74. this.pageNo = 1
  75. this.shelfList = []
  76. this.getShelfList()
  77. },
  78. // 获取数字货架列表
  79. getShelfList(){
  80. const _this = this
  81. let params = {
  82. pageNo: this.pageNo,
  83. pageSize: this.pageSize,
  84. shelfName: this.shelfName
  85. }
  86. _this.status = 'loading'
  87. getShelfList(params).then(res => {
  88. uni.hideLoading()
  89. if(res.status == 200){
  90. let list = res.data.list
  91. if (list && list.length){
  92. // 分页 拼接数据
  93. if (_this.pageNo != 1) {
  94. _this.shelfList = _this.shelfList ? _this.shelfList.concat(list) : list
  95. } else {
  96. _this.shelfList = list
  97. }
  98. this.total = res.data.count
  99. if (_this.shelfList.length == res.data.count) {
  100. _this.status = 'nomore'
  101. } else {
  102. _this.status = 'loadmore'
  103. }
  104. } else {
  105. _this.shelfList = list || []
  106. this.total = 0
  107. _this.status = 'nomore'
  108. _this.noDataText = '没有查询到相关货架'
  109. }
  110. }else{
  111. _this.status = 'loadmore'
  112. _this.shelfList = []
  113. _this.total = 0
  114. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  115. }
  116. })
  117. },
  118. // 加载更多
  119. onreachBottom () {
  120. if(this.shelfList.length < this.total ){
  121. if(this.isGobleSearch&&this.shelfName==''){
  122. return
  123. }
  124. this.pageNo++
  125. this.getShelfList()
  126. }else{
  127. this.status = "nomore"
  128. }
  129. },
  130. viewDetail(item){
  131. uni.navigateTo({
  132. url: "/pages/latePlay/chooseProduct?shelfSn="+item.shelfSn+'&shelfName='+item.shelfName
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="less">
  139. .moreShelfPart{
  140. width: 100%;
  141. height: 100vh;
  142. .moreShelfPart-search{
  143. padding: 20rpx;
  144. background-color: #FFFFFF;
  145. }
  146. .moreShelfPart-body{
  147. flex-grow: 1;
  148. background-color: #fff;
  149. }
  150. .nav-right{
  151. padding: 0 30upx;
  152. height: calc(100vh - 110rpx);
  153. box-sizing: border-box;
  154. .nav-right-item{
  155. padding:20upx 10upx;
  156. border-bottom: 2rpx solid #f5f5f5;
  157. display: flex;
  158. align-items: center;
  159. &:active{
  160. background: #f8f8f8;
  161. }
  162. .arrow{
  163. text-align: right;
  164. padding-left: 20rpx;
  165. }
  166. .item-info{
  167. flex:1;
  168. .item-name{
  169. font-size: 30upx;
  170. display: flex;
  171. align-items: center;
  172. }
  173. .item-detail{
  174. margin-top: 10rpx;
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .item-detail-text{
  179. font-size: 26upx;
  180. color: #9DA8B5;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. </style>