new-map
H 2022-11-11 16:45:11 +08:00
parent 777cca7944
commit 538ab49bed
16 changed files with 279 additions and 236 deletions

View File

@ -135,32 +135,46 @@ export function getTreeData(
return arr return arr
} }
// 获取近一周的时间 // 获取近7的时间
export function getWeek() { export function getWeek() {
const date = new Date() let toData = new Date(new Date().toLocaleDateString()).getTime()
const year = date.getFullYear() //今天
const month = date.getMonth() let todayStart = toData
const day = date.getDate() //昨天
const week = date.getDay() let yesterdayStart = toData - 3600 * 24 * 1000
//开始时间 let yesterdayEnd = yesterdayStart + 24 * 60 * 60 * 1000 - 1
let WeekStartDate = dayjs(new Date(year, month, day - week + 1)).format('YYYY-MM-DD') //最近7天
// 结束时间 let past7daysStart = todayStart - 7 * 3600 * 24 * 1000
let WeekEndDate = dayjs(new Date()).format('YYYY-MM-DD') // 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 { return {
WeekStartDate, WeekStartDate: dayjs(past7daysStart).format('YYYY-MM-DD'),
WeekEndDate, WeekEndDate: dayjs(yesterdayEnd).format('YYYY-MM-DD'),
} }
} }
// 获取近一月的数据 // 获取近一月的数据
export function getMonth() { export function getMonth() {
const date = new Date() let toData = new Date(new Date().toLocaleDateString()).getTime()
const year = date.getFullYear() //昨天
const month = date.getMonth() let yesterdayStart = toData - 3600 * 24 * 1000
let MonthStartDate = dayjs(new Date(year, month, 1)).format('YYYY-MM-DD') let yesterdayEnd = yesterdayStart + 24 * 60 * 60 * 1000 - 1
let MonthEndDate = dayjs(new Date()).format('YYYY-MM-DD') //最近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 { return {
MonthStartDate, MonthStartDate: dayjs(past30daysStart).format('YYYY-MM-DD'),
MonthEndDate, MonthEndDate: dayjs(yesterdayEnd).format('YYYY-MM-DD'),
} }
} }

View File

