queryByCode.vue 7.5 KB

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