setProductCost.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="uni-icon-error tits">以下产品需设置结算价(即修理厂的进货价),否则无法上架入库</view>
  4. <view class="proudct-body">
  5. <view class="partList-list-box" v-for="(item,index) in partList" :key="item.id">
  6. <view class="product flex align_center">
  7. <view class="flex align_center justify_between">
  8. <view class="pimgs">
  9. <u-image :src="item.product.images?item.product.images:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  10. </view>
  11. <view class="pinfo">
  12. <view class="pname">
  13. <text>{{item.shelfPlaceCode}}</text>
  14. {{item.productCode}}
  15. </view>
  16. <view class="pname pname1">
  17. {{item.product.productName}}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="ptools flex align_center justify_end">
  23. <view class="pcurnums flex align_center justify_end">
  24. <text>结算价</text>
  25. <view class="u-ninput">
  26. <u-input style="width: 400rpx;" trim border type="digit" clearable @blur="numberToFixed(item,2,999999)" v-model="item.cost" placeholder="请输入价格,最多两位小数"/>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="footer-bar">
  33. <u-button type='primary' shape="circle" size="medium" @click="submitForm">设置完成</u-button>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { clzConfirm, numberToFixed } from '@/libs/tools';
  39. import {updateBatchById, shelfCartConfirm} from '@/api/shelfCart.js'
  40. export default {
  41. data() {
  42. return {
  43. partList:[],
  44. }
  45. },
  46. onLoad() {
  47. this.partList = this.$store.state.vuex_tempData
  48. this.partList.map(item => {
  49. item.cost = ''
  50. })
  51. },
  52. onUnload() {
  53. this.$store.state.vuex_tempData = null
  54. },
  55. methods: {
  56. // 小数点后两位
  57. numberToFixed: function (item, num, max) {
  58. let val = item.cost
  59. let ret = numberToFixed(val, num, max)
  60. this.$set(item,'cost',Number(ret <= 0 ? '' : ret))
  61. this.partList = JSON.parse(JSON.stringify(this.partList))
  62. },
  63. submitForm(){
  64. const hasEmpty = this.partList.filter(item => !item.cost)
  65. console.log(hasEmpty)
  66. if(hasEmpty.length){
  67. this.toashMsg("请输入结算价")
  68. }else{
  69. uni.showLoading({
  70. mask: true,
  71. title: '正在设置价格...'
  72. })
  73. updateBatchById(this.partList).then(res => {
  74. uni.hideLoading()
  75. if(res.status == 200){
  76. uni.$emit("setCostOk")
  77. uni.navigateBack()
  78. }
  79. })
  80. }
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="less">
  86. .content{
  87. height: 100vh;
  88. .tits{
  89. padding: 20upx 30upx;
  90. color: darkorange;
  91. font-size: 24rpx;
  92. }
  93. .proudct-body{
  94. width: 100%;
  95. flex-grow: 1;
  96. overflow: auto;
  97. background-color: #fff;
  98. padding: 0 20upx;
  99. }
  100. .partList-list-box{
  101. padding: 10px 0;
  102. border-bottom: 2rpx solid #f5f5f5;
  103. .product{
  104. flex-grow: 1;
  105. .pinfo{
  106. flex-grow: 1;
  107. padding-left: 20rpx;
  108. .pname{
  109. color: #191919;
  110. margin-bottom: 5rpx;
  111. text{
  112. font-weight: normal;
  113. margin-right: 10rpx;
  114. padding: 0 10rpx;
  115. background: rgba(3, 54, 146, 0.15);
  116. border-radius: 30rpx;
  117. color: #033692;
  118. font-size: 24rpx;
  119. }
  120. }
  121. }
  122. }
  123. .ptxt{
  124. font-size: 28rpx;
  125. color: #999;
  126. .pnums{
  127. color: #222;
  128. margin-right: 20upx;
  129. }
  130. }
  131. .ptools{
  132. .pcurnums{
  133. width: 80%;
  134. color: #999;
  135. > text{
  136. margin-right: 20rpx;
  137. }
  138. }
  139. }
  140. }
  141. .footer-bar{
  142. padding: 20upx;
  143. button{
  144. width: 80%;
  145. }
  146. text-align: center;
  147. }
  148. }
  149. </style>