goods.vue 5.6 KB

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