From 4243f25a01f4e79b3f83218dfcbe94d9befee43d Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 20 十月 2025 09:59:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_7004' into dev_7004
---
src/utils/summarizeTable.js | 72 ++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 27 deletions(-)
diff --git a/src/utils/summarizeTable.js b/src/utils/summarizeTable.js
index 3b3a178..1ad480d 100644
--- a/src/utils/summarizeTable.js
+++ b/src/utils/summarizeTable.js
@@ -6,34 +6,52 @@
* @returns {Array} 鍚堣琛屾暟鎹�
*/
const summarizeTable = (param, summaryProps, specialFormat = {}) => {
- const { columns, data } = param;
- const sums = [];
- columns.forEach((column, index) => {
- if (index === 0) {
- sums[index] = '鍚堣';
- return;
- }
- const prop = column.property;
- if (summaryProps.includes(prop)) {
- const values = data.map(item => Number(item[prop]));
- // 鍙鏈夋晥鏁板瓧杩涜姹傚拰
- if (!values.every(isNaN)) {
- const sum = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0);
- if (specialFormat[prop] && specialFormat[prop].noDecimal) {
- // 濡傛灉鎸囧畾浜嗕笉闇�瑕佷繚鐣欏皬鏁帮紝鍒欑洿鎺ヨ浆鎹负鏁存暟
- sums[index] = Math.round(sum).toString();
- } else {
- // 榛樿淇濈暀涓や綅灏忔暟
- sums[index] = parseFloat(sum).toFixed(specialFormat[prop]?.decimalPlaces ?? 2);
- }
- } else {
- sums[index] = '';
- }
+ const { columns, data } = param;
+ const sums = [];
+ columns.forEach((column, index) => {
+ if (index === 0) {
+ sums[index] = "鍚堣";
+ return;
+ }
+ const prop = column.property;
+ if (summaryProps.includes(prop)) {
+ const values = data.map((item) => Number(item[prop]));
+ // 鍙鏈夋晥鏁板瓧杩涜姹傚拰
+ if (!values.every(isNaN)) {
+ const sum = values.reduce(
+ (acc, val) => (!isNaN(val) ? acc + val : acc),
+ 0
+ );
+ if (specialFormat[prop] && specialFormat[prop].noDecimal) {
+ // 濡傛灉鎸囧畾浜嗕笉闇�瑕佷繚鐣欏皬鏁帮紝鍒欑洿鎺ヨ浆鎹负鏁存暟
+ sums[index] = Math.round(sum).toString();
} else {
- sums[index] = '';
+ // 榛樿淇濈暀涓や綅灏忔暟
+ sums[index] = parseFloat(sum).toFixed(
+ specialFormat[prop]?.decimalPlaces ?? 2
+ );
}
- });
- return sums;
+ } else {
+ sums[index] = "";
+ }
+ } else {
+ sums[index] = "";
+ }
+ });
+ return sums;
+};
+// 涓嶅惈绋庢�讳环璁$畻
+const calculateTaxExclusiveTotalPrice = (taxInclusiveTotalPrice, taxRate) => {
+ const taxRateDecimal = taxRate / 100;
+ return (taxInclusiveTotalPrice / (1 + taxRateDecimal)).toFixed(2);
+};
+// 鍚◣鎬讳环璁$畻
+const calculateTaxIncludeTotalPrice = (taxInclusiveUnitPrice, quantity) => {
+ return (taxInclusiveUnitPrice * quantity).toFixed(2);
};
// 瀵煎嚭鍑芥暟渚涘叾浠栨枃浠朵娇鐢�
-export { summarizeTable };
\ No newline at end of file
+export {
+ summarizeTable,
+ calculateTaxExclusiveTotalPrice,
+ calculateTaxIncludeTotalPrice,
+};
--
Gitblit v1.9.3