From 2ffb9f460e73eb28980c7d19b7cec417c942f750 Mon Sep 17 00:00:00 2001
From: gerson <1405270578@qq.com>
Date: 星期日, 22 十二月 2024 17:58:51 +0800
Subject: [PATCH] 一次性同步测试

---
 src/utils/util.ts |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/src/utils/util.ts b/src/utils/util.ts
index 093d5d7..d92279e 100644
--- a/src/utils/util.ts
+++ b/src/utils/util.ts
@@ -547,6 +547,7 @@
 	const endDate = new Date();
 	const startDate = new Date();
 	startDate.setTime(startDate.getTime() - 3600 * 1000 * 24 * dates);
+	endDate.setHours(23,59,59,59)
 	startDate.setHours(0, 0, 0, 0);
 	return [startDate, endDate];
 };
@@ -620,11 +621,28 @@
 
 export const toPercent = (num: number, havePercentSymbol = true, decimalPlaces = 1, defaultValue = '-') => {
 	if (num == null) return `${defaultValue} %`;
-	let percent = Number(num * 100).toFixed(decimalPlaces);
+	const factor = Math.pow(10, decimalPlaces);
+
+	let percent = Math.round(Number(num) * 100 * factor) / factor + '';
 	if (havePercentSymbol) {
 		percent += '%';
 	}
 	return percent;
+};
+
+
+
+/**
+ * 淇濈暀鎸囧畾绮惧害灏忔暟浣嶏紝涓斾笉琛ラ浂
+ * @param num
+ * @param precision
+ * @returns
+ */
+export const toMyFixed = (num, precision) => {
+	if (num == null) return '';
+	if (!precision) return num + '';
+	const factor = Math.pow(10, precision);
+	return Math.round(Number(num) * factor) / factor + '';
 };
 
 /**
@@ -723,3 +741,12 @@
 	document.body.removeChild(spanEle);
 	return width;
 }
+
+export function decodeFormData(formDataString) {
+	const params = new URLSearchParams(formDataString);
+	const decodedData = {};
+	for (const [key, value] of params) {
+		decodedData[key] = decodeURIComponent(value);
+	}
+	return decodedData;
+}

--
Gitblit v1.9.3