From 73c84f7b8d40863de4ed7ac7f59f10635be87d3e Mon Sep 17 00:00:00 2001 From: lbw_9527443 <780139497@qq.com> Date: Tue, 14 Oct 2025 17:43:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(PerformanceComparison):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=80=A7=E8=83=BD=E5=AF=B9=E6=AF=94=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=92=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构表格样式,改进视觉层次和交互效果 - 调整变化值显示格式,将百分比和差值分开显示 - 增加表格行的悬停效果和斑马纹 - 改进数值格式化函数,添加单位显示 - 增强选择器交互效果和样式 - 添加NaN检查防止计算错误 --- .../components/PerformanceComparison.vue | 188 ++++++++++++------ 1 file changed, 127 insertions(+), 61 deletions(-) diff --git a/my-vue-app/src/views/senorManger/components/PerformanceComparison.vue b/my-vue-app/src/views/senorManger/components/PerformanceComparison.vue index a6b694e..c3b2024 100644 --- a/my-vue-app/src/views/senorManger/components/PerformanceComparison.vue +++ b/my-vue-app/src/views/senorManger/components/PerformanceComparison.vue @@ -25,26 +25,27 @@ - + - + - + - @@ -174,7 +175,9 @@ const comparedMetrics = computed(() => { }); const calculateChange = (current, previous) => { - if (previous === null || previous === undefined) return { diff: 'N/A', percentage: 'N/A', trend: 'neutral' }; + if (previous === null || previous === undefined || isNaN(current) || isNaN(previous)) { + return { diff: 'N/A', percentage: 'N/A', trend: 'neutral' }; + } const diff = current - previous; let percentage; @@ -195,7 +198,7 @@ const calculateChange = (current, previous) => { const formatValue = (value, unit) => { if (value === null || value === undefined) return '-'; if (unit === '分钟') { - return Math.round(value / 60); // 将秒转换为分钟 + return `${Math.round(value / 60)} 分钟`; } if (unit === '%') { return `${value.toFixed(1)}%`; @@ -205,57 +208,79 @@ const formatValue = (value, unit) => { const formatChange = (diff, unit) => { if (typeof diff !== 'number') return ''; - const formattedDiff = formatValue(Math.abs(diff), unit); - return `${diff > 0 ? '+' : '-'}${formattedDiff}`; + const prefix = diff > 0 ? '+' : '-'; + const absDiff = Math.abs(diff); + + if (unit === '分钟') { + return `${prefix}${Math.round(absDiff / 60)} 分钟`; + } + if (unit === '%') { + return `${prefix}${absDiff.toFixed(1)}%`; + } + return `${prefix}${absDiff.toLocaleString()}`; }; const getChangeClass = (trend) => { - if (trend === 'up') return 'text-positive'; - if (trend === 'down') return 'text-negative'; - return 'text-neutral'; + if (trend === 'up') return 'positive'; + if (trend === 'down') return 'negative'; + return 'neutral'; };
核心指标核心指标 本期数据 {{ selectedPeriodLabel }}数据变化情况变化情况
{{ metric.label }} + {{ metric.label }} + {{ formatValue(metric.current, metric.unit) }} {{ formatValue(metric.previous, metric.unit) }} -
- - {{ formatChange(metric.change.diff, metric.unit) }} - ({{ metric.change.percentage }}) +
+
+ + + + {{ metric.change.percentage }} - - - - + {{ formatChange(metric.change.diff, metric.unit) }}