From 301532b5c1cad2c1d45080bfef86579b20486bf5 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 25 十二月 2024 10:33:23 +0800
Subject: [PATCH] 首页调整、考核结果页面调整

---
 src/views/home/data-face/index.vue |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/views/home/data-face/index.vue b/src/views/home/data-face/index.vue
index c6d051f..d55da51 100644
--- a/src/views/home/data-face/index.vue
+++ b/src/views/home/data-face/index.vue
@@ -10,7 +10,13 @@
               </el-option>
             </el-select>
           </div>
-          <div>
+          <div class="select-container">
+            <el-select v-model="params.category" placeholder="鏁版嵁绫诲瀷" @change="getChart" clearable>
+              <el-option v-for="item in categories" :key="item.label" :label="item.label" :value="item.value">
+              </el-option>
+            </el-select>
+          </div>
+          <div class="select-container">
             <el-date-picker v-model="date" format="yyyy-MM" value-format="yyyy-MM" type="month" placeholder="閫夋嫨鏈堜唤"
                             @change="dateChange">
             </el-date-picker>
@@ -39,7 +45,12 @@
       date: '',
       params: {
         month: '',
+        category: 1
       },
+      categories: [
+        {label: '绱鏁版嵁', value: 1},
+        {label: '姣忔棩鏁版嵁', value: 2},
+      ],
       options: [
         {label: '鐪佸巺', value: 1}
       ],
@@ -78,10 +89,13 @@
       return tempArray;
     },
     getAllDay() {
-      const currentDate = this.date.split('-');
-      const currentYear = currentDate[0];
-      const currentMonth = currentDate[1];
+      // 鑾峰彇褰撳墠鏃ユ湡
+      const currentDate = new Date();
+      const currentYear = currentDate.getFullYear();
+      const currentMonth = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝闇�瑕佸姞1骞惰ˉ闆�
+      // 鑾峰彇褰撳墠鏈堜唤鐨勫ぉ鏁�
       const daysInMonth = new Date(currentYear, currentMonth, 0).getDate();
+      // 瀛樺偍褰撳墠鏈堜唤姣忎竴澶╃殑鏃ユ湡
       const datesOfMonth = [];
       for (var day = 1; day <= daysInMonth; day++) {
         const formattedDate = currentMonth + '-' + (day.toString().padStart(2, '0'));
@@ -97,9 +111,13 @@
       if (!data.list || data.list.length === 0) {
         snapCount = 0;
       }else {
-        snapCount = data.list[data.list.length - 1].snapCount
+        snapCount = data.list.reduce((max, item) => Math.max(max, item.snapCount), 0)
       }
-      const yMax = Math.max(snapCount, baseLine * 1.2);
+      const yMax = Math.max(snapCount * 1.2, baseLine * 1.2);
+      let interval = 1;
+      while ((yMax) / interval > 100) { // 杩欓噷鐨� 100 鏄竴涓槇鍊硷紝鎮ㄥ彲浠ユ牴鎹渶瑕佽皟鏁�
+        interval *= 10;
+      }
       const colors = ['#5470C6', '#66CC99', '#EE6666'];
       option = {
         color: colors,
@@ -191,7 +209,7 @@
             axisLabel: {
               formatter: function (value) {
                 // 杩斿洖鏁存暟閮ㄥ垎锛屾垨浣跨敤鍏朵粬閫昏緫鏉ユ牸寮忓寲鏍囩
-                return Math.floor(value);
+                return Math.floor(value / interval) * interval;
               }
             }
           }
@@ -330,7 +348,7 @@
 }
 
 .select-container {
-  margin: 0 20px;
+  margin-left: 20px;
   width: 180px;
 }
 </style>

--
Gitblit v1.8.0