From 387e7afc33068b758dd5cbef245bb13c85fdc3f5 Mon Sep 17 00:00:00 2001 From: jiangAB Date: Sun, 28 Dec 2025 22:39:07 +0800 Subject: [PATCH] update --- public/map/components/CompanyShorePower.vue | 2 +- public/map/components/ShipShorePower.vue | 21 +- public/map/components/ShorePowerUsage.vue | 13 +- public/map/components/ShorePowerUsageRate.vue | 523 ++++++++++++++++++ .../components/ShorePowerUsageSingleData.vue | 153 +++-- public/map/components/ShowData.vue | 98 +++- public/map/components/cesiumMap.vue | 63 ++- .../components/charts/ComparisonBarChart.vue | 14 +- public/map/index.vue | 68 ++- src/types/shorepower.d.ts | 22 + 10 files changed, 891 insertions(+), 86 deletions(-) create mode 100644 public/map/components/ShorePowerUsageRate.vue diff --git a/public/map/components/CompanyShorePower.vue b/public/map/components/CompanyShorePower.vue index d77acdc..7d40741 100644 --- a/public/map/components/CompanyShorePower.vue +++ b/public/map/components/CompanyShorePower.vue @@ -418,7 +418,7 @@ const handGetDeviceData = (deviceId: number | number[], range: 'realtime' | 'day // If deviceId is a single number, get its measure value const deviceData = deviceDataMap.value.get(deviceId); const startData = rangData.find(item => item.deviceId === deviceId) - console.log(deviceData, startData) + if (deviceData?.measureValue) { totalValue = deviceData.measureValue; } diff --git a/public/map/components/ShipShorePower.vue b/public/map/components/ShipShorePower.vue index 99f8d62..950b1d2 100644 --- a/public/map/components/ShipShorePower.vue +++ b/public/map/components/ShipShorePower.vue @@ -17,7 +17,7 @@
-
{{ shipTotalData.berthingShips }}
+
{{ shipTotalData.allPortAreaCount }}
在港船舶
@@ -127,7 +127,7 @@
名称: {{ selectedShip.shipBasicInfo.name + '-' + selectedShip.shipBasicInfo.nameEn - }} + }}
长度: @@ -169,7 +169,7 @@
靠泊类型: {{ getOperationTypeLabel(selectedShip.shorePowerAndShip.type, BERTH_TYPE) - }} + }}
靠泊时间: @@ -237,7 +237,7 @@ {{ getOperationTypeLabel(selectedShip.applyInfo?.arrivalHarborDistrict, harborDistrictIdAndNameList) - }} + }} @@ -292,7 +292,7 @@ {{ getOperationTypeLabel(selectedShip.applyInfo?.loadingCargoCategory, CARGO_CATEGORY) || '-' - }} + }} @@ -314,7 +314,7 @@ {{ getOperationTypeLabel(selectedShip.applyInfo?.unloadingCargoCategory, CARGO_CATEGORY) || '-' - }} + }} @@ -343,7 +343,7 @@ {{ getOperationTypeLabel(selectedShip.applyInfo?.reason, UNUSED_SHORE_POWER_REASON) || '-' - }} + }} @@ -535,13 +535,13 @@ {{ selectedShip.shipBasicInfo?.length !== undefined ? selectedShip.shipBasicInfo?.length : '-' - }} + }} {{ selectedShip.shipBasicInfo?.width !== undefined ? selectedShip.shipBasicInfo?.width : '-' - }} + }} @@ -550,7 +550,7 @@ {{ selectedShip.shipBasicInfo?.tonnage !== undefined ? selectedShip.shipBasicInfo?.tonnage : '-' - }} + }} @@ -621,6 +621,7 @@ interface Props { realtimeDeviceData: RealtimeDeviceData[]; realtimeDeviceDataTime: string; shipTotalData: { + allPortAreaCount: number; berthingShips: number; shorePowerShips: number; noShorePowerShips: number; diff --git a/public/map/components/ShorePowerUsage.vue b/public/map/components/ShorePowerUsage.vue index ad1d887..b949f3b 100644 --- a/public/map/components/ShorePowerUsage.vue +++ b/public/map/components/ShorePowerUsage.vue @@ -284,6 +284,7 @@ interface Props { activeHeadGroup?: number; handleGoBack: () => void; realtimeDeviceDataTime: string; + initialTimeRange?: string; } const props = defineProps() @@ -753,7 +754,9 @@ const getHistoryChartData = (cardId: string): ChartDataItem[] => { } // 时间范围选项 -const timeRange = ref<'realtime' | 'day' | 'month' | 'quarter' | 'year'>('day') +const timeRange = ref<'realtime' | 'day' | 'month' | 'quarter' | 'year'>( + (props.initialTimeRange as 'realtime' | 'day' | 'month' | 'quarter' | 'year') || 'day' +) // 时间范围选项定义 const timeRangeOptions = [ @@ -1049,6 +1052,14 @@ watch(() => props.activeHeadGroup, (newVal) => { } }, { immediate: true }) +// 监听 initialTimeRange 变化,当父组件传递新的时间范围时更新当前时间范围 +watch(() => props.initialTimeRange, (newVal) => { + console.log('newVal', newVal) + if (newVal) { + timeRange.value = newVal as 'realtime' | 'day' | 'month' | 'year' + } +}) + // 组件销毁前清除定时器 onBeforeUnmount(() => { if (cardSelectedHandler) { diff --git a/public/map/components/ShorePowerUsageRate.vue b/public/map/components/ShorePowerUsageRate.vue new file mode 100644 index 0000000..d01f01c --- /dev/null +++ b/public/map/components/ShorePowerUsageRate.vue @@ -0,0 +1,523 @@ + + + + + \ No newline at end of file diff --git a/public/map/components/ShorePowerUsageSingleData.vue b/public/map/components/ShorePowerUsageSingleData.vue index 5500b33..be5b90b 100644 --- a/public/map/components/ShorePowerUsageSingleData.vue +++ b/public/map/components/ShorePowerUsageSingleData.vue @@ -13,6 +13,11 @@
{{ startTimeDisplay }} 至 {{ realtimeDeviceDataTime }}
+ {{timeRangeOptions.find(option => option.value === timeRange)?.label || ''}}量:
{{ chartData[timeRange][card.value] }}
@@ -28,52 +33,61 @@
-
+
年环比 - - {{ getYearlyData[0].growthRate >= 0 ? '↑' : '↓' }} - {{ (getYearlyData[0].growthRate * 100).toFixed(1) }}% -
-
+
- 月环比 - - {{ 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 @@