goods.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. }
  54. },
  55. onReachBottom() {
  56. if(this.isOver) return
  57. this.getList();
  58. },
  59. onPullDownRefresh() {
  60. this.params.page = 1;
  61. this.isOver = false;
  62. this.list = [];
  63. this.getList();
  64. },
  65. watch:{
  66. list:{
  67. handler(newValue){
  68. this.selectNum = this.list.filter(l=>l.checked).length;
  69. },
  70. deep:true,
  71. immediate:true
  72. }
  73. },
  74. async onLoad(option) {
  75. let ids = option.ids;
  76. if(ids&&ids.indexOf(',')>-1) ids = ids.split(',');
  77. this.params.warehouseId = option.warehouseId;
  78. await this.getList();
  79. if(ids&&ids.length){
  80. ids.forEach(item=>{
  81. let fi = this.list.findIndex(l=>l.skuId===item);
  82. if(fi>-1) this.$set(this.list[fi],'checked',true);
  83. })
  84. }
  85. },
  86. methods:{
  87. async getList(){
  88. let res = await this.$api.get('/wms/inventory/boardList/warehouse',this.params);
  89. if(res.data.code===0){
  90. if(this.list.length<res.data.data.total){
  91. this.params.page++;
  92. this.list = [...this.list,...res.data.data.list];
  93. this.list.forEach((d,i)=>{
  94. this.$set(this.list[i],'checked',false);
  95. this.$set(this.list[i],'checknum',1);
  96. })
  97. }else this.isOver = true
  98. }else this.$showModal(res.msg)
  99. },
  100. changeCheck(index){
  101. this.$set(this.list[index],'checked',!this.list[index].checked);
  102. },
  103. changeNum(e,index){
  104. this.$set(this.list[index],'checknum',e.value);
  105. },
  106. confirmSelect(){
  107. let sn = this.list.filter(l=>l.checked).length;
  108. if(sn<1) return this.$showToast('请至少选择一件商品');
  109. let list = this.list.filter(l=>l.checked);
  110. list.forEach(l=>l.nextQuantity=l.quantity);
  111. this.getOpenerEventChannel().emit('addGoods', list);
  112. uni.navigateBack();
  113. }
  114. }
  115. }
  116. </script>
  117. <style scoped lang="less">
  118. .page{
  119. width: 100%;
  120. padding-bottom: 160rpx;
  121. box-sizing: border-box;
  122. background: #F4F8FB;
  123. .goods{
  124. width: calc(100% - 48rpx);
  125. margin: 0 auto;
  126. .good{
  127. width: 100%;
  128. padding: 34rpx 24rpx;
  129. box-sizing: border-box;
  130. background: #FFFFFF;
  131. border-radius: 16rpx;
  132. margin-top: 20rpx;
  133. display: flex;
  134. .check{
  135. width: 56rpx;
  136. image{
  137. width: 36rpx;
  138. height: 36rpx;
  139. }
  140. }
  141. .info{
  142. width: calc(100% - 56rpx);
  143. .name{
  144. font-family: PingFang-SC, PingFang-SC;
  145. font-weight: bold;
  146. font-size: 30rpx;
  147. color: #1D2129;
  148. line-height: 30rpx;
  149. text-align: left;
  150. overflow: hidden;
  151. text-overflow: ellipsis;
  152. white-space: nowrap;
  153. }
  154. .ggxx{
  155. font-family: PingFangSC, PingFang SC;
  156. font-weight: 400;
  157. font-size: 24rpx;
  158. color: #86909C;
  159. line-height: 24rpx;
  160. text-align: left;
  161. margin-top: 23rpx;
  162. span{
  163. color: #4E5969;
  164. }
  165. }
  166. .price{
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. margin-top: 23rpx;
  171. .left{
  172. font-family: PingFangSC, PingFang SC;
  173. font-weight: 400;
  174. font-size: 24rpx;
  175. color: #86909C;
  176. line-height: 24rpx;
  177. text-align: left;
  178. span{
  179. font-weight: bold;
  180. font-size: 26rpx;
  181. color: #FF4141;
  182. margin-left: 24rpx;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. .btn{
  190. width: 100%;
  191. height: 140rpx;
  192. padding: 16rpx 20rpx 0 30rpx;
  193. box-sizing: border-box;
  194. background: #FFFFFF;
  195. position: fixed;
  196. left: 0;
  197. bottom: 0;
  198. display: flex;
  199. align-items: center;
  200. justify-content: space-between;
  201. .left{
  202. display: flex;
  203. align-items: center;
  204. image{
  205. width: 36rpx;
  206. height: 36rpx;
  207. }
  208. text{
  209. font-family: PingFangSC, PingFang SC;
  210. font-weight: 400;
  211. font-size: 30rpx;
  212. color: #1D2129;
  213. line-height: 42rpx;
  214. text-align: left;
  215. margin-left: 12rpx;
  216. }
  217. }
  218. .confirm{
  219. width: 200rpx;
  220. height: 88rpx;
  221. background: #198CFF;
  222. border-radius: 16rpx;
  223. font-family: PingFang-SC, PingFang-SC;
  224. font-weight: bold;
  225. font-size: 32rpx;
  226. color: #FFFFFF;
  227. line-height: 88rpx;
  228. text-align: center;
  229. letter-spacing: 2rpx;
  230. }
  231. }
  232. }
  233. </style>