chooseProduct.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. if(this.queryWord != ''){
  99. this.getpartList()
  100. }
  101. },
  102. // 获取数字货架列表
  103. getpartList(){
  104. const _this = this
  105. let params = {
  106. pageNo: this.pageNo,
  107. pageSize: this.pageSize,
  108. shelfSn: this.shelfInfo.shelfSn,
  109. queryWord: this.queryWord
  110. }
  111. _this.status = 'loading'
  112. getShelfProductList(params).then(res => {
  113. uni.hideLoading()
  114. if(res.status == 200){
  115. let list = res.data.list
  116. console.log(list)
  117. if (list && list.length){
  118. // 分页 拼接数据
  119. if (_this.pageNo != 1) {
  120. _this.partList = _this.partList ? _this.partList.concat(list) : list
  121. } else {
  122. _this.partList = list
  123. }
  124. this.total = res.data.count
  125. if (_this.partList.length == res.data.count) {
  126. _this.status = 'nomore'
  127. } else {
  128. _this.status = 'loadmore'
  129. }
  130. } else {
  131. _this.partList = list || []
  132. this.total = 0
  133. _this.status = 'nomore'
  134. }
  135. _this.noDataText = '暂无配件'
  136. }else{
  137. _this.status = 'loadmore'
  138. _this.partList = []
  139. _this.total = 0
  140. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  141. }
  142. })
  143. },
  144. // 加载更多
  145. onreachBottom () {
  146. if(this.partList.length < this.total ){
  147. if(this.isGobleSearch&&this.queryWord==''){
  148. return
  149. }
  150. this.pageNo++
  151. this.getpartList()
  152. }else{
  153. this.status = "nomore"
  154. }
  155. },
  156. print(data){
  157. uni.navigateTo({ url: "/pages/common/printTag/printTag?page=bdtq&data="+JSON.stringify(data) })
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="less">
  163. .moreShelfPart{
  164. width: 100%;
  165. height: 100vh;
  166. .moreShelfPart-search{
  167. padding: 20rpx 20rpx 0;
  168. background-color: #FFFFFF;
  169. border-bottom: 2rpx solid #f5f5f5;
  170. }
  171. .p-title{
  172. padding: 20rpx;
  173. display: flex;
  174. align-items: center;
  175. color: #222;
  176. font-size: 32rpx;
  177. text{
  178. display: block;
  179. height: 32rpx;
  180. width: 6rpx;
  181. background: #0485F6;
  182. margin-right: 10rpx;
  183. border-radius: 10rpx;
  184. }
  185. }
  186. .moreShelfPart-body{
  187. flex-grow: 1;
  188. background-color: #fff;
  189. }
  190. .nav-right{
  191. padding: 0 30upx;
  192. height: calc(100vh - 180rpx);
  193. box-sizing: border-box;
  194. .partList-list-box{
  195. padding: 10px 0;
  196. border-bottom: 2rpx solid #f5f5f5;
  197. &:last-child{
  198. border:0;
  199. }
  200. .product{
  201. flex-grow: 1;
  202. .checkbox{
  203. width: 60rpx;
  204. }
  205. .pinfo{
  206. flex-grow: 1;
  207. padding-left: 20rpx;
  208. .pname{
  209. font-size: 32rpx;
  210. color: #191919;
  211. font-weight: bold;
  212. margin-bottom: 10rpx;
  213. text{
  214. font-weight: normal;
  215. margin-right: 6rpx;
  216. padding: 0 10rpx;
  217. background: rgba(3, 54, 146, 0.15);
  218. border-radius: 100rpx;
  219. color: #033692;
  220. font-size: 28rpx;
  221. }
  222. }
  223. .pno{
  224. background-color: rgba(3, 54, 146, 0.15);
  225. border-radius: 50rpx;
  226. padding: 2rpx 20rpx;
  227. color: #033692;
  228. font-size: 24rpx;
  229. margin-right: 10rpx;
  230. }
  231. .ptxt{
  232. font-size: 28rpx;
  233. color: #999;
  234. .pnums{
  235. color: #222;
  236. }
  237. }
  238. }
  239. }
  240. .ptools{
  241. margin-top: 20rpx;
  242. .print{
  243. padding: 0 10rpx;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. </style>