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" /> --> -
- - - - - - - - - - - - - - - - - - - - - - -
+ + @@ -192,7 +199,7 @@ import dayjs from 'dayjs' import { PageWrapper } from '/@/components/Page' import { ref, reactive, onMounted, computed } from 'vue' - import { Card, Form, FormItem, Select, Row, Col, Radio, RangePicker } from 'ant-design-vue' + import { Card, Form, FormItem, Select, Row, Col, Radio, RangePicker, Empty } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue' import AirTemperature from './components/AirTemperature.vue' import AirHumidity from './components/AirHumidity.vue' @@ -230,12 +237,14 @@ // 获取基地数据 const getBase = async () => { const res = await getGriculturalDeviceBasic({ device_type: 4 }) + if (res.length == 0) return baseDate.value = res if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined getPoint() } // 获取监控到数据 const getPoint = async () => { + if (baseDate.value.length == 0) return const res = await getaGriculturalDevicePoint({ device_type: 4, agricultural_basic: formState.base_id, diff --git a/src/views/main/soil-monitoring/index.vue b/src/views/main/soil-monitoring/index.vue index 3b2bf26c..3c1590b0 100644 --- a/src/views/main/soil-monitoring/index.vue +++ b/src/views/main/soil-monitoring/index.vue @@ -76,45 +76,52 @@ - -
- 预警数据统计 - -
-
- -
-
-
- -
{{ item.lable }}
+ + + @@ -149,6 +156,7 @@ RangePicker, Button, message, + Empty, } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue' const RadioButton = Radio.Button @@ -256,12 +264,14 @@ // 获取基地数据 const getBase = async () => { const res = await getGriculturalDeviceBasic({ device_type: 2 }) + if (res.length == 0) return baseDate.value = res if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined getPoint() } // 获取监控点数据 const getPoint = async () => { + if (baseDate.value.length == 0) return const res = await getaGriculturalDevicePoint({ device_type: 2, agricultural_basic: formState.base_id, diff --git a/src/views/main/water-quality/components/FormDrawer.vue b/src/views/main/water-quality/components/FormDrawer.vue index 97ee2a7d..f8358128 100644 --- a/src/views/main/water-quality/components/FormDrawer.vue +++ b/src/views/main/water-quality/components/FormDrawer.vue @@ -45,20 +45,20 @@ import { editDeviceWarningRules } from '/@/api/sys/user' const emits = defineEmits(['success', 'register']) const enumName = { + chlorine: '氯', conductivity: '电导率', - humidity: '湿度', + oxygen: '氧气', + ph: 'PH', temperature: '温度', - k: '氮', - n: '磷', - p: '钾', + turbidity: '浊度', } const enumCompany = { temperature: '℃', conductivity: 'us/cm', - humidity: '%', - k: 'mg/kg', - n: 'mg/kg', - p: 'mg/kg', + turbidity: 'NTU', + chlorine: 'mg/L', + oxygen: 'mg/L', + ph: '', } const enumName1 = { 1: 'Ⅰ级预警', @@ -79,7 +79,7 @@ setDrawerProps({ confirmLoading: false }) const res = await getDeviceWarningRules({}) - roulsDate.value = res.find((e) => e.slug === 'device_warning_rule_soil') + roulsDate.value = res.find((e) => e.slug === 'device_warning_rule_waterquality') }) const handleSubmit = async () => { diff --git a/src/views/main/water-quality/index.vue b/src/views/main/water-quality/index.vue index d822450c..ca942910 100644 --- a/src/views/main/water-quality/index.vue +++ b/src/views/main/water-quality/index.vue @@ -76,45 +76,52 @@ - -
- 预警数据统计 - -
-
- -
-
-
- -
{{ item.lable }}
+ + + @@ -149,6 +156,7 @@ RangePicker, Button, message, + Empty, } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue' const RadioButton = Radio.Button @@ -167,7 +175,7 @@ // 预警数量 const earlyNums = ref({}) // 选中 - const activeKey = ref('conductivity') + const activeKey = ref('chlorine') interface EarlyWarningItem { icon: String title: String @@ -211,6 +219,12 @@ return name1 + '-' + name2 }) const tagMenus = [ + { + lable: '氯', + value: 'chlorine', + icon: icon1, + icon1: uicon1, + }, { lable: '电导率', value: 'conductivity', @@ -218,8 +232,14 @@ icon1: uicon1, }, { - lable: '湿度', - value: 'humidity', + lable: '氧气', + value: 'oxygen', + icon: icon1, + icon1: uicon1, + }, + { + lable: 'PH', + value: 'ph', icon: icon1, icon1: uicon1, }, @@ -230,20 +250,8 @@ icon1: uicon1, }, { - lable: '氮', - value: 'k', - icon: icon1, - icon1: uicon1, - }, - { - lable: '磷', - value: 'n', - icon: icon1, - icon1: uicon1, - }, - { - lable: '钾', - value: 'p', + lable: '浊度', + value: 'turbidity', icon: icon1, icon1: uicon1, }, @@ -254,15 +262,17 @@ } // 获取基地数据 const getBase = async () => { - const res = await getGriculturalDeviceBasic({ device_type: 2 }) + const res = await getGriculturalDeviceBasic({ device_type: 3 }) + if (res.length == 0) return baseDate.value = res if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined getPoint() } // 获取监控点数据 const getPoint = async () => { + if (baseDate.value.length == 0) return const res = await getaGriculturalDevicePoint({ - device_type: 2, + device_type: 3, agricultural_basic: formState.base_id, }) pointDate.value = formatDataByObject(res)