chooseProduct.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入货位号/产品编码/产品名称搜索"
  6. v-model="queryWord"
  7. :show-action="isGobleSearch"
  8. @focus="isGobleSearch=true"
  9. @blur="isGobleSearch=false"
  10. @custom="searchPart"
  11. @search="searchPart"
  12. @clear="clearSearch"
  13. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  14. </u-search>
  15. <view class="p-title">
  16. <text></text>
  17. {{shelfInfo.shelfName}}
  18. </view>
  19. </view>
  20. <view class="moreShelfPart-body">
  21. <scroll-view class="nav-right" scroll-y @scrolltolower="onreachBottom">
  22. <view class="partList-list-box" v-for="item in partList" :key="item.id">
  23. <view class="product flex align_center">
  24. <view class="flex align_center flex_1">
  25. <view class="pimgs">
  26. <u-image :src="item.shelfProductApiEntity&&item.shelfProductApiEntity.productMsg?item.shelfProductApiEntity.productMsg:`../../static/${theme}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  27. </view>
  28. <view class="pinfo">
  29. <view class="pname">
  30. <!-- <text class="pno">A10</text>
  31. 箭牌机油滤清器10款进口大众途锐 5.0L V10 TDI -->
  32. {{item.shelfProductApiEntity&&item.shelfProductApiEntity.productName}}
  33. </view>
  34. <view class="ptxt flex align_center justify_between">
  35. <view>
  36. <text class="pcode">{{item.shelfProductApiEntity&&item.shelfProductApiEntity.productCode}}</text>
  37. </view>
  38. <view>
  39. 库存数量:<text class="pnums">3个</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="ptools flex align_center justify_between">
  46. <view></view>
  47. <view class="print" @click="print(item)">
  48. <u-image :src="`/static/${$config('themePath')}/icon_printer@3x.png`" width="48" height="48"></u-image>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-if="partList&&partList.length==0">
  53. <u-empty v-if="status!='loading'" :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="240" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  54. </view>
  55. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  56. <u-loadmore :status="status" />
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import { shelfProductList } from '@/api/shelf'
  64. export default {
  65. data() {
  66. return {
  67. queryWord: '',
  68. isGobleSearch: false,
  69. partList: [],
  70. pageNo:1,
  71. pageSize: 10,
  72. total: 0, // 列表总数
  73. noDataText: '暂无货架',
  74. status: 'loading',
  75. vinstatus: 'loading',
  76. shelfInfo: {
  77. shelfSn: '',
  78. shelfName: ''
  79. },
  80. theme: '',
  81. }
  82. },
  83. onLoad(options) {
  84. this.theme = getApp().globalData.theme
  85. this.shelfInfo = {
  86. shelfSn: options.shelfSn,
  87. shelfName: options.shelfName
  88. }
  89. this.getpartList()
  90. },
  91. methods: {
  92. clearSearch(){
  93. this.queryWord = ''
  94. this.pageNo = 1
  95. this.partList = []
  96. this.getpartList()
  97. },
  98. // 搜索配件
  99. searchPart(){
  100. if(this.queryWord != ''){
  101. this.getpartList()
  102. }
  103. },
  104. // 获取数字货架列表
  105. getpartList(){
  106. const _this = this
  107. let params = {
  108. pageNo: this.pageNo,
  109. pageSize: this.pageSize,
  110. shelfSn: this.shelfInfo.shelfSn,
  111. queryWord: this.queryWord
  112. }
  113. _this.status = 'loading'
  114. shelfProductList(params).then(res => {
  115. uni.hideLoading()
  116. if(res.status == 200){
  117. let list = res.data.list
  118. if (list && list.length){
  119. // 分页 拼接数据
  120. if (_this.pageNo != 1) {
  121. _this.partList = _this.partList ? _this.partList.concat(list) : list
  122. } else {
  123. _this.partList = list
  124. }
  125. this.total = res.data.count
  126. if (_this.partList.length == res.data.count) {
  127. _this.status = 'nomore'
  128. } else {
  129. _this.status = 'loadmore'
  130. }
  131. } else {
  132. _this.partList = list || []
  133. this.total = 0
  134. _this.status = 'nomore'
  135. }
  136. _this.noDataText = '暂无配件'
  137. }else{
  138. _this.status = 'loadmore'
  139. _this.partList = []
  140. _this.total = 0
  141. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  142. }
  143. })
  144. },
  145. // 加载更多
  146. onreachBottom () {
  147. if(this.partList.length < this.total ){
  148. if(this.isGobleSearch&&this.queryWord==''){
  149. return
  150. }
  151. this.pageNo++
  152. this.getpartList()
  153. }else{
  154. this.status = "nomore"
  155. }
  156. },
  157. print(item){
  158. uni.navigateTo({
  159. url: "/pages/common/printTag/printTag?id="+item.id+"&from=bdtq"
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="less">
  166. .moreShelfPart{
  167. width: 100%;
  168. height: 100vh;
  169. .moreShelfPart-search{
  170. padding: 20rpx 20rpx 0;
  171. background-color: #FFFFFF;
  172. border-bottom: 2rpx solid #f5f5f5;
  173. }
  174. .p-title{
  175. padding: 20rpx;
  176. display: flex;
  177. align-items: center;
  178. color: #222;
  179. font-size: 32rpx;
  180. text{
  181. display: block;
  182. height: 32rpx;
  183. width: 6rpx;
  184. background: #0485F6;
  185. margin-right: 10rpx;
  186. border-radius: 10rpx;
  187. }
  188. }
  189. .moreShelfPart-body{
  190. flex-grow: 1;
  191. background-color: #fff;
  192. }
  193. .nav-right{
  194. padding: 0 30upx;
  195. height: calc(100vh - 180rpx);
  196. box-sizing: border-box;
  197. .partList-list-box{
  198. padding: 10px 0;
  199. border-bottom: 2rpx solid #f5f5f5;
  200. &:last-child{
  201. border:0;
  202. }
  203. .product{
  204. flex-grow: 1;
  205. .checkbox{
  206. width: 60rpx;
  207. }
  208. .pinfo{
  209. flex-grow: 1;
  210. padding-left: 20rpx;
  211. .pname{
  212. font-size: 32rpx;
  213. color: #191919;
  214. font-weight: bold;
  215. margin-bottom: 10rpx;
  216. }
  217. .pno{
  218. background-color: rgba(3, 54, 146, 0.15);
  219. border-radius: 50rpx;
  220. padding: 2rpx 20rpx;
  221. color: #033692;
  222. font-size: 24rpx;
  223. margin-right: 10rpx;
  224. }
  225. .ptxt{
  226. font-size: 28rpx;
  227. color: #999;
  228. .pnums{
  229. color: #222;
  230. }
  231. }
  232. }
  233. }
  234. .ptools{
  235. margin-top: 20rpx;
  236. .print{
  237. padding: 0 10rpx;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>