From c402cbf74df6462dd81e4901a0933c4791cbf8c6 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 30 三月 2026 10:56:58 +0800
Subject: [PATCH] 初版进度追踪

---
 src/views/reportAnalysis/unitEnergyConsumption/index.vue |  212 +++++++++++++++++++++--------------------------------
 1 files changed, 84 insertions(+), 128 deletions(-)

diff --git a/src/views/reportAnalysis/unitEnergyConsumption/index.vue b/src/views/reportAnalysis/unitEnergyConsumption/index.vue
index 6aa4912..81d6679 100644
--- a/src/views/reportAnalysis/unitEnergyConsumption/index.vue
+++ b/src/views/reportAnalysis/unitEnergyConsumption/index.vue
@@ -89,53 +89,48 @@
       <el-table :data="tableData"
                 v-loading="tableLoading"
                 border>
-        <el-table-column prop="energyType"
-                         label="鑳借��"
-                         width="100"
-                         align="center">
+        <el-table-column prop="meterReadingDate"
+                         label="鏃ユ湡"
+                         align="center"
+                         width="120" />
+        <el-table-column prop="type"
+                         label="绫诲瀷"
+                         align="center"
+                         width="100">
           <template #default="scope">
-            <el-tag :type="getEnergyTypeType(scope.row.energyType)">
-              {{ scope.row.energyType }}
+            <el-tag :type="scope.row.type === '鐢熶骇' ? 'primary' : 'success'">
+              {{ scope.row.type }}
             </el-tag>
           </template>
         </el-table-column>
