goods.vue 5.5 KB

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