From a6d6eb116a63e9b53244699fd6f9fe919c304e91 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期日, 03 十一月 2024 16:57:27 +0800 Subject: [PATCH] 提交代码 --- src/utils/util.ts | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/utils/util.ts b/src/utils/util.ts index c449200..830c686 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -1,11 +1,11 @@ import { ElMessage, ElMessageBox } from 'element-plus'; import JSONbig from 'json-bigint'; + import { storeToRefs } from 'pinia'; import { unref, type Ref } from 'vue'; import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes'; import { useThemeConfig } from '/@/stores/themeConfig'; import request from '/@/utils/request'; - /** * @description 褰撶鍒� JSON 涓瓨鍦ㄨ繃闀跨殑鏁板瓧鏃讹紝浣跨敤 JSONbigString 瑙f瀽锛屾暟瀛椾細杞负瀛楃涓插鐞� * 鐢ㄦ硶锛欽SONbigString.parse(jsonStr)锛� @@ -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; } @@ -258,7 +257,7 @@ * @param tableData * @returns */ -export const flatten = (tableData: any[], removeChild?: boolean, children = 'Children'): any[] => { +export const flatten = (tableData: any[], removeChild?: boolean, children = 'children'): any[] => { const flattenedData: any[] = []; for (const item of tableData) { @@ -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,9 +707,10 @@ */ 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 = { size?: string; @@ -735,12 +737,11 @@ return width; } - export function decodeFormData(formDataString) { const params = new URLSearchParams(formDataString); const decodedData = {}; for (const [key, value] of params) { - decodedData[key] = decodeURIComponent(value); + decodedData[key] = decodeURIComponent(value); } return decodedData; - } \ No newline at end of file +} -- Gitblit v1.9.3