searchProduct.vue 7.3 KB

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