goods.vue 5.8 KB

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