+

-
月环比
-
- {{ getMonthlyData[0].growthRate >= 0 ? '↑' : '↓' }}
- {{ (getMonthlyData[0].growthRate * 100).toFixed(1) }}%
-
+
月对比
+
+
+
+
+
-
-
+

-
日环比
-
- {{ getDailyData[0].growthRate >= 0 ? '↑' : '↓' }}
- {{ (getDailyData[0].growthRate * 100).toFixed(1) }}%
-
+
日对比
+
+
+
+
+
-
+
@@ -276,6 +290,7 @@ interface Props {
handleGoBack: () => void;
realtimeDeviceDataTime: string;
comparativeData: ComparativeData;
+ initialTimeRange?: 'realtime' | 'day' | 'month' | 'year';
}
@@ -396,6 +411,38 @@ const getYearlyData = computed(() => {
}]
})
+// 日对比数据(根据对比类型选择环比或同比)
+const getDailyComparisonData = computed(() => {
+ const comparisonData = comparisonType.value === 'yearOnYear'
+ ? props.comparativeData.dayYearOnYear
+ : props.comparativeData.day;
+
+ return [{
+ name: comparisonType.value === 'yearOnYear' ? '本期去年同期对比' : '本期上期对比',
+ growthRate: comparisonData.growthRate,
+ currentValue: convertPowerUsage(comparisonData.current.value, selectedCard.value),
+ previousValue: convertPowerUsage(comparisonData.previous.value, selectedCard.value),
+ currentPeriod: comparisonData.current.period,
+ previousPeriod: comparisonData.previous.period,
+ }]
+})
+
+// 月对比数据(根据对比类型选择环比或同比)
+const getMonthlyComparisonData = computed(() => {
+ const comparisonData = comparisonType.value === 'yearOnYear'
+ ? props.comparativeData.monthYearOnYear
+ : props.comparativeData.month;
+
+ return [{
+ name: comparisonType.value === 'yearOnYear' ? '本期去年同期对比' : '本期上期对比',
+ growthRate: comparisonData.growthRate,
+ currentValue: convertPowerUsage(comparisonData.current.value, selectedCard.value),
+ previousValue: convertPowerUsage(comparisonData.previous.value, selectedCard.value),
+ currentPeriod: comparisonData.current.period,
+ previousPeriod: comparisonData.previous.period,
+ }]
+})
+
// 根据时间范围计算起始时间
const startTimeDisplay = computed(() => {
const now = new Date();
@@ -516,14 +563,6 @@ const chartData = ref({
'nox': 0,
'so2': 0,
},
- 'quarter': {
- 'totalPower': 0,
- 'fuel': 0,
- 'co2': 0,
- 'pm25': 0,
- 'nox': 0,
- 'so2': 0,
- },
'year': {
'totalPower': 0,
'fuel': 0,
@@ -713,18 +752,23 @@ const getHistoryChartData = (cardId: string): ChartDataItem[] => {
}
// 时间范围选项
-const timeRange = ref<'realtime' | 'day' | 'month' | 'year'>('day')
+const timeRange = ref<'day' | 'month' | 'year'>(
+ (props.initialTimeRange === 'realtime' ? 'year' : props.initialTimeRange) || 'day'
+)
+
+// 比较类型选项:chain(环比)或 yearOnYear(同比)
+const comparisonType = ref<'chain' | 'yearOnYear'>('chain')
// 时间范围选项定义
const timeRangeOptions = [
{ value: 'day', label: '当日' },
{ value: 'month', label: '当月' },
{ value: 'year', label: '当年' },
- { value: 'realtime', label: '汇总' },
+ // { value: 'realtime', label: '汇总' },
]
// 处理时间范围选择
-const handleTimeRangeChange = (range: 'realtime' | 'day' | 'month' | 'year') => {
+const handleTimeRangeChange = (range: 'day' | 'month' | 'year') => {
timeRange.value = range
// 这里可以添加根据时间范围切换数据源的逻辑
}
@@ -1032,6 +1076,18 @@ watch(() => props.activeHeadGroup, (newVal) => {
}
}, { immediate: true })
+// 监听 initialTimeRange 变化,当父组件传递新的时间范围时更新当前时间范围
+watch(() => props.initialTimeRange, (newVal) => {
+ console.log('newVal', newVal)
+ if (newVal) {
+ if (newVal === 'realtime') {
+ timeRange.value = 'year'
+ } else {
+ timeRange.value = newVal as 'day' | 'month' | 'year'
+ }
+ }
+})
+
// 组件销毁前清除定时器
onBeforeUnmount(() => {
if (cardSelectedHandler) {
@@ -1083,6 +1139,11 @@ onBeforeUnmount(() => {
height: 100%;
}
+
+ .card .card-title .title-text {
+ width: 120px;
+ }
+
.overview-value {
font-size: 48px;
}
@@ -1180,6 +1241,30 @@ onBeforeUnmount(() => {
margin-right: 4px;
}
+.comparison-type-selector {
+ display: inline-flex;
+ margin: 0 10px;
+ background: rgba(255, 255, 255, 0.1);
+ padding: 2px;
+ border-radius: 4px;
+}
+
+.comparison-type-btn {
+ border: none;
+ background: transparent;
+ color: #ccc;
+ padding: 4px 8px;
+ border-radius: 2px;
+ cursor: pointer;
+ font-size: 14px;
+ transition: all 0.3s;
+
+ &.active {
+ background: #1890ff;
+ color: white;
+ }
+}
+
.right {
/* gap: 0 */
}
diff --git a/public/map/components/ShowData.vue b/public/map/components/ShowData.vue
index ae4c783..f133196 100644
--- a/public/map/components/ShowData.vue
+++ b/public/map/components/ShowData.vue
@@ -1,8 +1,8 @@
-
+
-
+
-
×
@@ -64,7 +64,7 @@
名称:
{{ shipSelectedItem.shipBasicInfo.name + '-' +
shipSelectedItem.shipBasicInfo.nameEn
- }}
+ }}
@@ -173,7 +189,7 @@