queryByCode.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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="90"
  14. bg-color="#fff"
  15. :action-style="{borderRadius:'50rpx',color:'#ffffff',width: '120rpx',padding:'12rpx 20rpx',background:'#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 class="code"><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. uni.$on("updateQueryByCodeList",()=>{
  69. this.getpartList()
  70. })
  71. },
  72. onUnload() {
  73. uni.$off("updateQueryByCodeList")
  74. },
  75. methods: {
  76. //取货
  77. toEdit(item){
  78. if(item.currentInven){
  79. const params = {shelfSn: this.shelfSn, billSource: 'product_code', productSn: item.productSn}
  80. uni.navigateTo({
  81. url: '/pages/queryByCode/confirmQh?data='+ encodeURIComponent(JSON.stringify(params))
  82. })
  83. }else{
  84. uni.showToast({
  85. icon:'none',
  86. title: '库存不足,不能取货!',
  87. duration: 4000
  88. })
  89. }
  90. },
  91. clearSearch(){
  92. this.queryWord = ''
  93. this.pageNo = 1
  94. this.partList = []
  95. this.getpartList()
  96. },
  97. change(v){
  98. if(v==''){
  99. this.clearSearch()
  100. }
  101. },
  102. // 获取数字货架列表
  103. getpartList(){
  104. const _this = this
  105. let params = {
  106. pageNo: this.pageNo,
  107. pageSize: this.pageSize,
  108. code: this.queryWord,
  109. }
  110. _this.status = 'loading'
  111. getShelfProductList(params).then(res => {
  112. uni.hideLoading()
  113. if(res.status == 200){
  114. let list = res.data.list
  115. console.log(list)
  116. if (list && list.length){
  117. // 分页 拼接数据
  118. if (_this.pageNo != 1) {
  119. _this.partList = _this.partList ? _this.partList.concat(list) : list
  120. } else {
  121. _this.partList = list
  122. }
  123. this.total = res.data.count
  124. if (_this.partList.length == res.data.count) {
  125. _this.status = 'nomore'
  126. } else {
  127. _this.status = 'loadmore'
  128. }
  129. } else {
  130. _this.partList = list || []
  131. this.total = 0
  132. _this.status = 'nomore'
  133. }
  134. _this.noDataText = '暂无匹配产品'
  135. }else{
  136. _this.status = 'loadmore'
  137. _this.partList = []
  138. _this.total = 0
  139. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  140. }
  141. this.showTab = false
  142. })
  143. },
  144. // 加载更多
  145. onreachBottom () {
  146. if(this.partList.length < this.total ){
  147. this.pageNo++
  148. this.getpartList()
  149. }else{
  150. this.status = "nomore"
  151. }
  152. },
  153. }
  154. }
  155. </script>
  156. <style lang="less">
  157. .content{
  158. height: 100vh;
  159. width: 100%;
  160. padding: 0 0.5rem;
  161. background: #fff;
  162. .searchBar{
  163. padding: 0 0.3rem;
  164. .search{
  165. padding: 0.5rem 0.5rem 0.3rem 0.5rem;
  166. .input{
  167. flex-grow: 1;
  168. border:0.1rpx solid #eee;
  169. padding: 0.1rpx;
  170. border-radius: 50rpx;
  171. padding-right: 10rpx;
  172. }
  173. }
  174. }
  175. .check-list{
  176. flex-grow: 1;
  177. .scroll-view{
  178. height: calc(100vh - 180rpx);
  179. box-sizing: border-box;
  180. }
  181. .partList-list-box{
  182. padding: 20rpx 30rpx;
  183. border-bottom: 2rpx solid #f5f5f5;
  184. &:last-child{
  185. border:0;
  186. }
  187. .product{
  188. flex-grow: 1;
  189. &:active{
  190. opacity: 0.6;
  191. background-color: #f8f8f8;
  192. }
  193. .pinfo{
  194. flex-grow: 1;
  195. padding-left: 20rpx;
  196. .pname{
  197. font-size: 28rpx;
  198. color: #191919;
  199. margin-bottom: 10rpx;
  200. .code{
  201. text{
  202. font-weight: normal;
  203. margin-right: 6rpx;
  204. padding: 0 10rpx;
  205. background: rgba(3, 54, 146, 0.15);
  206. border-radius: 20rpx;
  207. color: #033692;
  208. font-size: 24rpx;
  209. }
  210. }
  211. .kc{
  212. color: #999;
  213. text{
  214. color: #333;
  215. }
  216. }
  217. }
  218. .ptxt{
  219. font-size: 28rpx;
  220. color: #333;
  221. font-weight: bold;
  222. .pnums{
  223. color: #222;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. </style>