queryByCode.vue 7.4 KB

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