searchProduct.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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" :input-height="60" @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(e) {
  92. console.log(e,'-----------')
  93. uni.$emit("updateTempHw")
  94. uni.redirectTo({
  95. url: "/pages/batchShelves/cartList?shelfSn="+this.shelfSn+'&layer='+this.layer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  96. })
  97. return true
  98. },
  99. onNavigationBarButtonTap(e) {
  100. this.scanProduct()
  101. },
  102. methods: {
  103. scanProduct(){
  104. uni.redirectTo({
  105. url: "/pages/batchShelves/scanProduct?shelfSn="+this.shelfSn+'&layer='+this.layer+'&shelfName='+this.shelfName+'&customerSn='+this.customerSn
  106. })
  107. },
  108. clearSearch(){
  109. this.queryWord = ''
  110. this.productList = []
  111. this.getProductList()
  112. },
  113. getProductList(){
  114. const _this = this
  115. if(this.queryWord == ''){
  116. this.productList = []
  117. return
  118. }
  119. uni.showLoading({
  120. title: "正在查询..."
  121. })
  122. let params = {
  123. pageNo:1,
  124. pageSize:20,
  125. code: this.queryWord,
  126. shelfSn: this.shelfSn,
  127. shelfTierCode: this.layer
  128. }
  129. console.log(params)
  130. queryProductPage(params).then(res => {
  131. console.log(res)
  132. if(res.status == 200&&res.data&&res.data.page){
  133. this.productList = res.data.page.list
  134. this.shelfPlaceCode = res.data.shelfPlaceCode
  135. this.total = res.data.page.count
  136. }else{
  137. this.noDataText = '没有搜索到相关产品'
  138. }
  139. this.status = 'nomore'
  140. uni.hideLoading()
  141. })
  142. },
  143. // 新增
  144. addItem(item){
  145. this.saveData(item,1)
  146. },
  147. // 修改数量
  148. updateNums(e){
  149. console.log(e)
  150. const row = this.productList.find(item => item.id == e.index)
  151. const nums = e.value
  152. this.saveData(row,nums)
  153. },
  154. saveData(row,nums){
  155. // 继续修改数量
  156. uni.showLoading({
  157. title: '正在保存...'
  158. })
  159. const item = row.shelfCartApi || row.shelfProductApi
  160. const params = {
  161. shelfSn: this.shelfSn,
  162. shelfName: this.shelfName,
  163. shelfTierCode: item?item.shelfTierCode:this.layer,
  164. shelfPlaceSn: item?item.shelfPlaceSn:undefined,
  165. shelfPlaceCode: item?item.shelfPlaceCode:this.shelfPlaceCode,
  166. productSn: row.productSn,
  167. productCode: row.code,
  168. qty: nums,
  169. price: row.price,
  170. cost: row.cost,
  171. shelfCartSn: item?item.shelfCartSn:undefined
  172. }
  173. console.log(params)
  174. shelfCartSave(params).then(res => {
  175. if(res.status == 200){
  176. this.toashMsg(res.message)
  177. this.getProductList()
  178. }
  179. uni.hideLoading()
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="less">
  186. .productList{
  187. width: 100%;
  188. height: 100vh;
  189. .productList-search{
  190. padding: 20rpx 30rpx;
  191. background-color: #FFFFFF;
  192. .search{
  193. padding: 0.1rem;
  194. border-radius: 50rpx;
  195. border:0.1rpx solid #eee;
  196. .input{
  197. flex-grow: 1;
  198. padding: 0.1rpx;
  199. }
  200. .icon{
  201. width: 13%;
  202. text-align: center;
  203. font-size: 46rpx;
  204. color: #999;
  205. }
  206. }
  207. }
  208. .productList-body{
  209. flex-grow: 1;
  210. background-color: #fff;
  211. padding: 0 40upx;
  212. overflow: auto;
  213. .partList-list-box{
  214. padding: 10px 0;
  215. border-bottom: 2rpx solid #f5f5f5;
  216. .pinfo{
  217. flex-grow: 1;
  218. padding-left: 20rpx;
  219. .pname{
  220. color: #666;
  221. font-size: 26rpx;
  222. font-weight: bold;
  223. text{
  224. font-weight: normal;
  225. margin-right: 10rpx;
  226. padding: 0 10rpx;
  227. background: rgba(3, 54, 146, 0.15);
  228. border-radius: 30rpx;
  229. color: #033692;
  230. font-size: 26rpx;
  231. }
  232. }
  233. .ptxt{
  234. color: #666;
  235. font-size: 26rpx;
  236. padding: 10upx 0;
  237. }
  238. }
  239. .ptools{
  240. color: #666;
  241. font-size: 24rpx;
  242. .u-ninput{
  243. border: 2rpx solid #eee;
  244. border-radius: 50rpx;
  245. padding: 0 6rpx;
  246. }
  247. /deep/ .u-icon-disabled{
  248. background: #fff!important;
  249. }
  250. /deep/ .u-number-input{
  251. margin: 0 0;
  252. border: 2rpx solid #eee;
  253. border-top: 0;
  254. border-bottom: 0;
  255. }
  256. /deep/ .u-icon-plus, /deep/ .u-icon-minus{
  257. border-radius: 50rpx;
  258. }
  259. }
  260. }
  261. }
  262. }
  263. </style>