searchProduct.vue 7.3 KB

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