shelfList.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 class="nav-right-item" v-for="(item, index) in shelfList" :key="item.id" @click="viewDetail(item)">
  20. <view class="item-info">
  21. <view class="item-name clearFix">
  22. <text class="barBox"></text>
  23. <text class="itemName">{{ item.shelfName }}</text>
  24. </view>
  25. <view class="item-detail">
  26. <view>
  27. 产品款数:
  28. <text class="item-detail-text">{{ item.shelfPlaceBindNum || 0 }}</text>
  29. </view>
  30. <view>
  31. 库存总量:
  32. <text class="item-detail-text">{{ item.qty || 0 }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="shelfList && shelfList.length == 0">
  38. <u-empty
  39. v-if="status != 'loading'"
  40. :src="`/static/${$config('themePath')}/def_no_data@3x.png`"
  41. icon-size="180"
  42. :text="noDataText"
  43. mode="list"
  44. :margin-top="100"
  45. ></u-empty>
  46. </view>
  47. <view style="padding: 20upx;" v-if="shelfList.length"><u-loadmore :status="status" /></view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { getShelfList } from '@/api/shelf';
  54. import { clzConfirm } from '@/libs/tools';
  55. export default {
  56. data() {
  57. return {
  58. shelfName: '',
  59. isGobleSearch: false,
  60. shelfList: [],
  61. noDataText: '暂无货架',
  62. status: 'loading',
  63. tempData: null,
  64. pageNo: 1,
  65. pageSize: 20
  66. };
  67. },
  68. onLoad() {
  69. this.getShelfList();
  70. uni.setNavigationBarColor({
  71. frontColor: '#ffffff',
  72. backgroundColor: this.$config('primaryColor')
  73. })
  74. },
  75. methods: {
  76. clearSearch() {
  77. this.pageNo = 1;
  78. this.shelfName = '';
  79. this.shelfList = [];
  80. this.$nextTick(() => {
  81. this.getShelfList();
  82. });
  83. },
  84. change(v) {
  85. if (v == '') {
  86. this.clearSearch();
  87. }else{
  88. this.pageNo = 1;
  89. }
  90. },
  91. // 获取数字货架列表
  92. getShelfList() {
  93. const _this = this;
  94. let params = {
  95. pageNo: _this.pageNo,
  96. pageSize: _this.pageSize,
  97. shelfName: _this.shelfName
  98. };
  99. _this.status = 'loading';
  100. getShelfList(params).then(res => {
  101. if (res.status == 200) {
  102. let list = res.data.list;
  103. if (list && list.length) {
  104. // 分页 拼接数据
  105. if (_this.pageNo > 1) {
  106. _this.shelfList = _this.shelfList.concat(res.data.list || []);
  107. } else {
  108. _this.shelfList = res.data.list;
  109. }
  110. _this.total = res.data.count;
  111. if (_this.shelfList.length == res.data.count) {
  112. //是否是最后一页
  113. _this.status = 'nomore';
  114. } else {
  115. _this.status = 'loadmore';
  116. }
  117. } else {
  118. _this.shelfList = list || [];
  119. _this.total = 0;
  120. _this.status = 'nomore';
  121. _this.noDataText = '没有查询到相关货架';
  122. }
  123. _this.noDataText = '暂无货架';
  124. } else {
  125. _this.status = 'loadmore';
  126. _this.shelfList = [];
  127. _this.total = 0;
  128. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试';
  129. }
  130. });
  131. },
  132. viewDetail(item) {
  133. let nowData={
  134. shelfSn:item.shelfSn,
  135. shelfName:item.shelfName
  136. }
  137. uni.navigateTo({
  138. url: "/pages/shuntBackManage/chooseProduct?data="+encodeURIComponent(JSON.stringify(nowData))
  139. })
  140. }
  141. },
  142. // 上拉加载更多
  143. onReachBottom() {
  144. if (this.shelfList.length < this.total) {
  145. // if (this.isGobleSearch && this.shelfName == '') {
  146. // return;
  147. // }
  148. this.pageNo++;
  149. this.getShelfList();
  150. } else {
  151. this.status = 'nomore';
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="less">
  157. .moreShelfPart {
  158. width: 100%;
  159. height: 100vh;
  160. background-color: #f8f8f8;
  161. .moreShelfPart-search {
  162. padding: 20rpx;
  163. }
  164. .moreShelfPart-body {
  165. flex-grow: 1;
  166. }
  167. .nav-right {
  168. padding: 0 30upx;
  169. box-sizing: border-box;
  170. overflow: auto;
  171. .nav-right-item {
  172. padding: 20upx;
  173. border: 2rpx solid #f5f5f5;
  174. border-radius: 15upx;
  175. margin-bottom: 20upx;
  176. box-shadow: 3rpx 3rpx 8rpx #eee;
  177. background-color: #ffff;
  178. &:active {
  179. background: #f8f8f8;
  180. }
  181. .item-info {
  182. .item-name {
  183. font-size: 30upx;
  184. vertical-align: middle;
  185. .barBox {
  186. display: block;
  187. height: 30rpx;
  188. width: 6rpx;
  189. background: #9da8b5;
  190. margin-right: 10rpx;
  191. border-radius: 10rpx;
  192. float: left;
  193. margin-top: 9rpx;
  194. }
  195. .itemName {
  196. vertical-align: top;
  197. }
  198. }
  199. .clearFix::after {
  200. clear: both;
  201. content: '';
  202. display: block;
  203. visibility: hidden;
  204. }
  205. .item-detail {
  206. margin-top: 15rpx;
  207. display: flex;
  208. align-items: center;
  209. color: #9da8b5;
  210. font-size: 26upx;
  211. :nth-child(1) {
  212. margin-right: 50rpx;
  213. }
  214. .item-detail-text {
  215. font-size: 26upx;
  216. color: #333;
  217. }
  218. }
  219. }
  220. .button-box {
  221. display: flex;
  222. margin-top: 20upx;
  223. button {
  224. margin: 0 10upx;
  225. }
  226. > text {
  227. font-size: 24upx;
  228. color: #00aaff;
  229. }
  230. }
  231. }
  232. }
  233. }
  234. </style>