From 2f78c4aa959b742de3d5883c1dfe8a02a0c874b4 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 02 四月 2026 15:42:55 +0800
Subject: [PATCH] fix: 首页趋势换成周、月、年

---
 src/views/index.vue |  152 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 109 insertions(+), 43 deletions(-)

diff --git a/src/views/index.vue b/src/views/index.vue
index 2e8ed36..1e23cb5 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -75,7 +75,7 @@
                    :xAxis="salesAmountXAxis"
                    :yAxis="salesAmountYAxis"
                    :series="salesAmountSeries"
-                   style="height: 300px" />
+                   style="height: 90%" />
         </section>
       </div>
       <div class="right-col">
@@ -111,9 +111,9 @@
             <el-radio-group v-model="chartRangePlan"
                             size="small"
                             @change="loadPlanTrend">
-              <el-radio-button :label="1">鏃�</el-radio-button>
-              <el-radio-button :label="2">鍛�</el-radio-button>
-              <el-radio-button :label="3">鏈�</el-radio-button>
+              <el-radio-button :label="1">鍛�</el-radio-button>
+              <el-radio-button :label="2">鏈�</el-radio-button>
+              <el-radio-button :label="3">骞�</el-radio-button>
             </el-radio-group>
           </div>
           <Echarts :chartStyle="chartStyle"
@@ -169,27 +169,51 @@
         <section class="section-card mini-table-wrap"
                  v-if="isSectionVisible('planTable')">
           <div class="section-title">鏈�杩戞姤宸�</div>
-          <el-table :data="planTable"
+          <el-table :data="reportingTable"
                     size="small"
-                    stripe>
-            <el-table-column prop="planNo"
-                             label="鐝"
+                    stripe
+                    :loading="reportingTableLoading">
+            <el-table-column prop="productNo"
+                             label="鎶ュ伐缂栧彿"
                              min-width="150" />
-            <el-table-column prop="product"
+            <el-table-column prop="schedule"
+                             label="鐝粍"
+                             min-width="80">
+              <template #default="{ row }">
+                <el-tag :type="row.schedule === '鐧界彮' ? 'primary' : 'warning'">{{ row.schedule || '-' }}</el-tag>
+              </template>
+            </el-table-column>
+            <el-table-column prop="postName"
                              label="鍒涘缓浜�"
-                             min-width="120" />
-            <el-table-column prop="product"
+                             min-width="100" />
+            <el-table-column prop="createTime"
                              label="鎶ュ伐鏃堕棿"
-                             min-width="120" />
-            <el-table-column prop="qty"
+                             min-width="150">
+              <template #default="{ row }">
+                {{ row.createTime ? dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') : '' }}
+              </template>
+            </el-table-column>
+            <el-table-column prop="productName"
                              label="浜у搧"
-                             min-width="90" />
-            <el-table-column prop="issued"
+                             min-width="120">
+              <template #default="{ row }">
+                <el-tag :type="row.productName === '鐮屽潡' ? 'primary' : 'warning'">{{ row.productName || '-' }}</el-tag>
+              </template>
+            </el-table-column>
+            <el-table-column prop="totalQuantity"
                              label="鐢熶骇鏁伴噺"
-                             min-width="90" />
-            <el-table-column prop="issued"
+                             min-width="100">
+              <template #default="{ row }">
+                <span style="color:rgba(18, 148, 212, 0.8);">{{ row.totalQuantity || '-' }}</span> 鏂�
+              </template>
+            </el-table-column>
+            <el-table-column prop="quantity"
                              label="鍚堟牸鏁伴噺"
-                             min-width="90" />
+                             min-width="100">
+              <template #default="{ row }">
+                <span style="color:rgba(0, 228, 99, 0.8);">{{ row.quantity || '-' }}</span> 鏂�
+              </template>
+            </el-table-column>
           </el-table>
         </section>
       </div>
@@ -269,9 +293,13 @@
     processDataProductionStatistics,
     qualityInspectionStatistics,
     nonComplianceWarning,
+    getManageStatistics,
+    planTrends,
   } from "@/api/viewIndex.js";
   import { energyConsumptionDetailStatistics } from "@/api/energyManagement/energyType";
   import { getSalesAmountAnalysis } from "@/api/reportAnalysis/salesStatistics";
+  import { productionReportListPage } from "@/api/productionManagement/productionReporting.js";
+  import dayjs from "dayjs";
 
   const router = useRouter();
   const userStore = useUserStore();
@@ -454,8 +482,8 @@
     { name: "宸插畬鎴愯鍗曟暟", value: "-" },
     { name: "鏈畬鎴愯鍗曟暟", value: "-" },
     { name: "閮ㄥ垎瀹屾垚璁㈠崟鏁�", value: "-" },
-    { name: "璐ㄦ鎬绘暟", value: "-" },
-    { name: "杩囩▼妫�鎬绘暟", value: "-" },
+    { name: "鏉ユ枡妫�鎬绘暟", value: "-" },
+    // { name: "杩囩▼妫�鎬绘暟", value: "-" },
   ]);
 
   const pendingTasks = reactive([]);
