From 574b449a39019a59dc90ecc19dda9f63d3aa9636 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期三, 18 十一月 2026 15:35:47 +0800
Subject: [PATCH] 测试完成

---
 src/views/index.vue |  306 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 238 insertions(+), 68 deletions(-)

diff --git a/src/views/index.vue b/src/views/index.vue
index 90b71a1..53ddfc7 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -3,9 +3,14 @@
     <div class="home" style="margin-top: 40px; margin-left: 20px">
       <!-- 澶撮儴涓や釜 -->
       <el-row :gutter="20">
-        <el-col :span="11">
+        <el-col :span="8">
           <!-- 灏辫瘖缁熻鐩掑瓙 -->
-          <div class="grid-content bg-purple headerBox bgc1">
+          <div
+            class="grid-content bg-purple headerBox bgc1"
+            v-loading="headerLoading"
+            element-loading-text="鍔犺浇涓�..."
+            element-loading-background="rgba(255, 255, 255, 0.55)"
+          >
             <div class="title">
               闂ㄨ瘖鏈嶅姟<span
                 style="
@@ -45,8 +50,13 @@
             </el-row>
           </div>
         </el-col>
-        <el-col :span="9">
-          <div class="grid-content bg-purple headerBox bgc2">
+        <el-col :span="12">
+          <div
+            class="grid-content bg-purple headerBox bgc2"
+            v-loading="headerLoading"
+            element-loading-text="鍔犺浇涓�..."
+            element-loading-background="rgba(255, 255, 255, 0.55)"
+          >
             <div class="title">
               鍑洪櫌鏈嶅姟
               <span
@@ -60,7 +70,8 @@
               <span>{{ endatd }} ~ {{ statd }}</span>
             </div>
             <el-row :gutter="20">
-              <el-col :span="10">
+              <!-- 鍑洪櫌灏辫瘖閲� -->
+              <el-col :span="6">
                 <div class="home-user-task-stats">
                   <p style="color: red">{{ DischargeData.rc }}</p>
                 </div>
@@ -68,12 +79,31 @@
                   <p>鍑洪櫌灏辫瘖閲忥紙浜烘锛�</p>
                 </div>
               </el-col>
-              <el-col :span="10">
+              <!-- 棣栨鏈嶅姟 -->
+              <el-col :span="6">
                 <div class="home-user-task-stats">
-                  <p style="color: red">{{ DischargeData.rs }}</p>
-                  <div class="text-color2">
-                    <p>鍑洪櫌鏈嶅姟閲忥紙浜烘锛�</p>
-                  </div>
+                  <p style="color: #67c23a">{{ DischargeData.scsf }}</p>
+                </div>
+                <div class="text-color2" style="color: #67c23a">
+                  <p>棣栨鏈嶅姟锛堜汉娆★級</p>
+                </div>
+              </el-col>
+              <!-- 鍐嶆鏈嶅姟 -->
+              <el-col :span="6">
+                <div class="home-user-task-stats">
+                  <p style="color: #e6a23c">{{ DischargeData.zcsf }}</p>
+                </div>
+                <div class="text-color2" style="color: #e6a23c">
+                  <p>鍐嶆鏈嶅姟锛堜汉娆★級</p>
+                </div>
+              </el-col>
+              <!-- 涓撶梾鏈嶅姟 -->
+              <el-col :span="6">
+                <div class="home-user-task-stats">
+                  <p style="color: #409eff">{{ DischargeData.zbsf }}</p>
+                </div>
+                <div class="text-color2" style="color: #409eff">
+                  <p>涓撶梾鏈嶅姟锛堜汉娆★級</p>
                 </div>
               </el-col>
             </el-row>
@@ -84,7 +114,13 @@
       <el-row :gutter="20">
         <el-col :span="20">
           <!-- echars鏁版嵁鍙鍖� -->
