goods.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. projectId:''
  49. },
  50. selectNum:0,
  51. ids:[]
  52. }
  53. },
  54. onReachBottom() {
  55. if(this.isOver) return
  56. this.getList();
  57. },
  58. onPullDownRefresh() {
  59. this.params.page = 1;
  60. this.isOver = false;
  61. this.list = [];
  62. this.getList();
  63. },
  64. watch:{
  65. list:{
  66. handler(newValue){
  67. this.selectNum = this.list.filter(l=>l.checked).length;
  68. },
  69. deep:true,
  70. immediate:true
  71. }
  72. },
  73. async onLoad(option) {
  74. this.params.warehouseId = option.warehouseId;
  75. this.params.projectId = option.projectId;
  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. this.getOpenerEventChannel().emit('addGoods', list);
  107. uni.navigateBack();
  108. }
  109. }
  110. }
  111. </script>
  112. <style scoped lang="less">
  113. .page{
  114. width: 100%;
  115. padding-bottom: 160rpx;
  116. box-sizing: border-box;
  117. background: #F4F8FB;
  118. .goods{
  119. width: calc(100% - 48rpx);
  120. margin: 0 auto;
  121. .good{
  122. width: 100%;
  123. padding: 34rpx 24rpx;
  124. box-sizing: border-box;
  125. background: #FFFFFF;
  126. border-radius: 16rpx;
  127. margin-top: 20rpx;
  128. display: flex;
  129. .check{
  130. width: 56rpx;
  131. image{
  132. width: 36rpx;
  133. height: 36rpx;
  134. }
  135. }
  136. .info{
  137. width: calc(100% - 56rpx);
  138. .name{
  139. font-family: PingFang-SC, PingFang-SC;
  140. font-weight: bold;
  141. font-size: 30rpx;
  142. color: #1D2129;
  143. line-height: 30rpx;
  144. text-align: left;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. white-space: nowrap;
  148. }
  149. .ggxx{
  150. font-family: PingFangSC, PingFang SC;
  151. font-weight: 400;
  152. font-size: 24rpx;
  153. color: #86909C;
  154. line-height: 24rpx;
  155. text-align: left;
  156. margin-top: 23rpx;
  157. span{
  158. color: #4E5969;
  159. }
  160. }
  161. .price{
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. margin-top: 23rpx;
  166. .left{
  167. font-family: PingFangSC, PingFang SC;
  168. font-weight: 400;
  169. font-size: 24rpx;
  170. color: #86909C;
  171. line-height: 24rpx;
  172. text-align: left;
  173. span{
  174. font-weight: bold;
  175. font-size: 26rpx;
  176. color: #FF4141;
  177. margin-left: 24rpx;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. .btn{
  185. width: 100%;
  186. height: 140rpx;
  187. padding: 16rpx 20rpx 0 30rpx;
  188. box-sizing: border-box;
  189. background: #FFFFFF;
  190. position: fixed;
  191. left: 0;
  192. bottom: 0;
  193. display: flex;
  194. align-items: center;
  195. justify-content: space-between;
  196. .left{
  197. display: flex;
  198. align-items: center;
  199. image{
  200. width: 36rpx;
  201. height: 36rpx;
  202. }
  203. text{
  204. font-family: PingFangSC, PingFang SC;
  205. font-weight: 400;
  206. font-size: 30rpx;
  207. color: #1D2129;
  208. line-height: 42rpx;
  209. text-align: left;
  210. margin-left: 12rpx;
  211. }
  212. }
  213. .confirm{
  214. width: 200rpx;
  215. height: 88rpx;
  216. background: #198CFF;
  217. border-radius: 16rpx;
  218. font-family: PingFang-SC, PingFang-SC;
  219. font-weight: bold;
  220. font-size: 32rpx;
  221. color: #FFFFFF;
  222. line-height: 88rpx;
  223. text-align: center;
  224. letter-spacing: 2rpx;
  225. }
  226. }
  227. }
  228. </style>