searchProduct.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="productList flex flex_column">
  3. <view class="productList-search">
  4. <view class="search flex align_center">
  5. <view class="input">
  6. <u-search
  7. focus
  8. v-model="queryWord"
  9. @input="$u.debounce(getProductList, 800)"
  10. @custom="$u.debounce(getProductList, 500)"
  11. @search="$u.debounce(getProductList, 500)"
  12. @clear="clearSearch"
  13. bg-color="#fff"
  14. :show-action="false"
  15. placeholder="请输入产品编码查询"></u-search>
  16. </view>
  17. <!-- <view class="icon" @click="toScan">
  18. <u-icon name="scan"></u-icon>
  19. </view> -->
  20. </view>
  21. </view>
  22. <view class="productList-body">
  23. <view class="partList-list-box" v-for="item in productList" :key="item.shelfCartSn">
  24. <view class="flex align_center flex_1">
  25. <view class="pimgs">
  26. <u-image :src="item.images?item.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
  27. </view>
  28. <view class="pinfo">
  29. <view class="pname">
  30. <text v-if="item.shelfCartApi&&item.shelfCartApi.shelfPlaceCode">{{item.shelfCartApi.shelfPlaceCode}}</text>
  31. {{item.productName}}
  32. </view>
  33. <view class="ptxt flex justify_between">
  34. <text>{{item.code}}</text>
  35. <view v-if="item.shelfProductApi">
  36. 可用库存:<text>{{item.shelfProductApi.qty}}</text>{{item.unit}}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="ptools flex align_center justify_between">
  42. <view></view>
  43. <view class="pcurnums flex align_center">
  44. <view class="u-ninput" v-if="item.shelfCartApi">
  45. <u-number-box :index="item.id" @blur="updateNums" @minus="updateNums" @plus="updateNums" color="#000" bg-color="#fff" v-model="item.shelfCartApi.qty" :min="1"></u-number-box>
  46. </view>
  47. <view v-else>
  48. <u-button @click="addItem(item)" plain style="height: 50rpx;line-height: 50rpx;" size="mini" shape="circle">
  49. <u-icon name="plus"></u-icon> 添加
  50. </u-button>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view
  56. v-if="productList&&productList.length"
  57. style="color:#999;font-size: 26upx;text-align: center;padding: 20upx;">
  58. 最多显示前20条匹配产品,请尝试输入更多内容
  59. </view>
  60. <view v-if="productList && productList.length == 0">
  61. <u-empty :text="noDataText" mode="list" :img-width="200" :margin-top="60"></u-empty>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { queryProductPage, shelfCartSave } from '@/api/shelfCart'
  68. export default {
  69. data() {
  70. return {
  71. shelfSn: null,
  72. shelfName: '',
  73. layer:'',
  74. queryWord: '',
  75. productList: [],
  76. total: 0, // 列表总数
  77. noDataText: '暂无产品',
  78. status: 'nomore',
  79. shelfPlaceCode: ''
  80. }
  81. },
  82. onLoad(options) {
  83. this.shelfSn = options.shelfSn
  84. this.layer = options.layer
  85. this.shelfName = options.shelfName
  86. this.customerSn = options.customerSn
  87. uni.setNavigationBarTitle({
  88. title: '按产品编码搜索——' +this.layer+'层'
  89. })
  90. },
  91. onBackPress() {
  92. uni.$emit("updateTempHw")
  93. uni.redirectTo({
  94. url: "/pages/batchShelves/cartList?shelfSn="+this.shelfSn+'&layer='+this.layer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  95. })
  96. },
  97. onNavigationBarButtonTap(e) {
  98. this.scanProduct()
  99. },
  100. methods: {
  101. scanProduct(){
  102. uni.redirectTo({
  103. url: "/pages/batchShelves/scanProduct?shelfSn="+this.shelfSn+'&layer='+this.layer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  104. })
  105. },
  106. clearSearch(){
  107. this.queryWord = ''
  108. this.productList = []
  109. this.getProductList()
  110. },
  111. getProductList(){
  112. const _this = this
  113. if(this.queryWord == ''){
  114. this.productList = []
  115. return
  116. }
  117. uni.showLoading({
  118. title: "正在查询..."
  119. })
  120. let params = {
  121. pageNo:1,
  122. pageSize:20,
  123. code: this.queryWord,
  124. shelfSn: this.shelfSn,
  125. shelfTierCode: this.layer
  126. }
  127. console.log(params)
  128. queryProductPage(params).then(res => {
  129. console.log(res)
  130. if(res.status == 200&&res.data&&res.data.page){
  131. this.productList = res.data.page.list
  132. this.shelfPlaceCode = res.data.shelfPlaceCode
  133. this.total = res.data.page.count
  134. }else{
  135. this.noDataText = '没有搜索到相关产品'
  136. }
  137. this.status = 'nomore'
  138. uni.hideLoading()
  139. })
  140. },
  141. // 新增
  142. addItem(item){
  143. this.saveData(item,1)
  144. },
  145. // 修改数量
  146. updateNums(e){
  147. console.log(e)
  148. const row = this.productList.find(item => item.id == e.index)
  149. const nums = e.value
  150. this.saveData(row,nums)
  151. },
  152. saveData(row,nums){
  153. // 继续修改数量
  154. uni.showLoading({
  155. title: '正在保存...'
  156. })
  157. const item = row.shelfCartApi || row.shelfProductApi
  158. const params = {
  159. shelfSn: this.shelfSn,
  160. shelfName: this.shelfName,
  161. shelfTierCode: item?item.shelfTierCode:this.layer,
  162. shelfPlaceSn: item?item.shelfPlaceSn:undefined,
  163. shelfPlaceCode: item?item.shelfPlaceCode:this.shelfPlaceCode,
  164. productSn: row.productSn,
  165. productCode: row.code,
  166. qty: nums,
  167. price: row.price,
  168. cost: row.cost,
  169. shelfCartSn: item?item.shelfCartSn:undefined
  170. }
  171. console.log(params)
  172. shelfCartSave(params).then(res => {
  173. if(res.status == 200){
  174. this.toashMsg(res.message)
  175. this.getProductList()
  176. }
  177. uni.hideLoading()
  178. })
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="less">
  184. .productList{
  185. width: 100%;
  186. height: 100vh;
  187. .productList-search{
  188. padding: 20rpx 30rpx;
  189. background-color: #FFFFFF;
  190. .search{
  191. padding: 0.1rem;
  192. border-radius: 50rpx;
  193. border:0.1rpx solid #eee;
  194. .input{
  195. flex-grow: 1;
  196. padding: 0.1rpx;
  197. }
  198. .icon{
  199. width: 13%;
  200. text-align: center;
  201. font-size: 46rpx;
  202. color: #999;
  203. }
  204. }
  205. }
  206. .productList-body{
  207. flex-grow: 1;
  208. background-color: #fff;
  209. padding: 0 40upx;
  210. overflow: auto;
  211. .partList-list-box{
  212. padding: 10px 0;
  213. border-bottom: 2rpx solid #f5f5f5;
  214. .pinfo{
  215. flex-grow: 1;
  216. padding-left: 20rpx;
  217. .pname{
  218. color: #666;
  219. font-size: 26rpx;
  220. font-weight: bold;
  221. text{
  222. font-weight: normal;
  223. margin-right: 10rpx;
  224. padding: 0 10rpx;
  225. background: rgba(3, 54, 146, 0.15);
  226. border-radius: 30rpx;
  227. color: #033692;
  228. font-size: 26rpx;
  229. }
  230. }
  231. .ptxt{
  232. color: #666;
  233. font-size: 26rpx;
  234. padding: 10upx 0;
  235. }
  236. }
  237. .ptools{
  238. color: #666;
  239. font-size: 24rpx;
  240. .u-ninput{
  241. border: 2rpx solid #eee;
  242. border-radius: 50rpx;
  243. padding: 0 6rpx;
  244. }
  245. /deep/ .u-icon-disabled{
  246. background: #fff!important;
  247. }
  248. /deep/ .u-number-input{
  249. margin: 0 0;
  250. border: 2rpx solid #eee;
  251. border-top: 0;
  252. border-bottom: 0;
  253. }
  254. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  255. border-radius: 50rpx;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. </style>