fix:修复采购管理零售价表格列合计计算错误

This commit is contained in:
weiwei committed 2025-10-15 10:40:48 +08:00
1 parent 69e7c1f0de
commit f5bf29ba9e
2 files changed
+12 -4

No files matched your search

@@ -73,6 +73,7 @@
{
seq: '合计',
quantity: total.quantity,
retailPrice: total.retailPrice,
purchasePrice: total.purchasePrice,
realPrice: `${total.realPrice}元`,
totalAmount: total.totalAmount,
@@ -129,7 +130,7 @@
<el-input-number v-else v-model="row.quantity" :min="0" :precision="2" @change="onQuantityChange(row, $rowIndex)" />
</template>
</vxe-column>
<vxe-column field="purchasePrice" title="零售价">
<vxe-column field="retailPrice" title="零售价">
<template #default="{ row }">
{{ displayPrice(row.selectedUnitObj?.retailPrice || 0) }}
</template>
@@ -256,12 +257,15 @@ const validRules = ref<VxeTablePropTypes.EditRules<any>>({
// 合计总金额
const total = computed(() => {
const quantity = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.quantity || 0), 0).toFixed(2)
const retailPrice = displayPrice(
vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.retailPrice || 0), 0).toFixed(2),
)
const purchasePrice = displayPrice(
vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.purchasePrice || 0), 0),
)
const realPrice = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.realPrice || 0), 0).toFixed(2)
const totalAmount = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.totalAmount || 0), 0).toFixed(2)
return { quantity, purchasePrice, realPrice, totalAmount }
return { quantity, retailPrice, purchasePrice, realPrice, totalAmount }
})
onMounted(async () => {
@@ -101,6 +101,7 @@
{
seq: '合计',
quantity: total.quantity,
retailPrice: total.retailPrice,
purchasePrice: total.purchasePrice,
realPrice: `${total.realPrice}元`,
totalAmount: total.totalAmount,
@@ -157,7 +158,7 @@
<el-input-number v-else v-model="row.quantity" :min="0" :precision="2" @change="onQuantityChange(row, $rowIndex)" />
</template>
</vxe-column>
<vxe-column field="purchasePrice" title="零售价">
<vxe-column field="retailPrice" title="零售价">
<template #default="{ row }">
{{ displayPrice(row.selectedUnitObj?.retailPrice || 0) }}
</template>
@@ -284,12 +285,15 @@ const validRules = ref<VxeTablePropTypes.EditRules<any>>({
// 合计总金额
const total = computed(() => {
const quantity = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.quantity || 0), 0).toFixed(2)
const retailPrice = displayPrice(
vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.retailPrice || 0), 0).toFixed(2),
)
const purchasePrice = displayPrice(
vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.purchasePrice || 0), 0),
)
const realPrice = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.realPrice || 0), 0).toFixed(2)
const totalAmount = vxeTableData.value.reduce((sum: any, row: any) => sum + Number(row.selectedUnitObj?.totalAmount || 0), 0).toFixed(2)
return { quantity, purchasePrice, realPrice, totalAmount }
return { quantity, retailPrice, purchasePrice, realPrice, totalAmount }
})
onMounted(async () => {