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 @@ + + + +