From 5e3f064530fe71987e2a5920fe59967ef348cbd7 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 19 八月 2025 14:14:28 +0800
Subject: [PATCH] 统计页面展示优化

---
 src/views/index.vue |  157 ++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 121 insertions(+), 36 deletions(-)

diff --git a/src/views/index.vue b/src/views/index.vue
index 90b71a1..ac2876e 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -94,15 +94,30 @@
                 style="margin-left: 390px"
                 @change="changes"
               >
-                <el-radio-button label="鍛�" @click="dyat = 7"></el-radio-button>
                 <el-radio-button
-                  label="鏈�"
-                  @click="dyat = 30"
+                  label="杩戜竴鍛�"
+                  @click="dyat = 7"
                 ></el-radio-button>
                 <el-radio-button
-                  label="骞�"
-                  @click="dyat = 360"
+                  label="杩戜竴鏈�"
+                  @click="dyat = 31"
                 ></el-radio-button>
+                <el-radio-button
+                  label="杩戜竴骞�"
+                  @click="dyat = 365"
+                ></el-radio-button>
+                <el-radio-button label="鑷畾涔�">
+                  <el-date-picker
+                    v-if="radio1 === '鑷畾涔�'"
+                    v-model="customDateRange"
+                    type="daterange"
+                    range-separator="鑷�"
+                    start-placeholder="寮�濮嬫棩鏈�"
+                    end-placeholder="缁撴潫鏃ユ湡"
+                    value-format="yyyy-MM-dd"
+                    @change="handleCustomDateChange"
+                  ></el-date-picker>
+                </el-radio-button>
               </el-radio-group>
             </div>
             <!-- 涓儴绾挎�ф煴鐘跺浘 -->
@@ -113,13 +128,18 @@
         </el-col>
         <!-- 鍙宠竟鍒楄〃 -->
         <el-col :span="4" class="aside">
-          <div class="grid-content bg-purple" style="margin-top: -180px">
+          <div class="grid-contentsa bg-purple" style="margin-top: -180px">
             <div class="title">
               绉戝鏈嶅姟閲�
               <span>{{ endatd }} ~ {{ statd }}</span>
             </div>
-            <div style="max-height: 690px; width: 100%; overflow: auto">
-              <el-table style="width: 100%" :data="SkuTop">
+            <div class="dept-table-container">
+              <el-table
+                v-if="SkuTop.length > 0"
+                style="width: 100%"
+                :data="SkuTop"
+                :height="tableHeight"
+              >
                 <template v-for="(item, index) in SkuTop"></template>
                 <el-table-column
                   prop="order"
@@ -129,7 +149,7 @@
                 ></el-table-column>
                 <el-table-column
                   prop="deptname"
-                  width="88"
+                  width="120"
                   class-name="name"
                 ></el-table-column>
 
@@ -137,24 +157,26 @@
                   <template slot-scope="scope"> {{ scope.row.rc }}娆� </template>
                 </el-table-column>
               </el-table>
+              <div v-else class="empty-tip">
+                <el-empty description="鏆傛棤绉戝鏈嶅姟鏁版嵁"></el-empty>
+              </div>
             </div>
           </div>
         </el-col>
       </el-row>
       <!-- 搴曢儴涓�涓� -->
       <el-row :gutter="20" style="margin-bottom: 20px">
-        <el-col :span="24">
+        <!-- <el-col :span="24">
           <div class="grid-content bg-purple" style="min-height: 300px">
             <div class="title">
               瀹f暀缁熻
               <span class="el-icon-s-unfold moreIcon"></span>
             </div>
             <div class="cooperate">
-              <!-- 鍚堜綔鍖哄煙 -->
               <div class="pieChart" id="pieCharts"></div>
             </div>
           </div>
-        </el-col>
+        </el-col> -->
         <!-- <el-col :span="9">
           <div class="grid-content bg-purple" style="min-height: 300px">
             <div class="title">
@@ -306,7 +328,7 @@
       mypPieCharts: null,
       lastWidth: window.innerWidth,
       lastHeight: window.innerHeight,
-      radio1: "鍛�",
+      radio1: "杩戜竴骞�",
       ticketStatistics: {},
       timeTypeMap: {
         鍛�: "day",
@@ -330,7 +352,8 @@
       SkuTop: [],
       cylinderSeries: [],
       cylinderXAxis: [],
-      dyat: 6,
+      customDateRange: [], // 鑷畾涔夋棩鏈熻寖鍥�
+      dyat: 365,
       intervalId: null,
     };
   },
