queryByCode.vue 7.5 KB

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