From ff1f5b4cab1b5cc15e7cbc2d0985e316b50cf2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E6=A0=A1=E4=BA=91?= <14135925+chenxilxy@user.noreply.gitee.com> Date: Thu, 5 Mar 2026 15:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ContactInformation/index.ts | 16 ++ src/router/index.ts | 19 ++ src/utils/auxiliaryFunction/index.ts | 23 +- .../components/DailyDataBreakdown.vue | 199 ++++++++++++++++ .../components/DataTrendChart.vue | 224 ++++++++++++++++++ .../DataStatistics/components/TaskDetails.vue | 7 + .../DataStatistics/components/TaskForm.vue | 110 +++++++++ src/views/DataStatistics/index.vue | 197 +++++++++++++++ 8 files changed, 791 insertions(+), 4 deletions(-) create mode 100644 src/views/DataStatistics/components/DailyDataBreakdown.vue create mode 100644 src/views/DataStatistics/components/DataTrendChart.vue create mode 100644 src/views/DataStatistics/components/TaskDetails.vue create mode 100644 src/views/DataStatistics/components/TaskForm.vue create mode 100644 src/views/DataStatistics/index.vue diff --git a/src/api/ContactInformation/index.ts b/src/api/ContactInformation/index.ts index e82af21..22bb35a 100644 --- a/src/api/ContactInformation/index.ts +++ b/src/api/ContactInformation/index.ts @@ -31,3 +31,19 @@ export const ApiContactsExport = (data: any) => { method: 'get' }) } + +// 获取总览统计数据 +export const ApiStats = (data: any) => { + return request({ + url: `/api/stats?period=${data.period}`, + method: 'get' + }) +} + +// 获取总览统计数据 +export const ApiStatsDaily = (data: any) => { + return request({ + url: `/api/stats/daily?days=${data.days}`, + method: 'get' + }) +} diff --git a/src/router/index.ts b/src/router/index.ts index 354d203..3303bca 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -324,6 +324,25 @@ export const constantRoutes: RouteRecordRaw[] = [ } } ] + }, + { + path: '/data', + name: 'Data', + component: Layout, + meta: { + title: '数据统计', + icon: 'setting' + }, + children: [ + { + path: 'dataStatistics', + name: 'DataStatistics', + component: () => import('@/views/DataStatistics/index.vue'), + meta: { + title: '数据统计' + } + } + ] } // 注册平台登记 // { diff --git a/src/utils/auxiliaryFunction/index.ts b/src/utils/auxiliaryFunction/index.ts index f352645..8fc229f 100644 --- a/src/utils/auxiliaryFunction/index.ts +++ b/src/utils/auxiliaryFunction/index.ts @@ -187,11 +187,19 @@ export function deepCloneByJSON(obj: any) { } /** - * 将 ISO 8601 时间格式转换为年月日时分秒格式 + * 将 ISO 8601 时间格式转换为指定格式 * @param isoString ISO 8601 格式的时间字符串,如 "2026-02-28T14:10:51.966269" - * @returns 格式化后的时间字符串,如 "2026-02-28 14:10:51" + * @param format 格式化模板,默认 'YYYY-MM-DD HH:mm:ss' + * @returns 格式化后的时间字符串 + * + * @example + * formatISOToDateTime('2026-02-28T14:10:51.966269') // '2026-02-28 14:10:51' + * formatISOToDateTime('2026-02-28T14:10:51.966269', 'YYYY-MM-DD') // '2026-02-28' + * formatISOToDateTime('2026-02-28T14:10:51.966269', 'YYYY/MM/DD HH:mm') // '2026/02/28 14:10' + * formatISOToDateTime('2026-02-28T14:10:51.966269', 'MM-DD HH:mm') // '02-28 14:10' + * formatISOToDateTime('2026-02-28T14:10:51.966269', 'YYYY 年 MM 月 DD 日') // '2026 年 02 月 28 日' */ -export function formatISOToDateTime(isoString: string): string { +export function formatISOToDateTime(isoString: string, format = 'YYYY-MM-DD HH:mm:ss'): string { if (!isoString) return '' try { @@ -210,7 +218,14 @@ export function formatISOToDateTime(isoString: string): string { const minutes = String(date.getMinutes()).padStart(2, '0') const seconds = String(date.getSeconds()).padStart(2, '0') - return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` + // 替换格式化模板中的占位符 + return format + .replace('YYYY', String(year)) + .replace('MM', month) + .replace('DD', day) + .replace('HH', hours) + .replace('mm', minutes) + .replace('ss', seconds) } catch (error) { console.error('日期格式化错误:', error) return isoString diff --git a/src/views/DataStatistics/components/DailyDataBreakdown.vue b/src/views/DataStatistics/components/DailyDataBreakdown.vue new file mode 100644 index 0000000..956a8d8 --- /dev/null +++ b/src/views/DataStatistics/components/DailyDataBreakdown.vue @@ -0,0 +1,199 @@ + + + + diff --git a/src/views/DataStatistics/components/DataTrendChart.vue b/src/views/DataStatistics/components/DataTrendChart.vue new file mode 100644 index 0000000..3b5e48e --- /dev/null +++ b/src/views/DataStatistics/components/DataTrendChart.vue @@ -0,0 +1,224 @@ + + + + + diff --git a/src/views/DataStatistics/components/TaskDetails.vue b/src/views/DataStatistics/components/TaskDetails.vue new file mode 100644 index 0000000..13d026b --- /dev/null +++ b/src/views/DataStatistics/components/TaskDetails.vue @@ -0,0 +1,7 @@ + + + + + diff --git a/src/views/DataStatistics/components/TaskForm.vue b/src/views/DataStatistics/components/TaskForm.vue new file mode 100644 index 0000000..f3586b5 --- /dev/null +++ b/src/views/DataStatistics/components/TaskForm.vue @@ -0,0 +1,110 @@ + + + + + diff --git a/src/views/DataStatistics/index.vue b/src/views/DataStatistics/index.vue new file mode 100644 index 0000000..5909dba --- /dev/null +++ b/src/views/DataStatistics/index.vue @@ -0,0 +1,197 @@ + + + +