fix: 调整价格弹窗不出来问题

This commit is contained in:
puhui999 2024-04-22 11:35:28 +08:00
parent deb4585d4b
commit 243da124a8

View File

@ -6,7 +6,7 @@
</el-form-item> </el-form-item>
<el-form-item label="订单调价"> <el-form-item label="订单调价">
<el-input-number v-model="formData.adjustPrice" :precision="2" :step="0.1" class="w-100%" /> <el-input-number v-model="formData.adjustPrice" :precision="2" :step="0.1" class="w-100%" />
<el-tag class="mt-10px" type="warning">订单调价 正数加价负数减价</el-tag> <el-tag class="ml-10px" type="warning">订单调价 正数加价负数减价</el-tag>
</el-form-item> </el-form-item>
<el-form-item label="调价后"> <el-form-item label="调价后">
<el-input v-model="formData.newPayPrice" disabled /> <el-input v-model="formData.newPayPrice" disabled />
@ -38,10 +38,13 @@ const formData = ref({
}) })
watch( watch(
() => formData.value.adjustPrice, () => formData.value.adjustPrice,
(data: number) => { (adjustPrice: number | string) => {
const num = formData.value.payPrice!.replace('元', '') const numMatch = formData.value.payPrice.match(/\d+(\.\d+)?/)
// @ts-ignore if (numMatch) {
formData.value.newPayPrice = (num * 1 + data).toFixed(2) + '元' const payPriceNum = parseFloat(numMatch[0])
adjustPrice = typeof adjustPrice === 'string' ? parseFloat(adjustPrice) : adjustPrice
formData.value.newPayPrice = (payPriceNum + adjustPrice).toFixed(2) + '元'
}
} }
) )