chooseProduct.vue 6.0 KB

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