From 3d34172c587fafd1c9cf2c11a899d1ecf6c9a5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E5=87=AF?= <2448379534@qq.com> Date: Thu, 2 Apr 2026 09:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9D=97=EF=BC=9A?= =?UTF-8?q?=E7=94=9F=E6=80=81=E6=B5=81=E9=87=8F=E6=B3=84=E6=94=BE=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=EF=BC=8C=E6=B3=84=E6=94=BE=E6=96=B9=E5=BC=8F=E5=88=86?= =?UTF-8?q?=E5=B8=83=E6=83=85=E5=86=B5=EF=BC=8C=E6=A8=A1=E5=9D=97=E7=94=9F?= =?UTF-8?q?=E6=80=81=E6=B5=81=E9=87=8F=E8=BE=BE=E6=A0=87=E6=83=85=E5=86=B5?= =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/ecoFlow/index.ts | 14 + frontend/src/api/ecoFlow/types.ts | 12 + .../xieFangFangShi/index.vue | 194 +++++++++ .../xieFangFenBu/index.vue | 386 ++++++++++++++++++ .../modules/shengtaidabiaoTwoMod/index.vue | 133 ++++-- .../shengTaiLiuLiangXieFangSheShi.vue | 38 +- 6 files changed, 743 insertions(+), 34 deletions(-) create mode 100644 frontend/src/api/ecoFlow/index.ts create mode 100644 frontend/src/api/ecoFlow/types.ts create mode 100644 frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFangShi/index.vue create mode 100644 frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFenBu/index.vue diff --git a/frontend/src/api/ecoFlow/index.ts b/frontend/src/api/ecoFlow/index.ts new file mode 100644 index 0000000..d7319b2 --- /dev/null +++ b/frontend/src/api/ecoFlow/index.ts @@ -0,0 +1,14 @@ +import request from '@/utils/request'; +import type { EcoFlowStandard, EcoFlowQueryParams } from './types'; + +/** + * 获取生态流量达标情况数据 + * @param params 查询参数 + */ +export function getEcoFlowStandardData(params?: EcoFlowQueryParams): Promise<{ data: EcoFlowStandard[] }> { + return request({ + url: '/api/eco-flow/standard', + method: 'get', + params + }); +} diff --git a/frontend/src/api/ecoFlow/types.ts b/frontend/src/api/ecoFlow/types.ts new file mode 100644 index 0000000..4f8adf2 --- /dev/null +++ b/frontend/src/api/ecoFlow/types.ts @@ -0,0 +1,12 @@ +export interface EcoFlowStandard { + id: number; + baseName: string; + category: string; + currentRate: number; + lastYearRate: number; +} + +export interface EcoFlowQueryParams { + mode?: 'top' | 'left'; + baseId?: number; +} diff --git a/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFangShi/index.vue b/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFangShi/index.vue new file mode 100644 index 0000000..a2585f7 --- /dev/null +++ b/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFangShi/index.vue @@ -0,0 +1,194 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFenBu/index.vue b/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFenBu/index.vue new file mode 100644 index 0000000..a404429 --- /dev/null +++ b/frontend/src/modules/shengTaiLiuLiangXieFangSheShiMod/xieFangFenBu/index.vue @@ -0,0 +1,386 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/modules/shengtaidabiaoTwoMod/index.vue b/frontend/src/modules/shengtaidabiaoTwoMod/index.vue index e829b86..2816903 100644 --- a/frontend/src/modules/shengtaidabiaoTwoMod/index.vue +++ b/frontend/src/modules/shengtaidabiaoTwoMod/index.vue @@ -19,7 +19,6 @@ import { ref, onMounted, watch } from 'vue'; import SidePanelItem from '@/components/SidePanelItem/index.vue'; import * as echarts from 'echarts'; - // 定义组件名(便于调试和递归) defineOptions({ name: 'shengtaidabiaoMod' @@ -34,18 +33,45 @@ const spinning = ref(false) const chartRef = ref(null); let chartInstance: echarts.ECharts | null = null; -// 模拟数据 -const categoryData = [ - '其他', '闽浙赣', '澜沧江干流', '东北', '南盘江·红水河', - '黄河中游干流', '黄河上游干流', '湘西', '长江上游干流', - '乌江干流', '大渡河干流', '雅砻江干流', '金沙江干流' -]; -const currentData = Array(13).fill(0).map(() => Math.random() * 5 + 86); -const lastYearData = Array(13).fill(0).map(() => Math.random() * 5 + 86); +// 按基地的静态数据(横向柱形图) +const baseData = { + categories: ['金沙江干流', '雅砻江干流', '大渡河干流', '乌江干流', '长江上游干流', '湘西', '黄河上游干流', '黄河中游干流', '南盘江 - 红水河', '东北', '澜沧江干流', '闽浙赣', '其他'], + currentData: [98, 100, 99.5, 99.8, 100, 98.5, 100, 100, 100, 97, 100, 93, 98], + lastYearData: [92, 100, 99, 100, 100, 98, 100, 100, 100, 100, 100, 88, 93] +}; + +// 按调节性能的静态数据(竖向柱状图) +const performanceData = { + categories: ['多年调节', '年调节', '季调节', '周调节', '其他'], + currentData: [95, 92, 88, 85, 90], + lastYearData: [93, 90, 85, 82, 88] +}; + +// 加载数据 +const loadData = () => { + spinning.value = true; + + // 模拟数据加载延迟,并确保 DOM 已渲染 + setTimeout(() => { + initChart(); + spinning.value = false; + }, 50); +}; // 初始化图表 const initChart = () => { - if (!chartRef.value) return; + if (!chartRef.value) { + console.error('图表容器未渲染'); + return; + } + + // 检查容器尺寸 + const containerHeight = chartRef.value.offsetHeight; + if (!containerHeight || containerHeight === 0) { + console.warn('容器高度为 0,延迟重试'); + setTimeout(() => initChart(), 50); + return; + } // 如果实例存在,先销毁 if (chartInstance) { @@ -54,6 +80,10 @@ const initChart = () => { chartInstance = echarts.init(chartRef.value); + // 根据 mode 选择数据 + const data = mode.value === 'top' ? baseData : performanceData; + const isHorizontal = mode.value === 'top'; + const option = { tooltip: { trigger: 'axis', @@ -80,16 +110,16 @@ const initChart = () => { } }, grid: { - left: '3%', - right: '4%', - bottom: '3%', - top: '50', + left: isHorizontal ? '3%' : '10%', + right: isHorizontal ? '4%' : '4%', + bottom: isHorizontal ? '3%' : '10%', + top: isHorizontal ? '50' : '60', containLabel: true }, dataZoom: [ { type: 'inside', - xAxisIndex: 0, + [isHorizontal ? 'yAxisIndex' : 'xAxisIndex']: 0, filterMode: 'empty', zoomOnMouseWheel: true, moveOnMouseMove: false, @@ -97,10 +127,10 @@ const initChart = () => { start: 0, end: 100, minValueSpan: 0, - maxValueSpan: 20 + maxValueSpan: isHorizontal ? 20 : 5 } ], - xAxis: { + xAxis: isHorizontal ? { type: 'value', min: 80, max: 100, @@ -115,11 +145,9 @@ const initChart = () => { color: '#666', formatter: '{value}' } - }, - yAxis: { + } : { type: 'category', - data: categoryData, - inverse: true, + data: data.categories, axisLabel: { color: '#666', fontSize: 12, @@ -143,36 +171,83 @@ const initChart = () => { show: false } }, + yAxis: isHorizontal ? { + type: 'category', + data: data.categories, + inverse: true, + axisLabel: { + color: '#666', + fontSize: 12, + interval: 0, + rotate: 45, + margin: 10 + }, + axisLine: { + show: true, + lineStyle: { + color: '#666' + } + }, + axisTick: { + show: true, + lineStyle: { + color: '#666' + } + }, + splitLine: { + show: false + } + } : { + type: 'value', + min: 0, + max: 100, + splitLine: { + show: true, + lineStyle: { + color: '#E8E8E8', + type: 'solid' + } + }, + axisLabel: { + color: '#666', + formatter: '{value}' + } + }, series: [ { name: '当前', type: 'bar', - data: currentData, + data: data.currentData, itemStyle: { color: '#5470C6' }, - barWidth: 12, + barWidth: isHorizontal ? 6 : 10, barGap: '30%' }, { name: '去年同期', type: 'bar', - data: lastYearData, + data: data.lastYearData, itemStyle: { color: '#91CC75' }, - barWidth: 12, + barWidth: isHorizontal ? 6 : 10, barGap: '30%' } ] }; chartInstance.setOption(option); + + // 强制重绘,确保尺寸正确 + setTimeout(() => { + chartInstance?.resize(); + }, 0); }; // 页面加载时执行的逻辑 onMounted(() => { - initChart(); + loadData(); // 监听窗口大小变化 window.addEventListener('resize', () => { @@ -182,16 +257,12 @@ onMounted(() => { // 监听 mode 变化 watch(mode, () => { - // 这里可以根据 mode 的值重新加载数据 - initChart(); + loadData(); });