From c48476691b8dad4db5964837e7cdcef253b9e9e7 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期四, 23 七月 2026 16:13:38 +0800
Subject: [PATCH] fix: 采购和销售优化公司名称显示
---
src/utils/numberFormat.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/utils/numberFormat.js b/src/utils/numberFormat.js
new file mode 100644
index 0000000..50175f0
--- /dev/null
+++ b/src/utils/numberFormat.js
@@ -0,0 +1,47 @@
+/** 閲戦绫诲瓧娈甸粯璁ゆ渶澶у皬鏁颁綅鏁� */
+export const AMOUNT_DECIMAL_SCALE = 6
+
+/**
+ * 鏍煎紡鍖栨暟瀛楋細鏈�澶氫繚鐣� scale 浣嶅皬鏁帮紝骞跺幓闄ゆ湯灏惧浣欑殑 0
+ */
+export function formatDecimal(value, scale = AMOUNT_DECIMAL_SCALE, fallback = '0') {
+ if (value === null || value === undefined || value === '') {
+ return fallback
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return fallback
+ }
+ return parseFloat(num.toFixed(scale)).toString()
+}
+
+/** 甯﹁揣甯佺鍙风殑閲戦灞曠ず */
+export function formatCurrency(value, scale = AMOUNT_DECIMAL_SCALE) {
+ return `楼${formatDecimal(value, scale)}`
+}
+
+/** el-table-column formatter */
+export function tableAmountFormatter(row, column, cellValue) {
+ return formatDecimal(cellValue)
+}
+
+/** 璁$畻鍚庝繚鐣欐寚瀹氫綅灏忔暟 */
+export function roundAmount(value, scale = AMOUNT_DECIMAL_SCALE) {
+ if (value === null || value === undefined || value === '') {
+ return 0
+ }
+ const num = Number(value)
+ if (Number.isNaN(num)) {
+ return 0
+ }
+ return parseFloat(num.toFixed(scale))
+}
+
+/** 鏋勫缓 summarizeTable 閲戦鍒楁牸寮忛厤缃� */
+export function buildAmountSummaryFormat(fields, extraFormat = {}) {
+ const format = { ...extraFormat }
+ fields.forEach(field => {
+ format[field] = { decimalPlaces: AMOUNT_DECIMAL_SCALE }
+ })
+ return format
+}
--
Gitblit v1.9.3