queryByCode.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 flex align_center justify_between">
  30. <view><text>{{item.shelfPlaceCode}}</text>{{item.code}}</view>
  31. <view class="kc">库存:<text>{{item.currentInven}}</text>{{item.unit}}</view>
  32. </view>
  33. <view class="ptxt">
  34. <view>
  35. <text class="pcode">{{item.name}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view style="padding: 20upx;">
  43. <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>
  44. <u-loadmore v-if="(total>=partList.length&&partList.length)||status=='loading'" :status="status" />
  45. </view>
  46. </scroll-view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import { getShelfProductList } from '@/api/shelf'
  52. export default {
  53. data() {
  54. return {
  55. queryWord: '',
  56. shelfName:'',
  57. shelfSn: '',
  58. pageNo:1,
  59. pageSize: 20,
  60. total: 0, // 列表总数
  61. noDataText: '暂无产品',
  62. status: 'nomore',
  63. partList: [],
  64. }
  65. },
  66. onLoad(opts) {
  67. this.shelfSn = this.$store.state.vuex_storeShelf.shelfSn
  68. },
  69. onShow() {
  70. if(this.queryWord!=''){
  71. this.getpartList()
  72. }
  73. },
  74. methods: {
  75. //取货
  76. toEdit(item){
  77. if(item.currentInven){
  78. const params = Object.assign({shelfSn: this.shelfSn, billSource: 'product_code'},item)
  79. uni.navigateTo({
  80. url: '/pages/queryByCode/confirmQh?data='+ encodeURIComponent(JSON.stringify(params))
  81. })
  82. }else{
  83. uni.showToast({
  84. icon:'none',
  85. title: '库存不足,不能取货!',
  86. duration: 4000
  87. })
  88. }
  89. },
  90. clearSearch(){
  91. this.queryWord = ''
  92. this.pageNo = 1
  93. this.partList = []
  94. },
  95. change(v){
  96. if(v==''){
  97. this.clearSearch()
  98. }
  99. },
  100. // 获取数字货架列表
  101. getpartList(){
  102. const _this = this
  103. let params = {
  104. pageNo: this.pageNo,
  105. pageSize: this.pageSize,
  106. code: this.queryWord,
  107. }
  108. _this.status = 'loading'
  109. getShelfProductList(params).then(res => {
  110. uni.hideLoading()
  111. if(res.status == 200){
  112. let list = res.data.list
  113. console.log(list)
  114. if (list && list.length){
  115. // 分页 拼接数据
  116. if (_this.pageNo != 1) {
  117. _this.partList = _this.partList ? _this.partList.concat(list) : list
  118. } else {
  119. _this.partList = list
  120. }
  121. this.total = res.data.count
  122. if (_this.partList.length == res.data.count) {
  123. _this.status = 'nomore'
  124. } else {
  125. _this.status = 'loadmore'
  126. }
  127. } else {
  128. _this.partList = list || []
  129. this.total = 0
  130. _this.status = 'nomore'
  131. }
  132. _this.noDataText = '暂无匹配产品'
  133. }else{
  134. _this.status = 'loadmore'
  135. _this.partList = []
  136. _this.total = 0
  137. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  138. }
  139. this.showTab = false
  140. })
  141. },
  142. // 加载更多
  143. onreachBottom () {
  144. if(this.partList.length < this.total ){
  145. this.pageNo++
  146. this.getpartList()
  147. }else{
  148. this.status = "nomore"
  149. }
  150. },
  151. }
  152. }
  153. </script>
  154. <style lang="less">
  155. .content{
  156. height: 100vh;
  157. width: 100%;
  158. padding: 0 0.5rem;
  159. background: #fff;
  160. .searchBar{
  161. padding: 0 0.3rem;
  162. .search{
  163. padding: 0.5rem 0.5rem 0.3rem 0.5rem;
  164. .input{
  165. flex-grow: 1;
  166. border:0.1rpx solid #eee;
  167. padding: 0.1rpx;
  168. border-radius: 50rpx;
  169. padding-right: 10rpx;
  170. }
  171. }
  172. }
  173. .check-list{
  174. flex-grow: 1;
  175. .scroll-view{
  176. height: calc(100vh - 180rpx);
  177. box-sizing: border-box;
  178. }
  179. .partList-list-box{
  180. padding: 20rpx 30rpx;
  181. border-bottom: 2rpx solid #f5f5f5;
  182. &:last-child{
  183. border:0;
  184. }
  185. .product{
  186. flex-grow: 1;
  187. &:active{
  188. opacity: 0.6;
  189. background-color: #f8f8f8;
  190. }
  191. .pinfo{
  192. flex-grow: 1;
  193. padding-left: 20rpx;
  194. .pname{
  195. font-size: 28rpx;
  196. color: #191919;
  197. margin-bottom: 10rpx;
  198. .kc{
  199. color: #999;
  200. text{
  201. color: #333;
  202. }
  203. }
  204. }
  205. .ptxt{
  206. font-size: 28rpx;
  207. color: #333;
  208. font-weight: bold;
  209. .pnums{
  210. color: #222;
  211. }
  212. }
  213. }
  214. }
  215. }
  216. }
  217. }
  218. </style>