shelfList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search ref="searchBox"
  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. onReady() {
  69. uni.setNavigationBarColor({
  70. frontColor: '#ffffff',
  71. backgroundColor: this.$config('primaryColor')
  72. })
  73. },
  74. onLoad() {
  75. this.getShelfList();
  76. },
  77. methods: {
  78. clearSearch() {
  79. this.pageNo = 1;
  80. this.shelfName = '';
  81. this.shelfList = [];
  82. this.$nextTick(() => {
  83. this.getShelfList();
  84. });
  85. },
  86. change(v) {
  87. if (v == '') {
  88. this.clearSearch();
  89. }else{
  90. this.pageNo = 1;
  91. }
  92. },
  93. // 获取数字货架列表
  94. getShelfList() {
  95. const _this = this;
  96. let params = {
  97. pageNo: _this.pageNo,
  98. pageSize: _this.pageSize,
  99. shelfName: _this.shelfName
  100. };
  101. _this.status = 'loading';
  102. getShelfList(params).then(res => {
  103. if (res.status == 200) {
  104. let list = res.data.list;
  105. if (list && list.length) {
  106. // 分页 拼接数据
  107. if (_this.pageNo > 1) {
  108. _this.shelfList = _this.shelfList.concat(res.data.list || []);
  109. } else {
  110. _this.shelfList = res.data.list;
  111. }
  112. _this.total = res.data.count;
  113. if (_this.shelfList.length == res.data.count) {
  114. //是否是最后一页
  115. _this.status = 'nomore';
  116. } else {
  117. _this.status = 'loadmore';
  118. }
  119. } else {
  120. _this.shelfList = list || [];
  121. _this.total = 0;
  122. _this.status = 'nomore';
  123. _this.noDataText = '没有查询到相关货架';
  124. }
  125. _this.noDataText = '暂无货架';
  126. } else {
  127. _this.status = 'loadmore';
  128. _this.shelfList = [];
  129. _this.total = 0;
  130. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试';
  131. }
  132. });
  133. },
  134. viewDetail(item) {
  135. let nowData={
  136. shelfSn:item.shelfSn,
  137. shelfName:item.shelfName
  138. }
  139. uni.navigateTo({
  140. url: "/pages/shuntBackManage/chooseProduct?data="+encodeURIComponent(JSON.stringify(nowData))
  141. })
  142. }
  143. },
  144. onHide() {
  145. this.$nextTick(()=>{
  146. this.$refs.searchBox.blur();
  147. this.isGobleSearch=false
  148. uni.hideKeyboard()
  149. })
  150. },
  151. // 上拉加载更多
  152. onReachBottom() {
  153. if (this.shelfList.length < this.total) {
  154. // if (this.isGobleSearch && this.shelfName == '') {
  155. // return;
  156. // }
  157. this.pageNo++;
  158. this.getShelfList();
  159. } else {
  160. this.status = 'nomore';
  161. }
  162. }
  163. };
  164. </script>
  165. <style lang="less">
  166. .moreShelfPart {
  167. width: 100%;
  168. height: 100vh;
  169. background-color: #f8f8f8;
  170. .moreShelfPart-search {
  171. padding: 20rpx;
  172. }
  173. .moreShelfPart-body {
  174. flex-grow: 1;
  175. }
  176. .nav-right {
  177. padding: 0 30upx;
  178. box-sizing: border-box;
  179. overflow: auto;
  180. .nav-right-item {
  181. padding: 20upx;
  182. border: 2rpx solid #f5f5f5;
  183. border-radius: 15upx;
  184. margin-bottom: 20upx;
  185. box-shadow: 3rpx 3rpx 8rpx #eee;
  186. background-color: #ffff;
  187. &:active {
  188. background: #f8f8f8;
  189. }
  190. .item-info {
  191. .item-name {
  192. font-size: 30upx;
  193. vertical-align: middle;
  194. .barBox {
  195. display: block;
  196. height: 30rpx;
  197. width: 6rpx;
  198. background: #9da8b5;
  199. margin-right: 10rpx;
  200. border-radius: 10rpx;
  201. float: left;
  202. margin-top: 9rpx;
  203. }
  204. .itemName {
  205. vertical-align: top;
  206. }
  207. }
  208. .clearFix::after {
  209. clear: both;
  210. content: '';
  211. display: block;
  212. visibility: hidden;
  213. }
  214. .item-detail {
  215. margin-top: 15rpx;
  216. display: flex;
  217. align-items: center;
  218. color: #9da8b5;
  219. font-size: 26upx;
  220. :nth-child(1) {
  221. margin-right: 50rpx;
  222. }
  223. .item-detail-text {
  224. font-size: 26upx;
  225. color: #333;
  226. }
  227. }
  228. }
  229. .button-box {
  230. display: flex;
  231. margin-top: 20upx;
  232. button {
  233. margin: 0 10upx;
  234. }
  235. > text {
  236. font-size: 24upx;
  237. color: #00aaff;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>