@@ -773,7 +801,33 @@
       });
   };
 
-  const planTable = reactive([]);
+  // 鎶ュ伐琛ㄦ牸鏁版嵁
+  const reportingTable = ref([]);
+  const reportingTableLoading = ref(false);
+
+  // 鑾峰彇鏈�杩戞姤宸ユ暟鎹�
+  const fetchReportingData = () => {
+    reportingTableLoading.value = true;
+    productionReportListPage({
+      current: 1,
+      size: 5, // 鍙樉绀烘渶杩�5鏉�
+    })
+      .then(res => {
+        if (res.code === 200) {
+          console.log(res.data.records || []);
+          reportingTable.value = res.data.records || [];
+        } else {
+          reportingTable.value = [];
+        }
+      })
+      .catch(error => {
+        console.error("鑾峰彇鎶ュ伐鏁版嵁澶辫触:", error);
+        reportingTable.value = [];
+      })
+      .finally(() => {
+        reportingTableLoading.value = false;
+      });
+  };
   const recentTrendCards = reactive([
     {
       key: "planIssued",
@@ -1055,26 +1109,18 @@
   };
 
   const loadPlanTrend = async () => {
-    // try {
-    //   const res = await processDataProductionStatistics({
-    //     type: chartRangePlan.value,
-    //   });
-    //   const list = Array.isArray(res?.data) ? res.data : [];
-    //   planXAxis[0].data = list.map(
-    //     (i, index) => i.processName || `宸ュ簭${index + 1}`
-    //   );
-    //   planSeries[0].data = list.map(i =>
-    //     pickFirstNumber(i, ["totalInput", "input", "planNum"])
-    //   );
-    //   planSeries[1].data = list.map(i =>
-    //     pickFirstNumber(i, ["totalOutput", "output", "issueNum"])
-    //   );
-    //   planSeries[2].data = list.map(i =>
-    //     pickFirstNumber(i, ["totalScrap", "scrap", "completeNum"])
-    //   );
-    // } catch (error) {
-    //   console.error("processDataProductionStatistics鎺ュ彛鑾峰彇澶辫触:", error);
-    // }
+    try {
+      const res = await planTrends({
+        type: chartRangePlan.value,
+      });
+      const list = Array.isArray(res?.data) ? res.data : [];
+      planXAxis[0].data = list.map(i => i.dateStr || "-");
+      planSeries[0].data = list.map(i => i.plannedVolume || 0);
+      planSeries[1].data = list.map(i => i.lowerVolume || 0);
+      planSeries[2].data = list.map(i => i.completionVolume || 0);
+    } catch (error) {
+      console.error("planTrends鎺ュ彛鑾峰彇澶辫触:", error);
+    }
   };
 
   const loadQualityData = async () => {
@@ -1204,16 +1250,36 @@
     //   console.error("expenseCompositionAnalysis鎺ュ彛鑾峰彇澶辫触:", error);
     // }
   };
+  const loadManageStatistics = async () => {
+    try {
+      const res = await getManageStatistics();
+      const data = res?.data || {};
+      businessFocus[0].value = `${pickFirstNumber(data, ["total"])} 鏉;
+      businessFocus[1].value = `${pickFirstNumber(data, ["completed"])} 鏉;
+      businessFocus[2].value = `${pickFirstNumber(data, ["uncompleted"])} 鏉;
+      businessFocus[3].value = `${pickFirstNumber(data, [
+        "partialCompleted",
+      ])} 鏉;
+      businessFocus[4].value = `${pickFirstNumber(data, [
+        "materialInspection",
+      ])} 鏉;
+      // businessFocus[5].value = `${pickFirstNumber(data, [""])} 鏉;
+    } catch (error) {
+      console.error("manageStatistics鎺ュ彛鑾峰彇澶辫触:", error);
+    }
+  };
 
   const refreshDashboardData = () => {
     // loadHomeTodos();
-    // loadOrderAndProgress();
-    // loadPlanTrend();
+    loadOrderAndProgress();
+    loadPlanTrend();
     // loadQualityData();
     // loadCostComposition();
     // loadWarningCenter();
+    loadManageStatistics();
     updateEnergyTypeChart();
     fetchSalesAmountChartData();
+    fetchReportingData();
     lastUpdatedAt.value = new Date().toLocaleString();
   };
 

--
Gitblit v1.9.3