queryByCode.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="search flex align_center">
  5. <view class="input">
  6. <u-search
  7. focus
  8. v-model="queryWord"
  9. @input="change"
  10. @custom="getpartList"
  11. @search="getpartList"
  12. @clear="clearSearch"
  13. :height="80"
  14. bg-color="#fff"
  15. :action-style="{border:'0.1rpx solid #00aaff',borderRadius:'50rpx',color:'#00aaff'}"
  16. placeholder="请输入产品编码或名称搜索"></u-search>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="check-list">
  21. <scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
  22. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  23. <view class="product flex align_center" @click="toEdit(item)">
  24. <view class="flex align_center flex_1">
  25. <view class="pimgs">
  26. <u-image :src="item.images?item.images:`/static/def_imgs.png`" width="128" height="128" border-radius="10"></u-image>
  27. </view>
  28. <view class="pinfo">
  29. <view class="pname">
  30. <text>{{item.shelfPlaceCode}}</text>{{item.code}}
  31. </view>
  32. <view class="ptxt flex align_center justify_between">
  33. <view>
  34. <text class="pcode">{{item.name}}</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view style="padding: 20upx;">
  42. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="partList.length==0 && status!='loading'" mode="list"></u-empty>
  43. <u-loadmore v-if="(total>=partList.length&&partList.length)||status=='loading'" :status="status" />
  44. </view>
  45. </scroll-view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import { getShelfProductList } from '@/api/shelf'
  51. export default {
  52. data() {
  53. return {
  54. queryWord: '',
  55. shelfName:'',
  56. shelfSn: '',
  57. pageNo:1,
  58. pageSize: 20,
  59. total: 0, // 列表总数
  60. noDataText: '暂无产品',
  61. status: 'nomore',
  62. partList: [],
  63. }
  64. },
  65. onLoad(opts) {
  66. this.shelfSn = this.$store.state.vuex_storeShelf.shelfSn
  67. },
  68. methods: {
  69. //取货
  70. toEdit(item){
  71. const params = Object.assign({shelfSn: this.shelfSn, billSource: 'product_code'},item)
  72. uni.navigateTo({
  73. url: '/pages/queryByCode/confirmQh?data='+ encodeURIComponent(JSON.stringify(params))
  74. })
  75. },
  76. clearSearch(){
  77. this.queryWord = ''
  78. this.pageNo = 1
  79. this.partList = []
  80. },
  81. change(v){
  82. if(v==''){
  83. this.clearSearch()
  84. }
  85. },
  86. // 获取数字货架列表
  87. getpartList(){
  88. const _this = this
  89. let params = {
  90. pageNo: this.pageNo,
  91. pageSize: this.pageSize,
  92. code: this.queryWord,
  93. }
  94. _this.status = 'loading'
  95. getShelfProductList(params).then(res => {
  96. uni.hideLoading()
  97. if(res.status == 200){
  98. let list = res.data.list
  99. console.log(list)
  100. if (list && list.length){
  101. // 分页 拼接数据
  102. if (_this.pageNo != 1) {
  103. _this.partList = _this.partList ? _this.partList.concat(list) : list
  104. } else {
  105. _this.partList = list
  106. }
  107. this.total = res.data.count
  108. if (_this.partList.length == res.data.count) {
  109. _this.status = 'nomore'
  110. } else {
  111. _this.status = 'loadmore'
  112. }
  113. } else {
  114. _this.partList = list || []
  115. this.total = 0
  116. _this.status = 'nomore'
  117. }
  118. _this.noDataText = '暂无匹配产品'
  119. }else{
  120. _this.status = 'loadmore'
  121. _this.partList = []
  122. _this.total = 0
  123. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  124. }
  125. this.showTab = false
  126. })
  127. },
  128. // 加载更多
  129. onreachBottom () {
  130. if(this.partList.length < this.total ){
  131. this.pageNo++
  132. this.getpartList()
  133. }else{
  134. this.status = "nomore"
  135. }
  136. },
  137. }
  138. }
  139. </script>
  140. <style lang="less">
  141. .content{
  142. height: 100vh;
  143. width: 100%;
  144. padding: 0 0.5rem;
  145. background: #fff;
  146. .searchBar{
  147. padding: 0 0.3rem;
  148. .search{
  149. padding: 0.5rem 0.5rem 0.3rem 0.5rem;
  150. .input{
  151. flex-grow: 1;
  152. border:0.1rpx solid #eee;
  153. padding: 0.1rpx;
  154. border-radius: 50rpx;
  155. padding-right: 10rpx;
  156. }
  157. }
  158. }
  159. .check-list{
  160. flex-grow: 1;
  161. .scroll-view{
  162. height: calc(100vh - 180rpx);
  163. box-sizing: border-box;
  164. }
  165. .partList-list-box{
  166. padding: 20rpx 30rpx;
  167. border-bottom: 2rpx solid #f5f5f5;
  168. &:last-child{
  169. border:0;
  170. }
  171. .product{
  172. flex-grow: 1;
  173. &:active{
  174. opacity: 0.6;
  175. background-color: #f8f8f8;
  176. }
  177. .pinfo{
  178. flex-grow: 1;
  179. padding-left: 20rpx;
  180. .pname{
  181. font-size: 28rpx;
  182. color: #191919;
  183. margin-bottom: 10rpx;
  184. text{
  185. font-weight: normal;
  186. margin-right: 6rpx;
  187. padding: 0 10rpx;
  188. background: rgba(3, 54, 146, 0.15);
  189. border-radius: 100rpx;
  190. color: #033692;
  191. font-size: 24rpx;
  192. }
  193. }
  194. .ptxt{
  195. font-size: 28rpx;
  196. color: #333;
  197. font-weight: bold;
  198. .pnums{
  199. color: #222;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. </style>