From 5a35edad3883c7bc7c18aa0a59967799c788991a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=B7=E5=86=89=E5=86=89?= Date: Mon, 8 Sep 2025 18:11:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=AF=BC=E5=87=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E6=94=B9=E3=80=81=E5=9B=BE=E5=BD=A2=E5=88=86?= =?UTF-8?q?=E6=9E=90=E9=BB=98=E8=AE=A4=E6=97=A5=E6=9C=9F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/styles/index.scss | 1 + src/components/echartsList/dateTimeSelect.vue | 51 +++++++++------- src/components/table/index.vue | 58 ++++++++++++++++--- src/utils/request.js | 24 +++++--- src/views/agentCollect/cpuData/cpuData.vue | 18 +++--- src/views/agentCollect/diskData/diskData.vue | 18 +++--- .../agentCollect/dockerData/dockerData.vue | 18 +++--- .../agentCollect/memoryData/memoryData.vue | 18 +++--- .../mountPointData/mountPointData.vue | 18 +++--- .../agentCollect/systemData/systemData.vue | 18 +++--- .../disRevenue/earnManage/business/index.vue | 18 +++--- .../earnManage/revenueMethod/index.vue | 18 +++--- .../earnManage/server/dialogView.vue | 50 +++++++++------- .../disRevenue/earnManage/server/index.vue | 18 ++---- .../earnManage/serverRevenue/index.vue | 19 +++--- .../disRevenue/earnManage/switch/index.vue | 19 +++--- src/views/disRevenue/resource/group/index.vue | 18 +++--- .../resource/monitorStategy/index.vue | 18 +++--- .../disRevenue/resource/monitorTemp/index.vue | 18 +++--- .../disRevenue/resource/register/index.vue | 18 +++--- .../disRevenue/resource/resMonitor/index.vue | 13 +---- .../disRevenue/resource/topology/index.vue | 18 +++--- src/views/index.vue | 10 ++-- 23 files changed, 276 insertions(+), 221 deletions(-) diff --git a/src/assets/styles/index.scss b/src/assets/styles/index.scss index 12d8850..ce960bd 100644 --- a/src/assets/styles/index.scss +++ b/src/assets/styles/index.scss @@ -139,6 +139,7 @@ aside { //main-container全局样式 .app-container { + height: calc(100vh - 132px); padding: 8px 20px 20px; } diff --git a/src/components/echartsList/dateTimeSelect.vue b/src/components/echartsList/dateTimeSelect.vue index 36570a7..ceb8e75 100644 --- a/src/components/echartsList/dateTimeSelect.vue +++ b/src/components/echartsList/dateTimeSelect.vue @@ -88,30 +88,41 @@ }, // 获取前一个月的所有日期 getDaysOfPreviousMonth(star, end) { + // 1. 获取当前日期(终点日期) const currentDate = new Date(); - const currentYear = currentDate.getFullYear(); - const currentMonth = currentDate.getMonth(); // 0-11 表示 1-12 月 + const endYear = currentDate.getFullYear(); + const endMonth = currentDate.getMonth(); // 0=1月,11=12月 + const endDay = currentDate.getDate(); // 当前日(如8) - // 计算前一个月的年份和月份 - const prevMonth = currentMonth - 1; - const prevYear = prevMonth >= 0 ? currentYear : currentYear - 1; - const prevMonthActual = prevMonth >= 0 ? prevMonth : 11; // 11 表示 12 月 + // 2. 计算起点日期(当前日期的“上月同日”,处理边界:如3月31日→2月28/29日) + const startDate = new Date(endYear, endMonth, endDay); + // 核心:将当前日期的月份减1(得到上月同日,自动处理天数不足问题) + startDate.setMonth(startDate.getMonth() - 1); - // 获取第一天和最后一天 - const firstDay = star ? new Date(star) : new Date(prevYear, prevMonthActual, 1); - const lastDay = end ? new Date(end) : new Date(prevYear, prevMonthActual + 1, 0); // 下个月首日减 1 天 + // 3. 提取起点日期的年、月、日(用于循环判断) + const startYear = startDate.getFullYear(); + const startMonth = startDate.getMonth(); + const startDay = startDate.getDate(); - // 生成所有日期 - const oneMonthDays = []; - let currentDay = firstDay; - while (currentDay <= lastDay) { - // 格式化为 YYYY-MM-DD - const formattedDate = currentDay.toISOString().split('T')[0]; - oneMonthDays.push(formattedDate); - currentDay = new Date(currentDay); // 避免引用同一对象 - currentDay.setDate(currentDay.getDate() + 1); + // 4. 循环生成“起点~终点”的所有日期 + const dateCollection = []; + // 临时日期:从起点日期开始递增 + const tempDate = new Date(startYear, startMonth, startDay); + + // 循环条件:临时日期 <= 当前日期(终点) + while (tempDate <= currentDate) { + // 格式化日期为“YYYY-MM-DD”(补零处理:如8月→08,5日→05) + const year = tempDate.getFullYear(); + const month = String(tempDate.getMonth() + 1).padStart(2, '0'); + const day = String(tempDate.getDate()).padStart(2, '0'); + const formattedDate = `${year}-${month}-${day}`; + + dateCollection.push(formattedDate); + + // 临时日期加1天(进入下一天) + tempDate.setDate(tempDate.getDate() + 1); } - let timeArr = [oneMonthDays[0], oneMonthDays[oneMonthDays.length - 1]]; + let timeArr = [dateCollection[0], dateCollection[dateCollection.length - 1]]; this.$emit("dataChange", this.isActive, [], timeArr); // this.$emit("dataChange", this.isActive, oneMonthDays); }, @@ -120,7 +131,7 @@ const threeMonths = []; const today = new Date(); // 当前日期 const currentYear = today.getFullYear(); - const currentMonth = today.getMonth(); // 月份从0开始(0=1月,11=12月) + const currentMonth = today.getMonth() + 1; // 月份从0开始(0=1月,11=12月) // 循环获取前3个月(i=0: 前1个月,i=1: 前2个月,i=2: 前3个月) for (let i = 1; i <= num; i++) { // 计算目标月份(当前月 - i) diff --git a/src/components/table/index.vue b/src/components/table/index.vue index ba9463b..1216120 100644 --- a/src/components/table/index.vue +++ b/src/components/table/index.vue @@ -1,5 +1,5 @@