From 02ecd75c6ba81122086b9cf75a2cf6d703eb3020 Mon Sep 17 00:00:00 2001 From: 张诺 <zhang_12370@163.com> Date: 星期五, 23 五月 2025 18:01:18 +0800 Subject: [PATCH] 采购管理>供应商往来=>书写页面样式以及页面交互逻辑 采购管理>付款登记=>编辑无登记人问题 --- src/utils/summarizeTable.js | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/utils/summarizeTable.js b/src/utils/summarizeTable.js index 6013def..ae6e975 100644 --- a/src/utils/summarizeTable.js +++ b/src/utils/summarizeTable.js @@ -1,12 +1,11 @@ /** * 閫氱敤鐨勮〃鏍煎悎璁℃柟娉� - * @param {Object} param - * @param {Array} param.columns 琛ㄦ牸鍒楅厤缃� - * @param {Array} param.data 鏁版嵁婧� - * @param {Array<string>} summaryProps 闇�瑕佹眹鎬荤殑瀛楁鍚嶆暟缁� + * @param {Object} param - 鍖呭惈琛ㄦ牸鍒楅厤缃拰鏁版嵁婧愮殑瀵硅薄 + * @param {Array<string>} summaryProps - 闇�瑕佹眹鎬荤殑瀛楁鍚嶆暟缁� + * @param {Object} specialFormat - 鐗规畩鏍煎紡鍖栬鍒欙細瀛楁鍚� -> 鏍煎紡鍖栭�夐」锛堝鏄惁鍘绘帀灏忔暟锛� * @returns {Array} 鍚堣琛屾暟鎹� */ -const summarizeTable = (param, summaryProps) => { +const summarizeTable = (param, summaryProps, specialFormat = {}) => { const { columns, data } = param; const sums = []; columns.forEach((column, index) => { @@ -20,7 +19,13 @@ // 鍙鏈夋晥鏁板瓧杩涜姹傚拰 if (!values.every(isNaN)) { const sum = values.reduce((acc, val) => (!isNaN(val) ? acc + val : acc), 0); - sums[index] = parseFloat(sum).toFixed(2); + 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] = ''; } @@ -29,7 +34,10 @@ } }); return sums; -}; - +} +const calculateTaxExclusiveTotalPrice = (taxInclusiveTotalPrice, taxRate) => { + const taxRateDecimal = taxRate / 100; + return (taxInclusiveTotalPrice / (1 + taxRateDecimal)).toFixed(2); +} // 瀵煎嚭鍑芥暟渚涘叾浠栨枃浠朵娇鐢� -export { summarizeTable }; \ No newline at end of file +export { summarizeTable, calculateTaxExclusiveTotalPrice }; \ No newline at end of file -- Gitblit v1.9.3