setProductCost.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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" :custom-style="customBtnStyle" @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. customBtnStyle: { // 自定义按钮样式
  43. borderColor: this.$config('primaryColor'),
  44. backgroundColor: this.$config('primaryColor'),
  45. color: '#fff'
  46. },
  47. }
  48. },
  49. onLoad() {
  50. this.partList = this.$store.state.vuex_tempData
  51. this.partList.map(item => {
  52. item.cost = ''
  53. })
  54. },
  55. onUnload() {
  56. this.$store.state.vuex_tempData = null
  57. },
  58. methods: {
  59. // 小数点后两位
  60. numberToFixed: function (item, num, max) {
  61. let val = item.cost
  62. let ret = numberToFixed(val, num, max)
  63. this.$set(item,'cost',Number(ret <= 0 ? '' : ret))
  64. this.partList = JSON.parse(JSON.stringify(this.partList))
  65. },
  66. submitForm(){
  67. const hasEmpty = this.partList.filter(item => !item.cost)
  68. console.log(hasEmpty)
  69. if(hasEmpty.length){
  70. this.toashMsg("请输入结算价")
  71. }else{
  72. uni.showLoading({
  73. mask: true,
  74. title: '正在设置价格...'
  75. })
  76. updateBatchById(this.partList).then(res => {
  77. uni.hideLoading()
  78. if(res.status == 200){
  79. uni.$emit("setCostOk")
  80. uni.navigateBack()
  81. }
  82. })
  83. }
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="less">
  89. .content{
  90. width: 100%;
  91. height: 100vh;
  92. .tits{
  93. padding: 20upx 30upx;
  94. color: darkorange;
  95. font-size: 24rpx;
  96. }
  97. .proudct-body{
  98. flex-grow: 1;
  99. width: 100%;
  100. overflow: auto;
  101. background-color: #fff;
  102. padding: 0 20upx;
  103. }
  104. .partList-list-box{
  105. padding: 10px 0;
  106. border-bottom: 2rpx solid #f5f5f5;
  107. .product{
  108. flex-grow: 1;
  109. .pinfo{
  110. flex-grow: 1;
  111. padding-left: 20rpx;
  112. .pname{
  113. color: #191919;
  114. margin-bottom: 5rpx;
  115. text{
  116. font-weight: normal;
  117. margin-right: 10rpx;
  118. padding: 0 10rpx;
  119. background: rgba(3, 54, 146, 0.15);
  120. border-radius: 30rpx;
  121. color: #033692;
  122. font-size: 24rpx;
  123. }
  124. }
  125. }
  126. }
  127. .pcurnums{
  128. color: #999;
  129. .u-ninput{
  130. width: 60%;
  131. padding: 0 10rpx;
  132. }
  133. }
  134. }
  135. .footer-bar{
  136. padding: 20upx;
  137. button{
  138. width: 80%;
  139. }
  140. text-align: center;
  141. }
  142. }
  143. </style>