searchProduct.vue 7.0 KB

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