queryByCode.vue 6.1 KB

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