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

修改单价

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