-        <el-table-column prop="unit"
-                         label="鍗曚綅"
-                         width="120"
-                         align="center" />
-        <el-table-column label="鏈堝害鏁版嵁"
-                         v-if="searchForm.timeDimension === 'month'">
-          <el-table-column prop="monthlyUnitConsumption"
-                           label="鏈堝害绱鍗曡��"
-                           align="right">
-            <template #default="scope">
-              <span class="data-value">{{ scope.row.monthlyUnitConsumption }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="monthlyConsumption"
-                           label="鏈堝害绱鐢ㄩ噺/鏈堝害绱浜ч噺"
-                           align="right">
-            <template #default="scope">
-              <span class="data-value">{{ scope.row.monthlyConsumption }}/{{ scope.row.monthlyProduction }}</span>
-            </template>
-          </el-table-column>
+        <el-table-column prop="energyTyep"
+                         label="鑳借�楃被鍨�"
+                         align="center"
+                         width="100">
+          <template #default="scope">
+            <el-tag :type="getEnergyTypeType(scope.row.energyTyep)">
+              {{ scope.row.energyTyep }}
+            </el-tag>
+          </template>
         </el-table-column>
-        <el-table-column label="骞村害鏁版嵁"
-                         v-if="searchForm.timeDimension === 'year'">
-          <el-table-column prop="annualUnitConsumption"
-                           label="骞村害绱鍗曡��"
-                           align="right">
-            <template #default="scope">
-              <span class="data-value">{{ scope.row.annualUnitConsumption }}</span>
-            </template>
-          </el-table-column>
-          <el-table-column prop="annualConsumption"
-                           label="骞村害绱鐢ㄩ噺/骞村害绱浜ч噺"
-                           align="right">
-            <template #default="scope">
-              <span class="data-value">{{ scope.row.annualConsumption }}/{{ scope.row.annualProduction }}</span>
-            </template>
-          </el-table-column>
+        <el-table-column prop="consumption"
+                         label="鐢ㄩ噺"
+                         align="right"
+                         width="120" />
+        <el-table-column prop="cost"
+                         label="鎴愭湰"
+                         align="right"
+                         width="120">
+          <template #default="scope">
+            <span class="data-value">楼{{ scope.row.cost }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column prop="unitConsumption"
+                         label="鍗曡��"
+                         align="right">
+          <template #default="scope">
+            <span class="data-value">{{ scope.row.unitConsumption }}</span>
+          </template>
         </el-table-column>
       </el-table>
     </div>
@@ -147,6 +142,7 @@
   import { ElMessage } from "element-plus";
   import { TrendCharts, List } from "@element-plus/icons-vue";
   import * as echarts from "echarts";
+  import { energyConsumptionDetailStatistics } from "@/api/energyManagement/energyType";
 
   // 鎼滅储琛ㄥ崟
   const searchForm = reactive({
@@ -229,12 +225,12 @@
     const energyTypes = ["姘�", "鐢�", "钂告苯"];
 
     energyTypes.forEach(type => {
-      const typeData = data.find(item => item.energyType === type);
-      if (typeData && typeData[seriesDataKey]) {
+      const typeData = data.find(item => item.energyTyep === type);
+      if (typeData) {
         series.push({
           name: type,
           type: "line",
-          data: typeData[seriesDataKey].map(seriesDataMap),
+          data: typeData.cost,
           smooth: true,
           symbol: "circle",
           symbolSize: 8,
@@ -302,12 +298,49 @@
   const handleQuery = () => {
     tableLoading.value = true;
 
-    // 妯℃嫙鎺ュ彛璋冪敤
-    setTimeout(() => {
-      generateMockData();
-      tableLoading.value = false;
-      updateChart();
-    }, 500);
+    const params = {
+      type: "",
+      state: searchForm.timeDimension === "year" ? "骞�" : "鏈�",
+    };
+
+    if (searchForm.energyType && searchForm.energyType !== "鍏ㄩ儴") {
+      params.type = searchForm.energyType;
+    }
+
+    if (searchForm.timeDimension === "year") {
+      params.startDate = searchForm.year + "-01-01";
+      params.endDate = searchForm.year + "-12-31";
+      params.days = 365;
+    } else if (searchForm.timeDimension === "month") {
+      const year = searchForm.year;
+      const month = searchForm.month;
+      const lastDay = new Date(year, month, 0).getDate();
+      params.startDate = `${year}-${String(month).padStart(2, "0")}-01`;
+      params.endDate = `${year}-${String(month).padStart(2, "0")}-${String(
+        lastDay
+      ).padStart(2, "0")}`;
+      params.days = lastDay;
+    }
+
+    energyConsumptionDetailStatistics(params)
+      .then(res => {
+        if (res.code === 200) {
+          const data = res.data;
+          tableData.value = data.energyCostDtos || [];
+          updateChart();
+        } else {
+          ElMessage.error(res.message || "鑾峰彇鏁版嵁澶辫触");
+          tableData.value = [];
+        }
+      })
+      .catch(err => {
+        console.error("鑾峰彇鏁版嵁寮傚父锛�", err);
+        ElMessage.error("绯荤粺寮傚父锛岃幏鍙栨暟鎹け璐�");
+        tableData.value = [];
+      })
+      .finally(() => {
+        tableLoading.value = false;
+      });
   };
 
   // 閲嶇疆
@@ -322,83 +355,6 @@
   // 瀵煎嚭
   const handleExport = () => {
     ElMessage.success("鎶ヨ〃瀵煎嚭鎴愬姛");
-  };
-
-  // 鐢熸垚鍋囨暟鎹�
-  const generateMockData = () => {
-    const energyTypes = [
-      {
-        energyType: "姘�",
-        unit: "鍚�/绔嬫柟绫�",
-        monthlyUnitConsumption: (Math.random() * 0.5 + 0.8).toFixed(4),
-        monthlyConsumption: Math.floor(Math.random() * 5000 + 10000),
-        monthlyProduction: Math.floor(Math.random() * 10000 + 20000),
-        annualUnitConsumption: (Math.random() * 0.3 + 0.9).toFixed(4),
-        annualConsumption: Math.floor(Math.random() * 60000 + 120000),
-        annualProduction: Math.floor(Math.random() * 120000 + 240000),
-        monthlyData: generateMonthlyData(0.8, 1.3),
-        dailyData: generateDailyData(0.7, 1.4),
-      },
-      {
-        energyType: "鐢�",
-        unit: "搴�/绔嬫柟绫�",
-        monthlyUnitConsumption: (Math.random() * 2 + 5).toFixed(4),
-        monthlyConsumption: Math.floor(Math.random() * 50000 + 100000),
-        monthlyProduction: Math.floor(Math.random() * 10000 + 20000),
-        annualUnitConsumption: (Math.random() * 1.5 + 5.5).toFixed(4),
-        annualConsumption: Math.floor(Math.random() * 600000 + 1200000),
-        annualProduction: Math.floor(Math.random() * 120000 + 240000),
-        monthlyData: generateMonthlyData(5, 7),
-        dailyData: generateDailyData(4.5, 7.5),
-      },
-      {
-        energyType: "钂告苯",
-        unit: "鍚�/绔嬫柟绫�",
-        monthlyUnitConsumption: (Math.random() * 0.3 + 0.5).toFixed(4),
-        monthlyConsumption: Math.floor(Math.random() * 3000 + 6000),
-        monthlyProduction: Math.floor(Math.random() * 10000 + 20000),
-        annualUnitConsumption: (Math.random() * 0.2 + 0.55).toFixed(4),
-        annualConsumption: Math.floor(Math.random() * 36000 + 72000),
-        annualProduction: Math.floor(Math.random() * 120000 + 240000),
-        monthlyData: generateMonthlyData(0.5, 0.8),
-        dailyData: generateDailyData(0.4, 0.9),
-      },
-    ];
-
-    if (searchForm.energyType && searchForm.energyType !== "鍏ㄩ儴") {
-      tableData.value = energyTypes.filter(
-        item => item.energyType === searchForm.energyType
-      );
-    } else {
-      tableData.value = energyTypes;
-    }
-  };
-
-  // 鐢熸垚鏈堝害鏁版嵁
-  const generateMonthlyData = (min, max) => {
-    const data = [];
-    for (let i = 1; i <= 12; i++) {
-      data.push({
-        month: i,
-        unitConsumption: (Math.random() * (max - min) + min).toFixed(4),
-      });
-    }
-    return data;
-  };
-
-  // 鐢熸垚姣忔棩鏁版嵁
-  const generateDailyData = (min, max) => {
-    const year = searchForm.year;
-    const month = searchForm.month;
-    const daysInMonth = new Date(year, month, 0).getDate();
-    const data = [];
-    for (let i = 1; i <= daysInMonth; i++) {
-      data.push({
-        day: i,
-        unitConsumption: (Math.random() * (max - min) + min).toFixed(4),
-      });
-    }
-    return data;
   };
 
   // 绐楀彛澶у皬鍙樺寲鏃堕噸鏂版覆鏌撳浘琛�

--
Gitblit v1.9.3