@ -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: [ series: [
{ {
smooth: true, smooth: true,

View File

@ -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: [ series: [
{ {
smooth: true, smooth: true,

View File

@ -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: [ series: [
{ {
data: Object.values(e), data: Object.values(e),

View File

@ -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: [ series: [
{ {
symbolSize: 20, symbolSize: 20,

View File

@ -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: [ series: [
{ {
data: Object.values(e), data: Object.values(e),

View File

@ -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: [ series: [
{ {
data: Object.values(e), data: Object.values(e),

View File

@ -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: [ series: [
{ {
data: Object.values(e), data: Object.values(e),

View File

@ -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: [ series: [
{ {
data: Object.values(e), data: Object.values(e),

View File

@ -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: [ series: [
{ {
symbolSize: 20, symbolSize: 20,

View File

@ -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: [ series: [
{ {
symbolSize: 20, symbolSize: 20,

View File

@ -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: [ series: [
{ {
smooth: true, smooth: true,

View File

@ -82,6 +82,12 @@
:rowProps="{ gutter: [16, 0] }" :rowProps="{ gutter: [16, 0] }"
:showActionButtonGroup="false" :showActionButtonGroup="false"
/> --> /> -->
<template v-if="baseDate.length === 0">
<div class="h-500px flex items-center justify-center flex-col">
<Empty></Empty>
</div>
</template>
<template v-else>
<div class="md:flex enter-y flex-wrap -mr-4"> <div class="md:flex enter-y flex-wrap -mr-4">
<!-- 空气温度 --> <!-- 空气温度 -->
<AirTemperature <AirTemperature
@ -183,6 +189,7 @@
:company="formState.time_interval" :company="formState.time_interval"
/> />
</div> </div>
</template>
</Card> </Card>
</PageWrapper> </PageWrapper>
</template> </template>
@ -192,7 +199,7 @@
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { PageWrapper } from '/@/components/Page' import { PageWrapper } from '/@/components/Page'
import { ref, reactive, onMounted, computed } from 'vue' 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 type { FormInstance } from 'ant-design-vue'
import AirTemperature from './components/AirTemperature.vue' import AirTemperature from './components/AirTemperature.vue'
import AirHumidity from './components/AirHumidity.vue' import AirHumidity from './components/AirHumidity.vue'
@ -230,12 +237,14 @@
// //
const getBase = async () => { const getBase = async () => {
const res = await getGriculturalDeviceBasic({ device_type: 4 }) const res = await getGriculturalDeviceBasic({ device_type: 4 })
if (res.length == 0) return
baseDate.value = res baseDate.value = res
if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined
getPoint() getPoint()
} }
// //
const getPoint = async () => { const getPoint = async () => {
if (baseDate.value.length == 0) return
const res = await getaGriculturalDevicePoint({ const res = await getaGriculturalDevicePoint({
device_type: 4, device_type: 4,
agricultural_basic: formState.base_id, agricultural_basic: formState.base_id,

View File

@ -76,7 +76,13 @@
</Col> </Col>
</Row> </Row>
</Form> </Form>
<template v-if="baseDate.length === 0">
<div class="h-500px flex items-center justify-center flex-col">
<Empty></Empty>
</div>
</template>
<!-- --> <!-- -->
<template v-else>
<div class="flex justify-between"> <div class="flex justify-between">
<span class="text-xl">预警数据统计</span> <span class="text-xl">预警数据统计</span>
<Button @click="handleSetting"></Button> <Button @click="handleSetting"></Button>
@ -115,6 +121,7 @@
:time="formState.time" :time="formState.time"
/> />
</div> </div>
</template>
</Card> </Card>
<FormDrawer @register="registerDrawer" @success="handleSuccess" /> <FormDrawer @register="registerDrawer" @success="handleSuccess" />
</PageWrapper> </PageWrapper>
@ -149,6 +156,7 @@
RangePicker, RangePicker,
Button, Button,
message, message,
Empty,
} from 'ant-design-vue' } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue'
const RadioButton = Radio.Button const RadioButton = Radio.Button
@ -256,12 +264,14 @@
// //
const getBase = async () => { const getBase = async () => {
const res = await getGriculturalDeviceBasic({ device_type: 2 }) const res = await getGriculturalDeviceBasic({ device_type: 2 })
if (res.length == 0) return
baseDate.value = res baseDate.value = res
if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined
getPoint() getPoint()
} }
// //
const getPoint = async () => { const getPoint = async () => {
if (baseDate.value.length == 0) return
const res = await getaGriculturalDevicePoint({ const res = await getaGriculturalDevicePoint({
device_type: 2, device_type: 2,
agricultural_basic: formState.base_id, agricultural_basic: formState.base_id,

View File

@ -45,20 +45,20 @@
import { editDeviceWarningRules } from '/@/api/sys/user' import { editDeviceWarningRules } from '/@/api/sys/user'
const emits = defineEmits(['success', 'register']) const emits = defineEmits(['success', 'register'])
const enumName = { const enumName = {
chlorine: '氯',
conductivity: '电导率', conductivity: '电导率',
humidity: '湿度', oxygen: '氧气',
ph: 'PH',
temperature: '温度', temperature: '温度',
k: '氮', turbidity: '浊度',
n: '磷',
p: '钾',
} }
const enumCompany = { const enumCompany = {
temperature: '℃', temperature: '℃',
conductivity: 'us/cm', conductivity: 'us/cm',
humidity: '%', turbidity: 'NTU',
k: 'mg/kg', chlorine: 'mg/L',
n: 'mg/kg', oxygen: 'mg/L',
p: 'mg/kg', ph: '',
} }
const enumName1 = { const enumName1 = {
1: 'Ⅰ级预警', 1: 'Ⅰ级预警',
@ -79,7 +79,7 @@
setDrawerProps({ confirmLoading: false }) setDrawerProps({ confirmLoading: false })
const res = await getDeviceWarningRules({}) 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 () => { const handleSubmit = async () => {

View File

@ -76,7 +76,13 @@
</Col> </Col>
</Row> </Row>
</Form> </Form>
<template v-if="baseDate.length === 0">
<div class="h-500px flex items-center justify-center flex-col">
<Empty></Empty>
</div>
</template>
<!-- --> <!-- -->
<template v-else>
<div class="flex justify-between"> <div class="flex justify-between">
<span class="text-xl">预警数据统计</span> <span class="text-xl">预警数据统计</span>
<Button @click="handleSetting"></Button> <Button @click="handleSetting"></Button>
@ -115,6 +121,7 @@
:time="formState.time" :time="formState.time"
/> />
</div> </div>
</template>
</Card> </Card>
<FormDrawer @register="registerDrawer" @success="handleSuccess" /> <FormDrawer @register="registerDrawer" @success="handleSuccess" />
</PageWrapper> </PageWrapper>
@ -149,6 +156,7 @@
RangePicker, RangePicker,
Button, Button,
message, message,
Empty,
} from 'ant-design-vue' } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue'
const RadioButton = Radio.Button const RadioButton = Radio.Button
@ -167,7 +175,7 @@
// //
const earlyNums = ref<any>({}) const earlyNums = ref<any>({})
// //
const activeKey = ref('conductivity') const activeKey = ref('chlorine')
interface EarlyWarningItem { interface EarlyWarningItem {
icon: String icon: String
title: String title: String
@ -211,6 +219,12 @@
return name1 + '-' + name2 return name1 + '-' + name2
}) })
const tagMenus = [ const tagMenus = [
{
lable: '氯',
value: 'chlorine',
icon: icon1,
icon1: uicon1,
},
{ {
lable: '电导率', lable: '电导率',
value: 'conductivity', value: 'conductivity',
@ -218,8 +232,14 @@
icon1: uicon1, icon1: uicon1,
}, },
{ {
lable: '湿度', lable: '氧气',
value: 'humidity', value: 'oxygen',
icon: icon1,
icon1: uicon1,
},
{
lable: 'PH',
value: 'ph',
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
@ -230,20 +250,8 @@
icon1: uicon1, icon1: uicon1,
}, },
{ {
lable: '氮', lable: '浊度',
value: 'k', value: 'turbidity',
icon: icon1,
icon1: uicon1,
},
{
lable: '磷',
value: 'n',
icon: icon1,
icon1: uicon1,
},
{
lable: '钾',
value: 'p',
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
@ -254,15 +262,17 @@
} }
// //
const getBase = async () => { 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 baseDate.value = res
if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined
getPoint() getPoint()
} }
// //
const getPoint = async () => { const getPoint = async () => {
if (baseDate.value.length == 0) return
const res = await getaGriculturalDevicePoint({ const res = await getaGriculturalDevicePoint({
device_type: 2, device_type: 3,
agricultural_basic: formState.base_id, agricultural_basic: formState.base_id,
}) })
pointDate.value = formatDataByObject(res) pointDate.value = formatDataByObject(res)