chooseProduct.vue 6.2 KB

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