queryByCode.vue 5.5 KB

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