shelfList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. @input="change"
  9. @focus="isGobleSearch=true"
  10. @blur="isGobleSearch=false"
  11. @custom="getShelfList"
  12. @search="getShelfList"
  13. @clear="clearSearch"
  14. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  15. </u-search>
  16. </view>
  17. <view class="moreShelfPart-body">
  18. <scroll-view class="nav-right" scroll-y @scrolltolower="onReachBottom">
  19. <view
  20. class="nav-right-item"
  21. v-for="(item, index) in shelfList"
  22. :key="item.id"
  23. @click="viewDetail(item)"
  24. >
  25. <view class="item-info">
  26. <view class="item-name">
  27. <text>{{item.shelfName}}</text>
  28. </view>
  29. <view class="item-detail">
  30. <view>
  31. 累计扫描VIN数量:
  32. <text class="item-detail-text">{{item.scanVinCount || 0}}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="shelfList&&shelfList.length==0">
  38. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" :text="noDataText" mode="list" :margin-top="100"></u-empty>
  39. </view>
  40. <view style="padding: 20upx;" v-if="shelfList.length">
  41. <u-loadmore :status="status" />
  42. </view>
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. import { getShelfList } from '@/api/shelf'
  49. import { clzConfirm } from '@/libs/tools'
  50. export default {
  51. data() {
  52. return {
  53. shelfName: '',
  54. isGobleSearch: false,
  55. shelfList: [],
  56. noDataText: '暂无货架',
  57. status: 'loading',
  58. tempData: null,
  59. pageNo:1,
  60. pageSize:20
  61. }
  62. },
  63. onLoad() {
  64. this.getShelfList()
  65. uni.setNavigationBarColor({
  66. frontColor: '#ffffff',
  67. backgroundColor: this.$config('primaryColor')
  68. })
  69. },
  70. methods: {
  71. clearSearch(){
  72. this.shelfName = ''
  73. this.shelfList = []
  74. this.getShelfList()
  75. },
  76. change(v){
  77. if(v==''){
  78. this.clearSearch()
  79. }
  80. },
  81. // 获取数字货架列表
  82. getShelfList(){
  83. const _this = this
  84. // if(this.shelfName == ''){
  85. // this.pageNo = 1
  86. // this.total = 0
  87. // }
  88. let params = {
  89. pageNo: _this.pageNo,
  90. pageSize: _this.pageSize,
  91. shelfName: _this.shelfName,
  92. stateSet: [ 'ENABLE', 'SUSPEND', 'DISABLED' ]
  93. }
  94. _this.status = 'loading'
  95. getShelfList(params).then(res => {
  96. if(res.status == 200){
  97. let list = res.data.list
  98. if (list && list.length){
  99. // 分页 拼接数据
  100. if(_this.pageNo>1){
  101. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  102. }else{
  103. _this.shelfList = res.data.list
  104. }
  105. _this.total = res.data.count
  106. if (_this.shelfList.length == res.data.count) {//是否是最后一页
  107. _this.status = 'nomore'
  108. } else {
  109. _this.status = 'loadmore'
  110. }
  111. } else {
  112. _this.shelfList = list || []
  113. _this.total = 0
  114. _this.status = 'nomore'
  115. _this.noDataText = '没有查询到相关货架'
  116. }
  117. _this.noDataText = '暂无货架'
  118. }else{
  119. _this.status = 'loadmore'
  120. _this.shelfList = []
  121. _this.total = 0
  122. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  123. }
  124. })
  125. },
  126. viewDetail(item){
  127. uni.navigateTo({
  128. url:"/pages/vinAnalyse/shelfAnalyse?shelfSn="+item.shelfSn + '&shelfName='+item.shelfName
  129. })
  130. },
  131. },
  132. // 上拉加载更多
  133. onReachBottom () {
  134. if(this.shelfList.length < this.total ){
  135. if(this.isGobleSearch&&this.shelfName==''){
  136. return
  137. }
  138. this.pageNo++
  139. this.getShelfList()
  140. }else{
  141. this.status = "nomore"
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="less">
  147. .moreShelfPart{
  148. width: 100%;
  149. height: 100vh;
  150. background-color: #f8f8f8;
  151. .moreShelfPart-search{
  152. padding: 20rpx;
  153. }
  154. .moreShelfPart-body{
  155. flex-grow: 1;
  156. }
  157. .nav-right{
  158. padding: 0 30upx;
  159. box-sizing: border-box;
  160. height: calc(100vh - 100rpx);
  161. .nav-right-item{
  162. padding:20upx;
  163. border: 2rpx solid #f5f5f5;
  164. border-radius: 15upx;
  165. margin-bottom: 20upx;
  166. box-shadow: 3rpx 3rpx 8rpx #eee;
  167. background-color: #ffff;
  168. &:active{
  169. background: #f8f8f8;
  170. }
  171. .item-info{
  172. .item-name{
  173. font-size: 30upx;
  174. display: flex;
  175. align-items: center;
  176. }
  177. .item-detail{
  178. margin-top: 15rpx;
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-between;
  182. color: #9DA8B5;
  183. font-size: 26upx;
  184. .item-detail-text{
  185. font-size: 26upx;
  186. color: #333;
  187. }
  188. }
  189. }
  190. .button-box{
  191. display: flex;
  192. margin-top: 20upx;
  193. button{
  194. margin: 0 10upx;
  195. }
  196. > text{
  197. font-size: 24upx;
  198. color: #00aaff;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. </style>