@@ -344,16 +367,32 @@
       return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD HH:mm:ss");
     },
     statd() {
+      if (this.radio1 === "鑷畾涔�" && this.customDateRange.length > 0) {
+        return this.customDateRange[1];
+      }
       return dayjs().format("YYYY-MM-DD");
     },
     endatd() {
+      if (this.radio1 === "鑷畾涔�" && this.customDateRange.length > 0) {
+        return this.customDateRange[0];
+      }
       return dayjs().subtract(this.dyat, "day").format("YYYY-MM-DD");
+    },
+    tableHeight() {
+      // 鏍规嵁鏁版嵁閲忓姩鎬佽绠楅珮搴�
+      const rowHeight = 40; // 姣忚澶х害楂樺害
+      const headerHeight = 40; // 琛ㄥご楂樺害
+      const minHeight = 500; // 鏈�灏忛珮搴�
+      const maxHeight = 600; // 鏈�澶ч珮搴�
+
+      const calculatedHeight = this.SkuTop.length * rowHeight + headerHeight;
+      return Math.min(Math.max(calculatedHeight, minHeight), maxHeight);
     },
   },
   created() {
     this.getTopdata();
     this.getgraphdata();
-    this.getranking();
+    // this.getranking();
     this.$nextTick(function () {
       this.myEcharts2();
       this.getnodeCollect();
@@ -372,15 +411,35 @@
   methods: {
     // 鏀瑰彉鏃堕棿浜嬩欢
     changes() {
-      if (this.radio1 == "鍛�") {
-        this.dyat = 6;
-      } else if (this.radio1 == "鏈�") {
-        this.dyat = 30;
-      } else {
-        this.dyat = 364;
+      switch (this.radio1) {
+        case "杩戜竴鍛�":
+          this.dyat = 7;
+          break;
+        case "杩戜竴鏈�":
+          this.dyat = 30;
+          break;
+        case "杩戜竴骞�":
+          this.dyat = 365;
+          break;
+        case "鑷畾涔�":
+          // 鑷畾涔夋棩鏈熷鐞嗗湪handleCustomDateChange鏂规硶涓�
+          return;
       }
+      this.refreshData();
+    },
+
+    // 澶勭悊鑷畾涔夋棩鏈熷彉鍖�
+    handleCustomDateChange(range) {
+      if (!range || range.length !== 2) return;
+
+      this.customDateRange = range;
+      this.refreshData();
+    },
+
+    // 缁熶竴鍒锋柊鏁版嵁鐨勬柟娉�
+    refreshData() {
       this.getgraphdata();
-      this.getranking();
+      // this.getranking();
       this.getTopdata();
       this.myEcharts2();
       this.getnodeCollect();
@@ -461,12 +520,7 @@
       let params = {
         startDate: this.endatd,
         endDate: this.statd,
-        timeType:
-          this.radio1 === "鍛�"
-            ? "day"
-            : this.radio1 === "鏈�"
-            ? "month"
-            : "year",
+        timeType: this.getTimeType(),
       };
 
       try {
@@ -477,6 +531,28 @@
       } catch (error) {
         console.error("鑾峰彇鍥捐〃鏁版嵁澶辫触:", error);
       }
+    },
+
+    // 鑾峰彇鏃堕棿绫诲瀷
+    getTimeType() {
+      if (this.radio1 === "杩戜竴鍛�" || this.radio1 === "杩戜竴鏈�") {
+        return "day";
+      }
+
+      if (this.radio1 === "杩戜竴骞�") {
+        return "month";
+      }
+
+      // 鑷畾涔夋棩鏈熻寖鍥�
+      if (this.radio1 === "鑷畾涔�" && this.customDateRange.length === 2) {
+        const start = dayjs(this.customDateRange[0]);
+        const end = dayjs(this.customDateRange[1]);
+        const diffDays = end.diff(start, "day");
+
+        return diffDays > 60 ? "month" : "day";
+      }
+
+      return "day"; // 榛樿杩斿洖day绫诲瀷
     },
     processChartData(data) {
       // 鎸夋椂闂存帓搴忕‘淇濇暟鎹『搴忔纭�
@@ -492,14 +568,11 @@
 
       sortedData.forEach((item) => {
         // 鏍规嵁鏃堕棿绫诲瀷鏍煎紡鍖栨樉绀�
-        let timeLabel = item.timePeriod;
-        if (this.radio1 === "鍛�") {
-          timeLabel = dayjs(item.timePeriod).format("MM-DD");
-        } else if (this.radio1 === "鏈�") {
-          timeLabel = item.timePeriod.split("-")[1] + "鏈�";
-        } else {
-          timeLabel = item.timePeriod.split("-")[0] + "骞�";
-        }
+        const timeType = this.getTimeType();
+        const timeLabel =
+          timeType === "day"
+            ? dayjs(item.timePeriod).format("MM-DD")
+            : dayjs(item.timePeriod).format("YYYY-MM");
 
         xAxisData.push(timeLabel);
         dischargeFollowData.push(item.dischargeFollowCount);
@@ -837,6 +910,12 @@
     flex: 1;
   }
 }
+.dept-table-container {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  min-height: 0; /* 閲嶈锛氬厑璁稿唴瀹规敹缂� */
+}
 ::v-deep .el-table {
   td:first-child {
     .cell {
@@ -1094,6 +1173,12 @@
   padding: 0 10px;
   text-align: center;
 }
+.grid-contentsa {
+  min-height: 600px;
+  border-radius: 20px;
+  padding: 0 10px;
+  text-align: center;
+}
 
 .grid-contents {
   min-height: 36px;

--
Gitblit v1.9.3