goods.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='添加商品'></cus-header>
  4. <div class="goods" v-if="list.length">
  5. <div class="good" v-for="(good,index) in list" :key="good.skuId">
  6. <div class="check" @click="changeCheck(index)">
  7. <image :src="imgBase+'storage/icon_notchecked_grey.png'" v-if="!good.checked"></image>
  8. <image :src="imgBase+'storage/icon_checked_blue.png'" v-else></image>
  9. </div>
  10. <div class="info">
  11. <div class="name">{{good.item.itemName}}</div>
  12. <div class="ggxx">
  13. 规格信息:<span>{{good.itemSku.skuName||''}} / {{good.itemSku.grossWeight||0}}kg / {{good.itemSku.width||0}}X{{good.itemSku.height||0}}cm</span>
  14. </div>
  15. <div class="ggxx">
  16. 库存:<span>{{good.quantity||''}}</span>
  17. </div>
  18. <!-- <div class="price">
  19. <div class="left">成本价:<span>¥{{good.itemSku.costPrice||0}}</span></div>
  20. <div class="right">
  21. <u-number-box v-model="good.checknum" button-size="48" :integer="true" inputWidth="102rpx"
  22. @change="e=>changeNum(e,index)" bgColor="#F5F8FA"></u-number-box>
  23. </div>
  24. </div> -->
  25. </div>
  26. </div>
  27. </div>
  28. <template v-else>
  29. <page-empty :height="'calc(100vh - 100px)'"></page-empty>
  30. </template>
  31. <div class="btn">
  32. <div class="left">
  33. <image :src="imgBase+'storage/icon_checked_blue.png'"></image>
  34. <text>已选:{{selectNum||0}}</text>
  35. </div>
  36. <div class="confirm" @tap="confirmSelect">确定</div>
  37. </div>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data(){
  43. return {
  44. list:[],
  45. isOver:false,
  46. params:{
  47. page:1,
  48. limit:10,
  49. minQuantity:1,
  50. warehouseId:''
  51. },
  52. selectNum:0,
  53. ids:[]
  54. }
  55. },
  56. onReachBottom() {
  57. if(this.isOver) return
  58. this.getList();
  59. },
  60. onPullDownRefresh() {
  61. this.params.page = 1;
  62. this.isOver = false;
  63. this.list = [];
  64. this.getList();
  65. },
  66. watch:{
  67. list:{
  68. handler(newValue){
  69. this.selectNum = this.list.filter(l=>l.checked).length;
  70. },
  71. deep:true,
  72. immediate:true
  73. }
  74. },
  75. onLoad(option) {
  76. let ids = option.ids;
  77. if(ids.indexOf(',')>-1) ids = ids.split(',');
  78. else ids = [ids];
  79. this.ids = ids;
  80. this.getList();
  81. },
  82. methods:{
  83. async getList(){
  84. let res = await this.$api.get('/wms/inventory/boardList/warehouse',this.params);
  85. if(res.data.code===0){
  86. if(this.list.length<res.data.data.total){
  87. this.params.page++;
  88. this.list = [...this.list,...res.data.data.list];
  89. this.list.forEach((d,i)=>{
  90. this.$set(this.list[i],'checked',this.ids.includes(d.skuId)?true:false);
  91. this.$set(this.list[i],'checknum',1);
  92. })
  93. }else this.isOver = true
  94. }else this.$showModal(res.msg)
  95. },
  96. changeCheck(index){
  97. this.$set(this.list[index],'checked',!this.list[index].checked);
  98. },
  99. changeNum(e,index){
  100. this.$set(this.list[index],'checknum',e.value);
  101. },
  102. confirmSelect(){
  103. let sn = this.list.filter(l=>l.checked).length;
  104. if(sn<1) return this.$showToast('请至少选择一件商品');
  105. let list = this.list.filter(l=>l.checked);
  106. list.forEach(l=>l.nextQuantity=l.quantity);
  107. this.getOpenerEventChannel().emit('addGoods', list);
  108. uni.navigateBack();
  109. }
  110. }
  111. }
  112. </script>
  113. <style scoped lang="less">
  114. .page{
  115. width: 100%;
  116. padding-bottom: 160rpx;
  117. box-sizing: border-box;
  118. background: #F4F8FB;
  119. .goods{
  120. width: calc(100% - 48rpx);
  121. margin: 0 auto;
  122. .good{
  123. width: 100%;
  124. padding: 34rpx 24rpx;
  125. box-sizing: border-box;
  126. background: #FFFFFF;
  127. border-radius: 16rpx;
  128. margin-top: 20rpx;
  129. display: flex;
  130. .check{
  131. width: 56rpx;
  132. image{
  133. width: 36rpx;
  134. height: 36rpx;
  135. }
  136. }
  137. .info{
  138. width: calc(100% - 56rpx);
  139. .name{
  140. font-family: PingFang-SC, PingFang-SC;
  141. font-weight: bold;
  142. font-size: 30rpx;
  143. color: #1D2129;
  144. line-height: 30rpx;
  145. text-align: left;
  146. overflow: hidden;
  147. text-overflow: ellipsis;
  148. white-space: nowrap;
  149. }
  150. .ggxx{
  151. font-family: PingFangSC, PingFang SC;
  152. font-weight: 400;
  153. font-size: 24rpx;
  154. color: #86909C;
  155. line-height: 24rpx;
  156. text-align: left;
  157. margin-top: 23rpx;
  158. span{
  159. color: #4E5969;
  160. }
  161. }
  162. .price{
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-between;
  166. margin-top: 23rpx;
  167. .left{
  168. font-family: PingFangSC, PingFang SC;
  169. font-weight: 400;
  170. font-size: 24rpx;
  171. color: #86909C;
  172. line-height: 24rpx;
  173. text-align: left;
  174. span{
  175. font-weight: bold;
  176. font-size: 26rpx;
  177. color: #FF4141;
  178. margin-left: 24rpx;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. .btn{
  186. width: 100%;
  187. height: 140rpx;
  188. padding: 16rpx 20rpx 0 30rpx;
  189. box-sizing: border-box;
  190. background: #FFFFFF;
  191. position: fixed;
  192. left: 0;
  193. bottom: 0;
  194. display: flex;
  195. align-items: center;
  196. justify-content: space-between;
  197. .left{
  198. display: flex;
  199. align-items: center;
  200. image{
  201. width: 36rpx;
  202. height: 36rpx;
  203. }
  204. text{
  205. font-family: PingFangSC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 30rpx;
  208. color: #1D2129;
  209. line-height: 42rpx;
  210. text-align: left;
  211. margin-left: 12rpx;
  212. }
  213. }
  214. .confirm{
  215. width: 200rpx;
  216. height: 88rpx;
  217. background: #198CFF;
  218. border-radius: 16rpx;
  219. font-family: PingFang-SC, PingFang-SC;
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. color: #FFFFFF;
  223. line-height: 88rpx;
  224. text-align: center;
  225. letter-spacing: 2rpx;
  226. }
  227. }
  228. }
  229. </style>