goods.vue 5.6 KB

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