shelfList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. <view class="nav-right">
  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. </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. }
  93. _this.status = 'loading'
  94. getShelfList(params).then(res => {
  95. if(res.status == 200){
  96. let list = res.data.list
  97. if (list && list.length){
  98. // 分页 拼接数据
  99. if(_this.pageNo>1){
  100. _this.shelfList = _this.shelfList.concat(res.data.list || [])
  101. }else{
  102. _this.shelfList = res.data.list
  103. }
  104. _this.total = res.data.count
  105. if (_this.shelfList.length == res.data.count) {//是否是最后一页
  106. _this.status = 'nomore'
  107. } else {
  108. _this.status = 'loadmore'
  109. }
  110. } else {
  111. _this.shelfList = list || []
  112. _this.total = 0
  113. _this.status = 'nomore'
  114. _this.noDataText = '没有查询到相关货架'
  115. }
  116. _this.noDataText = '暂无货架'
  117. }else{
  118. _this.status = 'loadmore'
  119. _this.shelfList = []
  120. _this.total = 0
  121. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  122. }
  123. })
  124. },
  125. viewDetail(item){
  126. uni.navigateTo({
  127. url:"/pages/vinAnalyse/shelfAnalyse?shelfSn="+item.shelfSn + '&shelfName='+item.shelfName
  128. })
  129. },
  130. },
  131. // 上拉加载更多
  132. onReachBottom () {
  133. if(this.shelfList.length < this.total ){
  134. if(this.isGobleSearch&&this.shelfName==''){
  135. return
  136. }
  137. this.pageNo++
  138. this.getShelfList()
  139. }else{
  140. this.status = "nomore"
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="less">
  146. .moreShelfPart{
  147. width: 100%;
  148. height: 100vh;
  149. background-color: #f8f8f8;
  150. .moreShelfPart-search{
  151. padding: 20rpx;
  152. }
  153. .moreShelfPart-body{
  154. flex-grow: 1;
  155. }
  156. .nav-right{
  157. padding: 0 30upx;
  158. box-sizing: border-box;
  159. overflow: auto;
  160. .nav-right-item{
  161. padding:20upx;
  162. border: 2rpx solid #f5f5f5;
  163. border-radius: 15upx;
  164. margin-bottom: 20upx;
  165. box-shadow: 3rpx 3rpx 8rpx #eee;
  166. background-color: #ffff;
  167. &:active{
  168. background: #f8f8f8;
  169. }
  170. .item-info{
  171. .item-name{
  172. font-size: 30upx;
  173. display: flex;
  174. align-items: center;
  175. }
  176. .item-detail{
  177. margin-top: 15rpx;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. color: #9DA8B5;
  182. font-size: 26upx;
  183. .item-detail-text{
  184. font-size: 26upx;
  185. color: #333;
  186. }
  187. }
  188. }
  189. .button-box{
  190. display: flex;
  191. margin-top: 20upx;
  192. button{
  193. margin: 0 10upx;
  194. }
  195. > text{
  196. font-size: 24upx;
  197. color: #00aaff;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. </style>