From 68b9c5fa5ee50782b5449fd7d13ec0beeac4f2ab Mon Sep 17 00:00:00 2001 From: zhongzm Date: Thu, 28 Nov 2024 18:45:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E7=B4=AF=E5=8A=A0?= =?UTF-8?q?=E5=80=BC=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 1 + src/i18n/locales/zh-CN.ts | 1 + src/views/perfManage/kpiOverView/index.vue | 26 ++++++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index de715fb2..5566b4da 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -1111,6 +1111,7 @@ export default { "maxValue":"Max Value", "minValue":"Min Value", "avgValue":"Average Value", + "totalValue":"Worth Value", "kpiChartTitle":"Overview of NE metrics", "changeLine":"Change to Line Charts", "changeBar":"Change to Bar Charts", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index d65403f0..5a77cb6b 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -1111,6 +1111,7 @@ export default { "maxValue":"最大值", "minValue":"最小值", "avgValue":"平均值", + "totalValue":"总值", "kpiChartTitle":"网元指标概览", "changeLine":"切换为折线图", "changeBar":"切换为柱状图", diff --git a/src/views/perfManage/kpiOverView/index.vue b/src/views/perfManage/kpiOverView/index.vue index b7a900e3..5998c22e 100644 --- a/src/views/perfManage/kpiOverView/index.vue +++ b/src/views/perfManage/kpiOverView/index.vue @@ -14,7 +14,6 @@ import { OptionsType, WS } from '@/plugins/ws-websocket'; import { generateColorRGBA } from '@/utils/generate-utils'; import { LineOutlined } from '@ant-design/icons-vue'; import { TableColumnType } from 'ant-design-vue'; -import { viewTransitionTheme } from 'antdv-pro-layout'; const { t, currentLocale } = useI18n(); //定义KPI接口 interface KPIBase{ @@ -394,7 +393,7 @@ const themeObserver = new MutationObserver(() => { extraCssText: 'box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);' }, // 重新设置系列数据 - series + series }; // 使用新的配置更新图表 @@ -564,7 +563,7 @@ const updateChart = () => { ? '#CACADA' : '#333' }, - // 添加自���计算的分割段数 + // 添加自计算的分割段数 splitNumber: 5, // 添加自动计算的最小/最大值范围 scale: true, @@ -745,7 +744,8 @@ interface KPIStats { title: string; max: number; min: number; - avg:number; + avg: number; + total: number; } // 添加计算属性,用于计算每个指标的最大值和最小值 @@ -766,9 +766,12 @@ const updateKpiStats = () => { // 获取该指标的所有数值 const values = chartData.value.map(item => Number(item[kpiId]) || 0); + // 计算总值 + const total = Number(values.reduce((sum, val) => sum + val, 0).toFixed(2)); + // 计算平均值 const avg = values.length > 0 - ? Number((values.reduce((sum, val) => sum + val, 0) / values.length).toFixed(2)) + ? Number((total / values.length).toFixed(2)) : 0; return { @@ -776,7 +779,8 @@ const updateKpiStats = () => { title: kpi.title, max: Math.max(...values), min: Math.min(...values), - avg:avg + avg: avg, + total: total }; }).filter((item): item is KPIStats => item !== null); }; @@ -805,7 +809,7 @@ const statsColumns: TableColumnType[] = [ title: t('views.perfManage.kpiOverView.kpiName'), dataIndex: 'title', key: 'title', - width: '63%', + width: '50%', }, { title: t('views.perfManage.kpiOverView.maxValue'), @@ -830,6 +834,14 @@ const statsColumns: TableColumnType[] = [ width: '12%', sorter: (a: KPIStats, b: KPIStats) => a.avg - b.avg, sortDirections: ['ascend', 'descend'], + }, + { + title: t('views.perfManage.kpiOverView.totalValue'), + dataIndex: 'total', + key: 'total', + width: '12%', + sorter: (a: KPIStats, b: KPIStats) => a.total - b.total, + sortDirections: ['ascend', 'descend'], } ];