From ce1658eb1c17ba7e8fe3f0a21771b4af5ccee8cd Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 14 十一月 2024 10:33:13 +0800 Subject: [PATCH] 三种布局方式 --- src/utils/util.ts | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/utils/util.ts b/src/utils/util.ts index 0ec84b8..830c686 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -214,7 +214,6 @@ ) => { if (!treeData || treeData.length === 0) return; if (!parent) parent = treeData; - for (let index = 0; index < treeData.length; index++) { const value = treeData[index] as any; if (markParent) { @@ -233,7 +232,7 @@ if (value[childrenKey] && value[childrenKey].length !== 0) { // 閫掑綊璺冲嚭 - const callResult = travelTree(value[childrenKey], callback, value, markParent); + const callResult = travelTree(value[childrenKey], callback, value, markParent, childrenKey); if (callResult) { return true; } @@ -464,12 +463,14 @@ * 鏈�杩� n 澶╃殑 startDate銆乪ndDate * @param dates */ -export const getRecentDateRange = (dates: number) => { +export const getRecentDateRange = (dates: number, includesCurrent = true) => { + dates = includesCurrent ? dates - 1 : dates; // 鑾峰彇褰撳墠鏃ユ湡 const endDate = new Date(); const startDate = new Date(); startDate.setTime(startDate.getTime() - 3600 * 1000 * 24 * dates); startDate.setHours(0, 0, 0, 0); + endDate.setHours(23,59,59,59) return [startDate, endDate]; }; @@ -706,7 +707,9 @@ */ export const toMyFixed = (num, precision) => { if (num == null) return ''; - return num.toFixed(precision).replace(/\.?0+$/, ''); + if (!precision) return num + ''; + const factor = Math.pow(10, precision); + return Math.round(Number(num) * factor) / factor + ''; }; type GetTextWidthOption = { @@ -742,5 +745,3 @@ } return decodedData; } - - -- Gitblit v1.9.3