queryByCode.vue 7.0 KB

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