输入等于0时不让其保留两位小数

This commit is contained in:
郑庆 2025-10-22 21:47:34 +08:00
parent 4304287f3e
commit 0f1843cde5

View File

@ -158,7 +158,13 @@
<template #header><span class="hl-table_header">*</span>预估单价</template> <template #header><span class="hl-table_header">*</span>预估单价</template>
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-form-item :prop="`${$index}.unitPrice`" class="mb-0px!" > <el-form-item :prop="`${$index}.unitPrice`" class="mb-0px!" >
<el-input-number v-model="row.unitPrice" type="number" :precision="2" @change="changeUnitPrice(row)" /> <el-input
v-model="row.unitPrice"
type="number"
placeholder="两位小数"
@change="changeUnitPrice(row)"
/>
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> </el-table-column>
@ -166,7 +172,11 @@
<template #header><span class="hl-table_header">*</span>预估总价</template> <template #header><span class="hl-table_header">*</span>预估总价</template>
<template #default="{ row, $index }"> <template #default="{ row, $index }">
<el-form-item :prop="`${$index}.estimatedPrices`" class="mb-0px!" > <el-form-item :prop="`${$index}.estimatedPrices`" class="mb-0px!" >
<el-input-number v-model="row.estimatedPrices" type="number" :precision="2" @change="changeEstimatedPrices(row)" <el-input
v-model="row.estimatedPrices"
type="number"
@change="changeEstimatedPrices(row)"
placeholder="两位小数"
/> />
</el-form-item> </el-form-item>
</template> </template>
@ -445,11 +455,11 @@ const floatMul = (a, b) => {
} catch (f) {} } catch (f) {}
return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c); return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
} }
const changeUnitPrice =(row:any)=>{ const changeUnitPrice =(row:any)=>{
row.estimatedPrices=parseFloat((row.unitPrice* row.purchaseAmounts).toFixed(1)) row.estimatedPrices=parseFloat((row.unitPrice* row.purchaseAmounts).toFixed(1))
} }
const changeEstimatedPrices =(row:any)=>{ const changeEstimatedPrices =(row:any)=>{
row.unitPrice=parseFloat((row.estimatedPrices/row.purchaseAmounts).toFixed(1)) row.unitPrice=parseFloat((row.estimatedPrices/row.purchaseAmounts).toFixed(1))
} }
const change1 =(row:any)=>{ const change1 =(row:any)=>{
@ -529,7 +539,7 @@ const handleSelectedUser = (currentIndex, newValue: any) => {
} }
} }
const singleSubmissions=()=>{ const singleSubmissions=()=>{
submitForm(); submitForm();
} }
const submitForm = async () => { const submitForm = async () => {