From 58246805d5f5d33ec43e88eca01acefa7dfd9777 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 08 十月 2026 20:54:05 +0800
Subject: [PATCH] fix: 小数点保存两位
---
src/utils/numberFormat.js | 16 ++++++++++++++--
src/views/salesManagement/receiptPaymentLedger/index.vue | 10 ++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/utils/numberFormat.js b/src/utils/numberFormat.js
index 50175f0..2913a07 100644
--- a/src/utils/numberFormat.js
+++ b/src/utils/numberFormat.js
@@ -1,6 +1,9 @@
/** 閲戦绫诲瓧娈甸粯璁ゆ渶澶у皬鏁颁綅鏁� */
export const AMOUNT_DECIMAL_SCALE = 6
+/** 閲戦锛堝厓锛夐粯璁ゅ睍绀哄皬鏁颁綅鏁� */
+export const MONEY_DECIMAL_SCALE = 2
+
/**
* 鏍煎紡鍖栨暟瀛楋細鏈�澶氫繚鐣� scale 浣嶅皬鏁帮紝骞跺幓闄ゆ湯灏惧浣欑殑 0
*/
@@ -25,6 +28,11 @@
return formatDecimal(cellValue)
}
+/** el-table-column formatter锛氶噾棰濓紙鍏冿級鍒楋紝鏈�澶氫繚鐣� 2 浣嶅皬鏁� */
+export function moneyAmountFormatter(row, column, cellValue) {
+ return formatDecimal(cellValue, MONEY_DECIMAL_SCALE)
+}
+
/** 璁$畻鍚庝繚鐣欐寚瀹氫綅灏忔暟 */
export function roundAmount(value, scale = AMOUNT_DECIMAL_SCALE) {
if (value === null || value === undefined || value === '') {
@@ -38,10 +46,14 @@
}
/** 鏋勫缓 summarizeTable 閲戦鍒楁牸寮忛厤缃� */
-export function buildAmountSummaryFormat(fields, extraFormat = {}) {
+export function buildAmountSummaryFormat(
+ fields,
+ extraFormat = {},
+ scale = AMOUNT_DECIMAL_SCALE
+) {
const format = { ...extraFormat }
fields.forEach(field => {
- format[field] = { decimalPlaces: AMOUNT_DECIMAL_SCALE }
+ format[field] = { decimalPlaces: scale }
})
return format
}
diff --git a/src/views/salesManagement/receiptPaymentLedger/index.vue b/src/views/salesManagement/receiptPaymentLedger/index.vue
index 0bc5de3..1afe45e 100644
--- a/src/views/salesManagement/receiptPaymentLedger/index.vue
+++ b/src/views/salesManagement/receiptPaymentLedger/index.vue
@@ -126,7 +126,7 @@
customewTransactionsDetails,
} from "@/api/salesManagement/indicatorStats.js";
import Pagination from "../../../components/PIMTable/Pagination.vue";
- import { tableAmountFormatter, buildAmountSummaryFormat } from "@/utils/numberFormat";
+ import { moneyAmountFormatter, buildAmountSummaryFormat, MONEY_DECIMAL_SCALE } from "@/utils/numberFormat";
const { proxy } = getCurrentInstance();
const tableData = ref([]);
const receiptRecord = ref([]);
@@ -174,7 +174,7 @@
}
});
};
- const formattedNumber = tableAmountFormatter;
+ const formattedNumber = moneyAmountFormatter;
// 涓昏〃鍚堣鏂规硶
const summarizeMainTable = param => {
return proxy.summarizeTable(
@@ -185,7 +185,8 @@
{
ticketsNum: { noDecimal: true },
futureTickets: { noDecimal: true },
- }
+ },
+ MONEY_DECIMAL_SCALE
)
);
};
@@ -199,7 +200,8 @@
{
ticketsNum: { noDecimal: true },
futureTickets: { noDecimal: true },
- }
+ },
+ MONEY_DECIMAL_SCALE
)
);
return summarizeTable;
--
Gitblit v1.9.3