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_between">
  23. <view></view>
  24. <view class="pcurnums flex align_center">
  25. <text>结算价</text>
  26. <view class="u-ninput">
  27. <u-input trim border type="digit" clearable @blur="numberToFixed(item,2,999999)" v-model="item.cost" placeholder="请输入价格,最多两位小数"/>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="footer-bar">
  34. <u-button type='primary' shape="circle" size="medium" @click="submitForm">设置完成</u-button>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import { clzConfirm, numberToFixed } from '@/libs/tools';
  40. import {updateBatchById, shelfCartConfirm} from '@/api/shelfCart.js'
  41. export default {
  42. data() {
  43. return {
  44. partList:[],
  45. }
  46. },
  47. onLoad() {
  48. this.partList = this.$store.state.vuex_tempData
  49. this.partList.map(item => {
  50. item.cost = ''
  51. })
  52. },
  53. onUnload() {
  54. this.$store.state.vuex_tempData = null
  55. },
  56. methods: {
  57. // 小数点后两位
  58. numberToFixed: function (item, num, max) {
  59. let val = item.cost
  60. let ret = numberToFixed(val, num, max)
  61. this.$set(item,'cost',Number(ret <= 0 ? '' : ret))
  62. this.partList = JSON.parse(JSON.stringify(this.partList))
  63. },
  64. submitForm(){
  65. const hasEmpty = this.partList.filter(item => !item.cost)
  66. console.log(hasEmpty)
  67. if(hasEmpty.length){
  68. this.toashMsg("请输入结算价")
  69. }else{
  70. uni.showLoading({
  71. mask: true,
  72. title: '正在设置价格...'
  73. })
  74. updateBatchById(this.partList).then(res => {
  75. uni.hideLoading()
  76. if(res.status == 200){
  77. uni.$emit("setCostOk")
  78. uni.navigateBack()
  79. }
  80. })
  81. }
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="less">
  87. .content{
  88. height: 100vh;
  89. .tits{
  90. padding: 20upx 30upx;
  91. color: darkorange;
  92. font-size: 24rpx;
  93. }
  94. .proudct-body{
  95. width: 100%;
  96. flex-grow: 1;
  97. overflow: auto;
  98. background-color: #fff;
  99. padding: 0 20upx;
  100. }
  101. .partList-list-box{
  102. padding: 10px 0;
  103. border-bottom: 2rpx solid #f5f5f5;
  104. .product{
  105. flex-grow: 1;
  106. .pinfo{
  107. flex-grow: 1;
  108. padding-left: 20rpx;
  109. .pname{
  110. color: #191919;
  111. margin-bottom: 5rpx;
  112. text{
  113. font-weight: normal;
  114. margin-right: 10rpx;
  115. padding: 0 10rpx;
  116. background: rgba(3, 54, 146, 0.15);
  117. border-radius: 30rpx;
  118. color: #033692;
  119. font-size: 24rpx;
  120. }
  121. }
  122. }
  123. }
  124. .ptxt{
  125. font-size: 28rpx;
  126. color: #999;
  127. .pnums{
  128. color: #222;
  129. margin-right: 20upx;
  130. }
  131. }
  132. .ptools{
  133. .pcurnums{
  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>