From 01bd8d7b18b84843e53432d8405ff325def10b94 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 15 十月 2026 09:08:51 +0800
Subject: [PATCH] feat: 更新金额格式化功能,统一使用四舍五入到两位小数并去掉多余的零
---
src/views/procurementManagement/procurementLedger/index.vue | 39 ++++++++++++-------
src/views/salesManagement/salesLedger/index.vue | 40 ++++++++++++-------
2 files changed, 50 insertions(+), 29 deletions(-)
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 61852f4..b28df5d 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -133,10 +133,10 @@
:formatter="formattedNumber" />
<el-table-column label="鍚◣鎬讳环(鍏�)"
prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber" />
+ :formatter="formattedAmount" />
<el-table-column label="涓嶅惈绋庢�讳环(鍏�)"
prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber" />
+ :formatter="formattedAmount" />
</el-table>
</template>
</el-table-column>
@@ -194,7 +194,7 @@
prop="contractAmount"
width="200"
show-overflow-tooltip
- :formatter="formattedNumber" />
+ :formatter="formattedAmount" />
<!-- <el-table-column label="瀹為檯鍚堝悓閲戦(鍏�)"-->
<!-- prop="netContractAmount"-->
<!-- width="200"-->
@@ -432,11 +432,11 @@
width="150" />
<el-table-column label="鍚◣鎬讳环(鍏�)"
prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
width="150" />
<el-table-column label="涓嶅惈绋庢�讳环(鍏�)"
prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
width="150" />
<el-table-column label="鏄惁璐ㄦ"
prop="isChecked"
@@ -761,7 +761,7 @@
import { modelList, productTreeList } from "@/api/basicData/product.js";
import dayjs from "dayjs";
import FileUpload from "@/components/AttachmentUpload/file/index.vue";
- import { trimZeros } from "@/utils/formatNumber.js";
+ import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js";
const userStore = useUserStore();
@@ -1088,6 +1088,14 @@
const formattedNumber = (row, column, cellValue) => {
return trimZeros(cellValue, 6);
};
+ // 閲戦鏄剧ず鏍煎紡鍖栵細鎸夊崄杩涘埗鍥涜垗浜斿叆鍒� 2 浣嶅皬鏁帮紙涓庢暟鎹簱 ROUND 涓�鑷达級锛屽啀鍘绘帀鏈熬澶氫綑鐨� 0
+ const formatAmount = value => {
+ return trimZeros(roundHalfUp(value, 2), 2);
+ };
+ // 閲戦鍒楃殑琛ㄦ牸鏍煎紡鍖栧嚱鏁帮紙鍗曚环鍒椾粛鐢� formattedNumber 淇濈暀 6 浣嶅皬鏁帮級
+ const formattedAmount = (row, column, cellValue) => {
+ return formatAmount(cellValue);
+ };
// 鏌ヨ鍒楄〃
/** 鎼滅储鎸夐挳鎿嶄綔 */
const handleQuery = () => {
@@ -1207,10 +1215,11 @@
],
{
taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
- taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
- taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
- ticketsAmount: { decimalPlaces: 6, trimZeros: true },
- futureTicketsAmount: { decimalPlaces: 6, trimZeros: true },
+ // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
+ taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ ticketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ futureTicketsAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁�
}
@@ -1280,8 +1289,9 @@
param,
["contractAmount", "netContractAmount"],
{
- contractAmount: { decimalPlaces: 6, trimZeros: true },
- netContractAmount: { decimalPlaces: 6, trimZeros: true },
+ // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
+ contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ netContractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
}
);
};
@@ -1296,8 +1306,9 @@
],
{
taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
- taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
- taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+ // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
+ taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
}
);
};
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 93d5ef6..5d21226 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -161,12 +161,12 @@
<el-table-column
label="鍚◣鎬讳环(鍏�)"
prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
/>
<el-table-column
label="涓嶅惈绋庢�讳环(鍏�)"
prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
/>
<!--鎿嶄綔-->
<el-table-column Width="60px" label="鎿嶄綔" align="center">
@@ -219,7 +219,7 @@
prop="contractAmount"
width="220"
show-overflow-tooltip
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
/>
<el-table-column
label="褰曞叆浜�"
@@ -523,12 +523,12 @@
<el-table-column
label="鍚◣鎬讳环(鍏�)"
prop="taxInclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
/>
<el-table-column
label="涓嶅惈绋庢�讳环(鍏�)"
prop="taxExclusiveTotalPrice"
- :formatter="formattedNumber"
+ :formatter="formattedAmount"
/>
<el-table-column label="鏄惁鐢熶骇" prop="isProduction" width="150">
<template #default="scope">
@@ -654,7 +654,7 @@
align="right"
>
<template #default="scope">
- {{ trimZeros(scope.row.totalAmount, 6) }}
+ {{ formatAmount(scope.row.totalAmount) }}
</template>
</el-table-column>
<el-table-column fixed="right" label="鎿嶄綔" width="120" align="center">
@@ -962,7 +962,7 @@
<td>{{ trimZeros(product.taxInclusiveUnitPrice, 6) }}</td>
<td>{{ trimZeros(product.quantity, 6) }}</td>
<td>
- {{ trimZeros(product.taxInclusiveTotalPrice, 6) }}
+ {{ formatAmount(product.taxInclusiveTotalPrice) }}
</td>
</tr>
<tr v-if="!item.products || item.products.length === 0">
@@ -1190,7 +1190,7 @@
import FileUpload from "@/components/AttachmentUpload/file/index.vue";
import ImageUpload from "@/components/AttachmentUpload/image/index.vue";
import { getCurrentDate } from "@/utils/index.js";
-import { trimZeros } from "@/utils/formatNumber.js";
+import { roundHalfUp, trimZeros } from "@/utils/formatNumber.js";
import { listCustomer } from "@/api/basicData/customer.js";
const FileList = defineAsyncComponent(() =>
@@ -1536,6 +1536,14 @@
const formattedNumber = (row, column, cellValue) => {
return trimZeros(cellValue, 6);
};
+// 閲戦鏄剧ず鏍煎紡鍖栵細鎸夊崄杩涘埗鍥涜垗浜斿叆鍒� 2 浣嶅皬鏁帮紙涓庢暟鎹簱 ROUND 涓�鑷达級锛屽啀鍘绘帀鏈熬澶氫綑鐨� 0
+const formatAmount = (value) => {
+ return trimZeros(roundHalfUp(value, 2), 2);
+};
+// 閲戦鍒楃殑琛ㄦ牸鏍煎紡鍖栧嚱鏁帮紙鍗曚环鍒椾粛鐢� formattedNumber 淇濈暀 6 浣嶅皬鏁帮級
+const formattedAmount = (row, column, cellValue) => {
+ return formatAmount(cellValue);
+};
const findLedgerRecordByRow = (row) => {
if (!row) return null;
if (
@@ -1694,9 +1702,10 @@
param,
["contractAmount", "taxInclusiveTotalPrice", "taxExclusiveTotalPrice"],
{
- contractAmount: { decimalPlaces: 6, trimZeros: true },
- taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
- taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+ // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
+ contractAmount: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
}
);
};
@@ -1711,8 +1720,9 @@
],
{
taxInclusiveUnitPrice: { decimalPlaces: 6, trimZeros: true },
- taxInclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
- taxExclusiveTotalPrice: { decimalPlaces: 6, trimZeros: true },
+ // 閲戦鍒楋細姣忚鍏堟寜 2 浣嶅皬鏁板洓鑸嶄簲鍏ュ啀姹傚拰锛屼繚璇佸悎璁′笌鍒楀唴灞曠ず鍊间竴鑷�
+ taxInclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
+ taxExclusiveTotalPrice: { roundEach: 2, decimalPlaces: 2, trimZeros: true },
}
);
};
@@ -2544,7 +2554,7 @@
const total = products.reduce((sum, product) => {
return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
}, 0);
- return trimZeros(total, 6);
+ return formatAmount(total);
};
// 鐢ㄤ簬鎵撳嵃鐨勮绠楀嚱鏁�
@@ -2561,7 +2571,7 @@
const total = products.reduce((sum, product) => {
return sum + (parseFloat(product.taxInclusiveTotalPrice) || 0);
}, 0);
- return trimZeros(total, 6);
+ return formatAmount(total);
};
const mathNum = () => {
--
Gitblit v1.9.3