PurchaseGoods.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view>
  3. <view class="goods-ul">
  4. <view class="goods-li" v-for="(item, index) in goods_list" :key="index">
  5. <view class="del-icon" @click="delGoods(index)"><u-icon name="minus-circle-fill" color="#fa3534" size="40"></u-icon></view>
  6. <view class="goods-name ellipsis">{{ item.goodsName }}</view>
  7. <view class="goods-sku clearfix">
  8. <view class="float_left" style="width: 430rpx;">规格:{{ item.unitName }}{{ item.specGropName }}</view>
  9. <view class="float_right">{{ item.goodsCode }}</view>
  10. </view>
  11. <view class="goods-sku clearfix" v-if="item.skuValue">
  12. <view class="float_left">换算比例:{{ item.skuValue }}</view>
  13. <view class="float_right">转换数量:{{ item.skuNum }}</view>
  14. </view>
  15. <view class="num-ul">
  16. <view class="num-li">
  17. <view class="label">采购单价</view>
  18. <view class="value"><input type="digit" @blur="subtotalPriceChange(index)" v-model="item.buyerUnitPrice" /></view>
  19. </view>
  20. <view class="num-li">
  21. <view class="label">采购数量</view>
  22. <view class="value"><input type="digit" @blur="subtotalPriceChange(index)" placeholder="请输入" v-model="item.buyerNum" /></view>
  23. </view>
  24. <view class="num-li" v-if="item.isEq === 5">
  25. <view class="label">其他单位</view>
  26. <view class="value"><input type="digit" @blur="subtotalPriceChange(index)" placeholder="请输入" v-model="item.otherNum" /></view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="detail-bottom clearfix">
  32. <view class="left-view">
  33. <view class="total-price">¥{{ purchaseAmount }}</view>
  34. <view class="left-desc">已选{{ goods_list.length }}种,{{ totalNum }}个</view>
  35. </view>
  36. <view class="right-view" @click="goodsConfirm"><view class="btn-li">确定</view></view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. value: 0,
  45. goods_list: []
  46. };
  47. },
  48. computed: {
  49. totalNum() {
  50. let sum = 0;
  51. if (this.goods_list.length > 1) {
  52. this.goods_list.forEach(item => {
  53. sum = this.$NP.plus(sum, Number(item.buyerNum));
  54. });
  55. } else if (this.goods_list.length === 1) {
  56. sum = Number(this.goods_list[0].buyerNum);
  57. } else {
  58. sum = 0;
  59. }
  60. return sum || 0;
  61. },
  62. purchaseAmount() {
  63. let sum = 0;
  64. if (this.goods_list.length > 1) {
  65. this.goods_list.forEach(item => {
  66. sum = this.$NP.plus(sum, Number(item.subtotalPrice));
  67. });
  68. } else if (this.goods_list.length === 1) {
  69. sum = Number(this.goods_list[0].subtotalPrice);
  70. } else {
  71. sum = 0;
  72. }
  73. return sum || 0;
  74. }
  75. },
  76. onLoad() {
  77. this.goods_list = uni.getStorageSync('PurchaseGoods');
  78. console.log('goods_list::', this.goods_list);
  79. },
  80. methods: {
  81. subtotalPriceChange(index) {
  82. const target = this.$u.deepClone(this.goods_list);
  83. target[index].subtotalPrice = this.$NP.times(target[index].buyerUnitPrice, target[index].buyerNum);
  84. this.goods_list = target;
  85. },
  86. goodsConfirm() {
  87. this._prePage().purchaseGoods = this.goods_list;
  88. uni.navigateBack();
  89. },
  90. delGoods(index) {
  91. this.goods_list.splice(index, 1);
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. .goods-ul {
  98. padding-bottom: 100rpx;
  99. .goods-li {
  100. background-color: #ffffff;
  101. border-bottom: 1px solid #eeeeee;
  102. padding: 20rpx;
  103. padding-left: 80rpx;
  104. font-size: 24rpx;
  105. color: #6c6c6c;
  106. line-height: 50rpx;
  107. position: relative;
  108. .del-icon {
  109. position: absolute;
  110. top: 50%;
  111. left: 20rpx;
  112. transform: translateY(-50%);
  113. }
  114. .goods-name {
  115. -webkit-line-clamp: 2;
  116. font-size: 28rpx;
  117. color: #111111;
  118. }
  119. .price {
  120. font-size: 28rpx;
  121. color: $uni-color-error;
  122. }
  123. .goods-num {
  124. input {
  125. width: 170rpx;
  126. display: inline-block;
  127. border: 1px solid #eeeeee;
  128. line-height: 60rpx;
  129. border-radius: 10rpx;
  130. padding: 0 10rpx;
  131. vertical-align: middle;
  132. font-size: 24rpx;
  133. }
  134. }
  135. }
  136. }
  137. .num-ul {
  138. display: flex;
  139. font-size: 24rpx;
  140. padding-top: 10rpx;
  141. .num-li {
  142. flex: 4;
  143. border-right: 1px solid #ecf0f7;
  144. text-align: center;
  145. padding: 0 10rpx;
  146. &:last-child {
  147. border-right: 0 none;
  148. }
  149. .label {
  150. color: #879bba;
  151. }
  152. .value {
  153. height: 40rpx;
  154. line-height: 40rpx;
  155. border-bottom: 1px solid $uni-color-primary;
  156. input {
  157. font-size: 24rpx;
  158. height: 40rpx;
  159. line-height: 40rpx;
  160. }
  161. }
  162. }
  163. }
  164. .detail-bottom {
  165. display: block;
  166. background-color: #ffffff;
  167. .left-view {
  168. float: left;
  169. padding: 10rpx 30rpx;
  170. .total-price {
  171. color: $uni-color-error;
  172. font-weight: bold;
  173. }
  174. .left-desc {
  175. font-size: 24rpx;
  176. color: #6c6c6c;
  177. }
  178. }
  179. .right-view {
  180. float: right;
  181. padding: 10rpx 30rpx;
  182. margin-left: 30rpx;
  183. .btn-li {
  184. width: 200rpx;
  185. text-align: center;
  186. line-height: 80rpx;
  187. height: 80rpx;
  188. background: $uni-color-primary;
  189. border: 1px solid $uni-color-primary;
  190. color: #ffffff;
  191. border-radius: 10rpx;
  192. }
  193. }
  194. }
  195. </style>