setProductCost.vue 3.3 KB

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