提交 17dc0fe7 authored 作者: 刘旭's avatar 刘旭

修改单价

上级 b062c6ec
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<h4>{{ item.goodsName }}</h4> <h4>{{ item.goodsName }}</h4>
<view style="display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx;"> <view style="display: flex; flex-direction: row; align-items: center; margin-bottom: 10rpx;">
<text>重新设置单价:</text> <text>重新设置单价:</text>
<u-input v-model="item.price" type="number" height="50" placeholder="请输入单价" style="width: 200rpx;" <input v-model="item.price" type="number" height="50" placeholder="请输入单价" style="width: 200rpx;"
@input="priceInput($event, index)" /> @blur="priceBlur($event, index)" @focus="priceFocus" />
</view> </view>
<view style="margin-bottom: 10rpx; display: flex; justify-content: space-between;"> <view style="margin-bottom: 10rpx; display: flex; justify-content: space-between;">
<view class=""> <view class="">
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { ref, computed } from 'vue'; import { ref, computed, nextTick } from 'vue';
import { quotationInitAgain, fillQuotation } from '@/api/cart'; import { quotationInitAgain, fillQuotation } from '@/api/cart';
import { getTax } from '@/api/index'; import { getTax } from '@/api/index';
import config from '@/utils/config'; import config from '@/utils/config';
...@@ -68,6 +68,8 @@ let tax = ref(); ...@@ -68,6 +68,8 @@ let tax = ref();
let content = ref('确认重新报价?'); let content = ref('确认重新报价?');
let show = ref(false); let show = ref(false);
let showModel = ref(false); let showModel = ref(false);
let oldPrice = ref()
onLoad((options: any) => { onLoad((options: any) => {
orderId.value = options.orderId; orderId.value = options.orderId;
getTax().then((res: any) => { getTax().then((res: any) => {
...@@ -148,20 +150,29 @@ let valChange = (val: any) => { ...@@ -148,20 +150,29 @@ let valChange = (val: any) => {
quotationData.value.items[val.index].number * quotationData.value.items[val.index].price; quotationData.value.items[val.index].number * quotationData.value.items[val.index].price;
quotationData.value.items[val.index].totalPriceTex = quotationData.value.items[val.index].totalPriceTex =
quotationData.value.items[val.index].totalPrice * tax.value + Number(quotationData.value.items[val.index].price * tax.value +
quotationData.value.items[val.index].totalPrice; quotationData.value.items[val.index].price) * val.value
}; };
// 单价变化处理 let priceFocus = (data: any) => {
let priceInput = (val: any, index: number) => { const { value } = data.detail
quotationData.value.items[index].price = val; oldPrice.value = value
}
// 单价变化处理
let priceBlur = (data: any, index: number) => {
const { value: val } = data.detail
if (Number(val) === Number(oldPrice.value)) return
let price = Number(val) * 100
nextTick(() => {
let newPrice = (price - price * tax.value) / 100
let number = quotationData.value.items[index].number
quotationData.value.items[index].price = newPrice.toFixed(2)
quotationData.value.items[index].totalPrice = quotationData.value.items[index].totalPrice =
Number(quotationData.value.items[index].number) * val; Number(number) * newPrice
quotationData.value.items[index].totalPriceTex = quotationData.value.items[index].totalPriceTex =
quotationData.value.items[index].totalPrice * tax.value + Number((newPrice * tax.value + newPrice) * number)
quotationData.value.items[index].totalPrice; })
}; };
let init = () => { let init = () => {
......
...@@ -325,7 +325,6 @@ let priceCheck = (data: any, index: number) => { ...@@ -325,7 +325,6 @@ let priceCheck = (data: any, index: number) => {
}) })
if (Number(val) === Number(oldPrice.value)) return if (Number(val) === Number(oldPrice.value)) return
else { else {
oldPrice.value = val
let price = Number(val) * 100 let price = Number(val) * 100
nextTick(() => { nextTick(() => {
detailData.value[index].unitPrice = ((price - price * tax.value * 0.01) / 100).toFixed(2) detailData.value[index].unitPrice = ((price - price * tax.value * 0.01) / 100).toFixed(2)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论