-          <div class="grid-content bg-purple" style="min-height: 365px">
+          <div
+            class="grid-content bg-purple"
+            style="min-height: 365px"
+            v-loading="chartLoading"
+            element-loading-text="鍥捐〃鏁版嵁鍔犺浇涓�..."
+            element-loading-background="rgba(255, 255, 255, 0.55)"
+          >
             <div class="title">
               鏈嶅姟缁熻
               <span>{{ endatd }} ~ {{ statd }}</span>
@@ -94,15 +130,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 +164,24 @@
         </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"
+            v-loading="deptLoading"
+            element-loading-text="鍔犺浇涓�..."
+            element-loading-background="rgba(255, 255, 255, 0.55)"
+          >
             <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 +191,7 @@
                 ></el-table-column>
                 <el-table-column
                   prop="deptname"
-                  width="88"
+                  width="120"
                   class-name="name"
                 ></el-table-column>
 
@@ -137,24 +199,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">
@@ -299,6 +363,9 @@
   name: "home",
   data() {
     return {
+      headerLoading: false, // 椤堕儴缁熻鍗″姞杞戒腑
+      chartLoading: false, // 鏈嶅姟缁熻瓒嬪娍鍥惧姞杞戒腑
+      deptLoading: false, // 绉戝鏈嶅姟閲忓姞杞戒腑
       NodeCount: "",
       PrtnerCount: "",
       NodeCount: "",
@@ -306,7 +373,7 @@
       mypPieCharts: null,
       lastWidth: window.innerWidth,
       lastHeight: window.innerHeight,
-      radio1: "鍛�",
+      radio1: "杩戜竴骞�",
       ticketStatistics: {},
       timeTypeMap: {
         鍛�: "day",
@@ -314,8 +381,11 @@
         骞�: "year",
       },
       DischargeData: {
-        rs: "",
-        rc: "",
+        rc: "", // 鍑洪櫌灏辫瘖閲忥紙鎬讳汉娆★級
+        rs: "", // 鍑洪櫌鏈嶅姟閲忥紙鎬讳汉娆★級
+        scsf: 0, // 鏂板锛氶娆℃湇鍔′汉娆�
+        zcsf: 0, // 鏂板锛氬啀娆℃湇鍔′汉娆�
+        zbsf: 0, // 鏂板锛氫笓鐥呮湇鍔′汉娆�
       },
       OutpatientData: {
         rs: "",
@@ -330,7 +400,8 @@
       SkuTop: [],
       cylinderSeries: [],
       cylinderXAxis: [],
-      dyat: 6,
+      customDateRange: [], // 鑷畾涔夋棩鏈熻寖鍥�
+      dyat: 365,
       intervalId: null,
     };
   },
@@ -344,17 +415,33 @@
       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() {
+    // 鍚勫尯鍧楃嫭绔嬪姞杞斤紝loading 鐢卞悇鑷柟娉曞唴閮ㄧ鐞�
     this.getTopdata();
     this.getgraphdata();
-    this.getranking();
-    this.$nextTick(function () {
+    this.$nextTick(() => {
       this.myEcharts2();
       this.getnodeCollect();
       this.getSkuTop();
@@ -372,15 +459,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();
@@ -399,17 +506,24 @@
     },
     // top鎺掕
     async getSkuTop() {
+      this.deptLoading = true;
       let Rankingdata = {
         startDate: this.endatd,
         endDate: this.statd,
         cy: 1,
       };
-      await getDeptRanking(Rankingdata).then((res) => {
-        if (res.code == 200) {
-          this.SkuTop = res.rows.sort((a, b) => b.rc - a.rc);
-          console.log(this.SkuTop, "this.SkuTop");
-        }
-      });
+      try {
+        await getDeptRanking(Rankingdata).then((res) => {
+          if (res.code == 200) {
+            this.SkuTop = res.rows.sort((a, b) => b.rc - a.rc);
+            console.log(this.SkuTop, "this.SkuTop");
+          }
+        });
+      } catch (e) {
+        console.error("鑾峰彇绉戝鎺掕澶辫触:", e);
+      } finally {
+        this.deptLoading = false;
+      }
 
       // this.SkuTop = [
       //   { amount: 0, count: 123, skuId: "0", skuName: "蹇冭偤绉�" },
@@ -431,6 +545,7 @@
     },
     // 鑾峰彇澶撮儴鏁版嵁
     getTopdata() {
+      this.headerLoading = true;
       let hospCountdata = {
         startDate: this.endatd,
         endDate: this.statd,
@@ -441,42 +556,66 @@
         endDate: this.statd,
         cy: 1,
       };
-      // 鏌ヨ闂ㄨ瘖鐪嬬梾浜烘鍜屼汉鏁�
-      getEChartsPatMedOuthospCount(hospCountdata).then((res) => {
-        if (res.code == 200) {
-          this.OutpatientData = res.data;
-        }
-      });
-      // 鏌ヨ鍑恒�佸叆闄㈢湅鐥呬汉娆″拰浜烘暟
-      getechartsListCountdata(Countdata).then((res) => {
-        if (res.code == 200) {
-          this.DischargeData = res.data;
-        }
+      // 鏌ヨ闂ㄨ瘖鐪嬬梾浜烘鍜屼汉鏁� / 鏌ヨ鍑恒�佸叆闄㈢湅鐥呬汉娆″拰浜烘暟
+      return Promise.all([
+        getEChartsPatMedOuthospCount(hospCountdata).then((res) => {
+          if (res.code == 200) {
+            this.OutpatientData = res.data;
+          }
+        }),
+        getechartsListCountdata(Countdata).then((res) => {
+          if (res.code == 200) {
+            this.DischargeData = res.data;
+          }
+        }),
+      ]).finally(() => {
+        this.headerLoading = false;
       });
     },
     // 鑾峰彇涓儴绾挎煴鍥炬暟鎹�
     getranking() {},
 
     async getgraphdata() {
+      this.chartLoading = true;
       let params = {
         startDate: this.endatd,
         endDate: this.statd,
-        timeType:
-          this.radio1 === "鍛�"
-            ? "day"
-            : this.radio1 === "鏈�"
-            ? "month"
-            : "year",
+        timeType: this.getTimeType(),
       };
 
       try {
         const res = await getServiceStatistics(params);
         if (res.code === 200) {
           this.processChartData(res.data);
+        } else {
+          this.chartLoading = false;
         }
       } catch (error) {
         console.error("鑾峰彇鍥捐〃鏁版嵁澶辫触:", error);
+        this.chartLoading = false;
       }
+    },
+
+    // 鑾峰彇鏃堕棿绫诲瀷
+    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 +631,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);
@@ -564,6 +700,7 @@
       };
 
       this.myChart2.setOption(option);
+      this.chartLoading = false;
     },
 
     // 璁$畻鏈�浼樼殑interval鍊�
@@ -800,7 +937,6 @@
     },
     // 椤甸潰鍙樺寲璋冩暣澶у皬
     handleResize() {
-      console.log(111);
       // 璋冩暣 ECharts 鍥捐〃澶у皬
       if (this.myChart2) {
         this.myChart2.resize();
@@ -836,6 +972,12 @@
   .echars1 {
     flex: 1;
   }
+}
+.dept-table-container {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+  min-height: 0; /* 閲嶈锛氬厑璁稿唴瀹规敹缂� */
 }
 ::v-deep .el-table {
   td:first-child {
@@ -1094,6 +1236,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;
@@ -1106,3 +1254,25 @@
   background-color: #f9fafc;
 }
 </style>
+
+<style>
+/* 棣栭〉鍒嗗潡鍔犺浇鍔ㄧ敾锛氭洿杞婚噺銆佹洿娓呯埥鐨� loading */
+.home .el-loading-mask {
+  background-color: rgba(255, 255, 255, 0.55);
+}
+.home .el-loading-spinner {
+  top: 50%;
+  margin-top: -25px;
+  width: 100%;
+  text-align: center;
+}
+.home .el-loading-spinner .el-icon-loading {
+  font-size: 30px;
+  color: #409eff;
+}
+.home .el-loading-spinner .el-loading-text {
+  margin-top: 8px;
+  color: #606266;
+  font-size: 13px;
+}
+</style>

--
Gitblit v1.9.3