diff --git a/src/utils/index.ts b/src/utils/index.ts index 65ab7ebc..7f97d4e4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -135,32 +135,46 @@ export function getTreeData( return arr } -// 获取近一周的时间 +// 获取近7的时间 export function getWeek() { - const date = new Date() - const year = date.getFullYear() - const month = date.getMonth() - const day = date.getDate() - const week = date.getDay() - //开始时间 - let WeekStartDate = dayjs(new Date(year, month, day - week + 1)).format('YYYY-MM-DD') - // 结束时间 - let WeekEndDate = dayjs(new Date()).format('YYYY-MM-DD') + let toData = new Date(new Date().toLocaleDateString()).getTime() + //今天 + let todayStart = toData + //昨天 + let yesterdayStart = toData - 3600 * 24 * 1000 + let yesterdayEnd = yesterdayStart + 24 * 60 * 60 * 1000 - 1 + //最近7天 + let past7daysStart = todayStart - 7 * 3600 * 24 * 1000 + // const date = new Date() + // const year = date.getFullYear() + // const month = date.getMonth() + // const day = date.getDate() + // const week = date.getDay() + // //开始时间 + // let WeekStartDate = dayjs(new Date(year, month, day - week + 1)).format('YYYY-MM-DD') + // // 结束时间 + // let WeekEndDate = dayjs(new Date()).format('YYYY-MM-DD') return { - WeekStartDate, - WeekEndDate, + WeekStartDate: dayjs(past7daysStart).format('YYYY-MM-DD'), + WeekEndDate: dayjs(yesterdayEnd).format('YYYY-MM-DD'), } } // 获取近一月的数据 export function getMonth() { - const date = new Date() - const year = date.getFullYear() - const month = date.getMonth() - let MonthStartDate = dayjs(new Date(year, month, 1)).format('YYYY-MM-DD') - let MonthEndDate = dayjs(new Date()).format('YYYY-MM-DD') + let toData = new Date(new Date().toLocaleDateString()).getTime() + //昨天 + let yesterdayStart = toData - 3600 * 24 * 1000 + let yesterdayEnd = yesterdayStart + 24 * 60 * 60 * 1000 - 1 + //最近30天 + let past30daysStart = toData - 30 * 3600 * 24 * 1000 + // const date = new Date() + // const year = date.getFullYear() + // const month = date.getMonth() + // let MonthStartDate = dayjs(new Date(year, month, 1)).format('YYYY-MM-DD') + // let MonthEndDate = dayjs(new Date()).format('YYYY-MM-DD') return { - MonthStartDate, - MonthEndDate, + MonthStartDate: dayjs(past30daysStart).format('YYYY-MM-DD'), + MonthEndDate: dayjs(yesterdayEnd).format('YYYY-MM-DD'), } } diff --git a/src/views/main/meteorological/components/AirHumidity.vue b/src/views/main/meteorological/components/AirHumidity.vue index ef128507..a8d594dc 100644 --- a/src/views/main/meteorological/components/AirHumidity.vue +++ b/src/views/main/meteorological/components/AirHumidity.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { smooth: true, diff --git a/src/views/main/meteorological/components/AirTemperature.vue b/src/views/main/meteorological/components/AirTemperature.vue index 161ddede..86478237 100644 --- a/src/views/main/meteorological/components/AirTemperature.vue +++ b/src/views/main/meteorological/components/AirTemperature.vue @@ -85,7 +85,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { smooth: true, diff --git a/src/views/main/meteorological/components/CO2.vue b/src/views/main/meteorological/components/CO2.vue index caaf1a88..2244a3c3 100644 --- a/src/views/main/meteorological/components/CO2.vue +++ b/src/views/main/meteorological/components/CO2.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: Object.values(e), diff --git a/src/views/main/meteorological/components/LightIntensity.vue b/src/views/main/meteorological/components/LightIntensity.vue index 38751996..59d0a94f 100644 --- a/src/views/main/meteorological/components/LightIntensity.vue +++ b/src/views/main/meteorological/components/LightIntensity.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { symbolSize: 20, diff --git a/src/views/main/meteorological/components/Noise.vue b/src/views/main/meteorological/components/Noise.vue index fc0d94a2..2fcfa108 100644 --- a/src/views/main/meteorological/components/Noise.vue +++ b/src/views/main/meteorological/components/Noise.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: Object.values(e), diff --git a/src/views/main/meteorological/components/PM10.vue b/src/views/main/meteorological/components/PM10.vue index 53ba11c1..a3b7b8bc 100644 --- a/src/views/main/meteorological/components/PM10.vue +++ b/src/views/main/meteorological/components/PM10.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: Object.values(e), diff --git a/src/views/main/meteorological/components/PM25.vue b/src/views/main/meteorological/components/PM25.vue index 5399f960..622a9217 100644 --- a/src/views/main/meteorological/components/PM25.vue +++ b/src/views/main/meteorological/components/PM25.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: Object.values(e), diff --git a/src/views/main/meteorological/components/Pressure.vue b/src/views/main/meteorological/components/Pressure.vue index 08f50cf6..df871b61 100644 --- a/src/views/main/meteorological/components/Pressure.vue +++ b/src/views/main/meteorological/components/Pressure.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { data: Object.values(e), diff --git a/src/views/main/meteorological/components/Rainfall.vue b/src/views/main/meteorological/components/Rainfall.vue index be45e4b3..5e0b8f98 100644 --- a/src/views/main/meteorological/components/Rainfall.vue +++ b/src/views/main/meteorological/components/Rainfall.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { symbolSize: 20, diff --git a/src/views/main/meteorological/components/WindDirection.vue b/src/views/main/meteorological/components/WindDirection.vue index f4c5c287..4188c5dd 100644 --- a/src/views/main/meteorological/components/WindDirection.vue +++ b/src/views/main/meteorological/components/WindDirection.vue @@ -84,7 +84,7 @@ }, }, ], - grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { symbolSize: 20, diff --git a/src/views/main/meteorological/components/WindSpeed.vue b/src/views/main/meteorological/components/WindSpeed.vue index 40686ec6..47f5c465 100644 --- a/src/views/main/meteorological/components/WindSpeed.vue +++ b/src/views/main/meteorological/components/WindSpeed.vue @@ -85,7 +85,7 @@ }, }, ], - grid: { left: '1%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, + grid: { left: '2%', right: '4%', top: '2 %', bottom: 0, containLabel: true }, series: [ { smooth: true, diff --git a/src/views/main/meteorological/index.vue b/src/views/main/meteorological/index.vue index 1b87fb40..c8865e7e 100644 --- a/src/views/main/meteorological/index.vue +++ b/src/views/main/meteorological/index.vue @@ -82,107 +82,114 @@ :rowProps="{ gutter: [16, 0] }" :showActionButtonGroup="false" /> --> -