Compare commits

..

No commits in common. "777cca79442910053cf71eb246ca37ae5a0403d1" and "d11406d74113b0ebc3a7992c6d39e9790e441ce2" have entirely different histories.

18 changed files with 387 additions and 671 deletions

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -88,7 +76,10 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: Object.values(e), data: Object.values(e).map((e) => {
if (!!e) return e
return 0
}),
type: 'line', type: 'line',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
import echarts from '/@/utils/lib/echarts' import echarts from '/@/utils/lib/echarts'
const props = defineProps({ const props = defineProps({
@ -32,19 +32,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -52,6 +39,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -64,7 +52,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -89,7 +77,10 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: Object.values(e), data: Object.values(e).map((e) => {
if (!!e) return e
return 0
}),
type: 'line', type: 'line',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -87,7 +75,10 @@
grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
series: [ series: [
{ {
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -89,7 +77,10 @@
{ {
symbolSize: 20, symbolSize: 20,
type: 'scatter', type: 'scatter',
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
}, },
], ],
dataZoom: [ dataZoom: [

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -87,7 +75,10 @@
grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
series: [ series: [
{ {
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -87,7 +75,10 @@
grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
series: [ series: [
{ {
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -87,7 +75,10 @@
grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
series: [ series: [
{ {
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -87,7 +75,10 @@
grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true }, grid: { left: '5%', right: '1%', top: '2 %', bottom: 0, containLabel: true },
series: [ series: [
{ {
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
color: '#5ab1ef', color: '#5ab1ef',

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -89,7 +77,10 @@
{ {
symbolSize: 20, symbolSize: 20,
type: 'scatter', type: 'scatter',
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
}, },
], ],
dataZoom: [ dataZoom: [

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
@ -31,19 +31,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -51,6 +38,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -63,7 +51,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -89,7 +77,10 @@
{ {
symbolSize: 20, symbolSize: 20,
type: 'scatter', type: 'scatter',
data: Object.values(e), data: Object.values(e).map((e) => {
if (e === 0) return null
return e
}),
}, },
], ],
dataZoom: [ dataZoom: [

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
import echarts from '/@/utils/lib/echarts' import echarts from '/@/utils/lib/echarts'
const props = defineProps({ const props = defineProps({
@ -32,19 +32,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -52,6 +39,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -64,7 +52,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -89,7 +77,10 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: Object.values(e), data: Object.values(e).map((e) => {
if (!!e) return e
return 0
}),
type: 'line', type: 'line',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

View File

@ -48,7 +48,7 @@
<FormItem label="日期"> <FormItem label="日期">
<RangePicker <RangePicker
:disabledDate="disabledDate" :disabledDate="disabledDate"
@change="onChangTime" @change="onChange('time')"
v-model:value="formState.time" v-model:value="formState.time"
/> />
</FormItem> </FormItem>
@ -89,7 +89,6 @@
:extra="name" :extra="name"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 空气湿度 --> <!-- 空气湿度 -->
@ -98,7 +97,6 @@
:data="statisData.air_humidity" :data="statisData.air_humidity"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 光照强度 --> <!-- 光照强度 -->
@ -107,13 +105,11 @@
:data="statisData.illumination" :data="statisData.illumination"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 降雨量 --> <!-- 降雨量 -->
<Rainfall <Rainfall
:extra="name" :extra="name"
:time="formState.time"
:data="statisData.daily_rainfall" :data="statisData.daily_rainfall"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
@ -125,7 +121,6 @@
:data="statisData.wind_speed" :data="statisData.wind_speed"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 风力 --> <!-- 风力 -->
@ -134,7 +129,6 @@
:data="statisData.wind_degree" :data="statisData.wind_degree"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 风向 --> <!-- 风向 -->
@ -143,7 +137,6 @@
:data="statisData.wind_direction" :data="statisData.wind_direction"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- 噪声 --> <!-- 噪声 -->
@ -152,7 +145,6 @@
:data="statisData.noise" :data="statisData.noise"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- PM10 --> <!-- PM10 -->
@ -161,7 +153,6 @@
:data="statisData.pm10" :data="statisData.pm10"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- PM25 --> <!-- PM25 -->
@ -170,7 +161,6 @@
:data="statisData.pm25" :data="statisData.pm25"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
<!-- CO2 --> <!-- CO2 -->
@ -179,7 +169,6 @@
:data="statisData.co2" :data="statisData.co2"
class="md:w-386px w-full !mr-4 !mb-4" class="md:w-386px w-full !mr-4 !mb-4"
:loading="false" :loading="false"
:time="formState.time"
:company="formState.time_interval" :company="formState.time_interval"
/> />
</div> </div>
@ -276,11 +265,6 @@
if (e === 'time_interval') formState.time = undefined if (e === 'time_interval') formState.time = undefined
getPoint() getPoint()
} }
const onChangTime = (e) => {
if (e === null) formState.time_interval = 'day'
else formState.time_interval = ''
getPoint()
}
onMounted(() => { onMounted(() => {
getBase() getBase()
}) })

View File

@ -11,7 +11,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { Card } from 'ant-design-vue' import { Card } from 'ant-design-vue'
import { Ref, ref, watch, computed } from 'vue' import { Ref, ref, watch } from 'vue'
import { useECharts } from '/@/hooks/web/useECharts' import { useECharts } from '/@/hooks/web/useECharts'
import echarts from '/@/utils/lib/echarts' import echarts from '/@/utils/lib/echarts'
const props = defineProps({ const props = defineProps({
@ -36,19 +36,6 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '', default: '',
}, },
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
}) })
const chartRef = ref<HTMLDivElement | null>(null) const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>) const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
@ -56,6 +43,7 @@
() => props.data, () => props.data,
(e) => { (e) => {
if (e) { if (e) {
const format = props.company === 'day' ? 'HH:mm' : 'YYYY-MM-DD'
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -68,7 +56,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: Object.keys(e).map((e) => dayjs(e).format(format)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -93,7 +81,10 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: Object.values(e), data: Object.values(e).map((e) => {
if (!!e) return e
return 0
}),
type: 'line', type: 'line',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [

View File

@ -18,7 +18,7 @@
:options="baseDate" :options="baseDate"
v-model:value="formState.base_id" v-model:value="formState.base_id"
placeholder="请选择基地" placeholder="请选择基地"
></Select> />
</FormItem> </FormItem>
</Col> </Col>
<Col <Col
@ -31,11 +31,11 @@
> >
<FormItem label="检测点"> <FormItem label="检测点">
<Select <Select
@select="onChange('device_id')" @select="onChange('')"
placeholder="请选择检测点" placeholder="请选择检测点"
:options="pointDate" :options="pointDate"
v-model:value="formState.device_id" v-model:value="formState.device_id"
></Select> />
</FormItem> </FormItem>
</Col> </Col>
<Col <Col
@ -47,11 +47,7 @@
:xxl="{ span: 4 }" :xxl="{ span: 4 }"
> >
<FormItem label="日期"> <FormItem label="日期">
<RangePicker <RangePicker @change="onChange('time')" v-model:value="formState.time" />
:disabledDate="disabledDate"
@change="onChangTime"
v-model:value="formState.time"
></RangePicker>
</FormItem> </FormItem>
</Col> </Col>
<Col <Col
@ -112,7 +108,6 @@
:loading="false" :loading="false"
:title="currentActiveLable" :title="currentActiveLable"
:data="chartData" :data="chartData"
:time="formState.time"
/> />
</div> </div>
</Card> </Card>
@ -151,6 +146,7 @@
message, message,
} 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
const RadioGroup = Radio.Group const RadioGroup = Radio.Group
@ -250,9 +246,6 @@
}, },
] ]
const disabledDate = (current) => {
return current && current > dayjs().endOf('day')
}
// //
const getBase = async () => { const getBase = async () => {
const res = await getGriculturalDeviceBasic({ device_type: 2 }) const res = await getGriculturalDeviceBasic({ device_type: 2 })
@ -313,12 +306,6 @@
getPoint() getPoint()
} }
const onChangTime = (e) => {
if (e === null) formState.time_interval = 'day'
else formState.time_interval = ''
getPoint()
}
const handleSetting = () => { const handleSetting = () => {
openDrawer(true, { openDrawer(true, {
isUpdate: false, isUpdate: false,

View File

@ -13,14 +13,14 @@
<script setup lang="ts"> <script setup lang="ts">
// import { Ref, ref, watch } from 'vue'; // import { Ref, ref, watch } from 'vue';
import { SvgIcon } from '/@/components/Icon/index' import { SvgIcon } from '/@/components/Icon/index';
defineProps({ defineProps({
loading: Boolean, loading: Boolean,
data: { data: {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
}) });
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -3,101 +3,59 @@
v-bind="$attrs" v-bind="$attrs"
@register="registerDrawer" @register="registerDrawer"
showFooter showFooter
title="设置" :title="getTitle"
width="500px" width="500px"
@ok="handleSubmit" @ok="handleSubmit"
> >
<div v-for="(item, index) in Title" :key="index" class="mt-10px"> <a-form>
<div class="text-20px font-semibold">{{ enumName[item] }}</div> <div class="text-20px font-medium">温度</div>
<div class="mt-30px flex" v-for="(item1, index1) in setFormat(item)" :key="index1"> <div class="mt-30px flex">
<div class="w-90px leading-42px">{{ enumName1[item1] }}</div> <div class="w-90px leading-32px">Ⅰ级预警</div>
<div> <div>
<div <div class="flex w-full items-center" v-for="item in 3" :key="item">
class="flex w-full items-center mt-10px" <a-form-item>
v-for="(item2, index2) in roulsDate.value[item][item1]" <a-input suffix="℃" />
:key="index2" </a-form-item>
> <div class="mb-24px px-10px">-</div>
<Input <a-form-item>
type="number" <a-input suffix="℃" />
v-model:value="item2.min" </a-form-item>
placeholder="请输入"
:suffix="enumCompany[item]"
/>
<div class="mx-10px">-</div>
<Input
type="number"
v-model:value="item2.max"
placeholder="请输入"
:suffix="enumCompany[item]"
/>
</div>
</div> </div>
</div> </div>
</div> </div>
</a-form>
</BasicDrawer> </BasicDrawer>
</template> </template>
<script lang="ts" setup> <script lang="ts">
import { getDeviceWarningRules } from '/@/api/sys/user' import { defineComponent, ref, computed, unref } from 'vue';
import { ref, computed } from 'vue' import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer' import { Form, Input } from 'ant-design-vue';
import { Input } from 'ant-design-vue'
import { editDeviceWarningRules } from '/@/api/sys/user'
const emits = defineEmits(['success', 'register'])
const enumName = {
conductivity: '电导率',
humidity: '湿度',
temperature: '温度',
k: '氮',
n: '磷',
p: '钾',
}
const enumCompany = {
temperature: '℃',
conductivity: 'us/cm',
humidity: '%',
k: 'mg/kg',
n: 'mg/kg',
p: 'mg/kg',
}
const enumName1 = {
1: 'Ⅰ级预警',
2: 'Ⅱ级预警',
3: 'Ⅲ级预警',
4: 'Ⅳ级预警',
}
const roulsDate = ref(null)
const Title = computed(() => {
if (!roulsDate.value) return []
return Object.keys(roulsDate.value.value)
})
const setFormat = (e: string) => {
if (!roulsDate.value) return []
return Object.keys(roulsDate.value.value[e])
}
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async () => {
setDrawerProps({ confirmLoading: false })
const res = await getDeviceWarningRules({}) export default defineComponent({
roulsDate.value = res.find((e) => e.slug === 'device_warning_rule_soil') components: {
}) BasicDrawer,
[Form.name]: Form,
[Form.Item.name]: Form.Item,
[Input.name]: Input,
},
setup() {
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
setDrawerProps({ confirmLoading: false });
// setFieldsValuetreeDataTreekey not exist
});
const handleSubmit = async () => { const getTitle = '设置';
if (!roulsDate.value) return
try { async function handleSubmit() {}
const params = {
slug: roulsDate.value.slug, return {
value: roulsDate.value.value, getTitle,
} registerDrawer,
console.log(params) handleSubmit,
const res = await editDeviceWarningRules(params) };
console.log(res) },
closeDrawer() });
emits('success')
} finally {
setDrawerProps({ confirmLoading: false })
}
}
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -3,17 +3,16 @@
<template #title> <template #title>
<div class="text-18px font-extrabold">{{ title }}</div> <div class="text-18px font-extrabold">{{ title }}</div>
</template> </template>
<template #extra></template> <template #extra>普润镇桔博园-设备间旁边</template>
<div ref="chartRef" :style="{ width, height }"></div> <div ref="chartRef" :style="{ width, height }"></div>
</Card> </Card>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import dayjs from 'dayjs' import { Card } from 'ant-design-vue';
import { Card } from 'ant-design-vue' import { Ref, ref, watch } from 'vue';
import { Ref, ref, watch, computed } from 'vue' import { useECharts } from '/@/hooks/web/useECharts';
import { useECharts } from '/@/hooks/web/useECharts' import echarts from '/@/utils/lib/echarts';
import echarts from '/@/utils/lib/echarts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
title: { title: {
@ -28,34 +27,15 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '300px', default: '300px',
}, },
data: { });
type: Object as PropType<object>, const chartRef = ref<HTMLDivElement | null>(null);
default: () => {}, const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
},
company: {
type: String as PropType<string>,
default: '',
},
time: {
type: Object as PropType<object>,
default: () => {},
},
})
const format = computed(() => {
if (props.time) {
const start_time = dayjs(props.time?.[0]).format('YYYY-MM-DD')
const end_time = dayjs(props.time?.[1]).format('YYYY-MM-DD')
if (start_time === end_time) return 'HH:mm'
}
if (props.company === 'day') return 'HH:mm'
return 'YYYY-MM-DD'
})
const chartRef = ref<HTMLDivElement | null>(null)
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
watch( watch(
() => props.data, () => props.loading,
(e) => { () => {
if (e) { if (props.loading) {
return;
}
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -68,7 +48,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: Object.keys(e).map((e) => dayjs(e).format(format.value)), data: [...new Array(18)].map((_item, index) => `${index + 6}:00`),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -93,7 +73,7 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: Object.values(e), data: [11, 22, 40, 18, 3, 55, 66, 33, 14, 30, 66, 44, 22, 11, 40, 20, 50, 33, 22, 11],
type: 'line', type: 'line',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -112,20 +92,12 @@
}, },
}, },
], ],
dataZoom: [ });
{
type: 'inside', //sliderinside
show: false,
xAxisIndex: 0,
},
],
})
}
}, },
{ {
immediate: true, immediate: true,
}, },
) );
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -1,85 +1,16 @@
<template> <template>
<PageWrapper> <PageWrapper>
<Card> <a-card>
<Form ref="formRef" :model="formState"> <BasicForm
<Row :gutter="[16, 16]"> autoFocusFirstItem
<Col :labelWidth="0"
:xs="{ span: 24 }" :schemas="schemas"
:sm="{ span: 12 }" :rowProps="{ gutter: [16, 0] }"
:md="{ span: 8 }" :showActionButtonGroup="false"
:lg="{ span: 6 }" />
:xl="{ span: 6 }"
:xxl="{ span: 4 }"
>
<FormItem label="基地">
<Select
@select="onChange('base_id')"
:fieldNames="{ label: 'name', value: 'id' }"
:options="baseDate"
v-model:value="formState.base_id"
placeholder="请选择基地"
></Select>
</FormItem>
</Col>
<Col
:xs="{ span: 24 }"
:sm="{ span: 12 }"
:md="{ span: 8 }"
:lg="{ span: 6 }"
:xl="{ span: 6 }"
:xxl="{ span: 4 }"
>
<FormItem label="检测点">
<Select
@select="onChange('')"
placeholder="请选择检测点"
:options="pointDate"
v-model:value="formState.device_id"
></Select>
</FormItem>
</Col>
<Col
:xs="{ span: 24 }"
:sm="{ span: 12 }"
:md="{ span: 8 }"
:lg="{ span: 6 }"
:xl="{ span: 6 }"
:xxl="{ span: 4 }"
>
<FormItem label="日期">
<RangePicker
:disabledDate="disabledDate"
@change="onChangTime"
v-model:value="formState.time"
></RangePicker>
</FormItem>
</Col>
<Col
:xs="{ span: 24 }"
:sm="{ span: 12 }"
:md="{ span: 8 }"
:lg="{ span: 6 }"
:xl="{ span: 6 }"
:xxl="{ span: 4 }"
>
<FormItem>
<RadioGroup
@change="onChange('time_interval')"
button-style="solid"
v-model:value="formState.time_interval"
>
<RadioButton value="day">今天</RadioButton>
<RadioButton value="week">近一周</RadioButton>
<RadioButton value="month">近一个月</RadioButton>
</RadioGroup>
</FormItem>
</Col>
</Row>
</Form>
<!-- -->
<div class="flex justify-between"> <div class="flex justify-between">
<span class="text-xl">预警数据统计</span> <span class="text-xl">预警数据统计</span>
<Button @click="handleSetting"></Button> <a-button @click="handleSetting"></a-button>
</div> </div>
<div class="mt-20px flex"> <div class="mt-20px flex">
<EarlyWarningItem <EarlyWarningItem
@ -95,7 +26,7 @@
:key="item.value" :key="item.value"
class="flex items-center mr-28px font-medium text-[#828fa2] mt-24px cursor-pointer" class="flex items-center mr-28px font-medium text-[#828fa2] mt-24px cursor-pointer"
:class="{ active: item.value == activeKey }" :class="{ active: item.value == activeKey }"
@click="onChangeTag(item.value)" @click="onChangeTag(item)"
> >
<img <img
class="w-16px h-16px" class="w-16px h-16px"
@ -106,233 +37,225 @@
</div> </div>
</div> </div>
<div class="mt-20px"> <div class="mt-20px">
<LineCharts <LineCharts :loading="false" :title="currentActiveLable" />
:company="formState.time_interval"
:extra="extra"
:loading="false"
:title="currentActiveLable"
:data="chartData"
:time="formState.time"
/>
</div> </div>
</Card> </a-card>
<FormDrawer @register="registerDrawer" @success="handleSuccess" /> <FormDrawer @register="registerDrawer" @success="handleSuccess" />
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts">
import dayjs from 'dayjs' import { PageWrapper } from '/@/components/Page';
import { formatDataByObject, getWeek, getMonth } from '/@/utils/index' import { defineComponent, ref, computed } from 'vue';
import { PageWrapper } from '/@/components/Page' import { BasicForm, FormSchema } from '/@/components/Form/index';
import { ref, reactive, onMounted, computed } from 'vue' import { Card, Button } from 'ant-design-vue';
import EarlyWarningItem from './components/EarlyWarningItem.vue' import { ColEx } from '/@/components/Form/src/types';
import icon1 from '/@/assets/images/icon_1.png' import EarlyWarningItem from './components/EarlyWarningItem.vue';
import uicon1 from '/@/assets/images/uicon_1.png' import icon1 from '/@/assets/images/icon_1.png';
import LineCharts from './components/LineCharts.vue' import uicon1 from '/@/assets/images/uicon_1.png';
import FormDrawer from './components/FormDrawer.vue' import LineCharts from './components/LineCharts.vue';
import { useDrawer } from '/@/components/Drawer' import FormDrawer from './components/FormDrawer.vue';
import { useDrawer } from '/@/components/Drawer';
const valueSelectA = ref<string[]>([]);
import {
getGriculturalDeviceBasic,
getaGriculturalDevicePoint,
getAmonitoringData,
getDeviceWarningNums,
} from '/@/api/sys/user'
import {
Card,
Form,
FormItem,
Select,
Row,
Col,
Radio,
RangePicker,
Button,
message,
} from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
const RadioButton = Radio.Button
const RadioGroup = Radio.Group
const [registerDrawer, { openDrawer }] = useDrawer()
const formRef = ref<FormInstance>()
const formState = reactive({
base_id: undefined, //
device_id: undefined, //
time: undefined, //
time_interval: 'day',
})
const baseDate = ref([])
const pointDate = ref<any>([])
const statisData = ref<any>({})
//
const earlyNums = ref<any>({})
//
const activeKey = ref('conductivity')
interface EarlyWarningItem { interface EarlyWarningItem {
icon: String icon: String;
title: String title: String;
value: String | Number value: String;
} }
const earlyWarningList = computed(() => {
const arr: EarlyWarningItem[] = [ const colProps: Partial<ColEx> = {
xs: 24,
sm: 12,
md: 8,
lg: 6,
xl: 6,
xxl: 4,
};
const schemas: FormSchema[] = [
{
field: 'field1',
component: 'Select',
label: '',
colProps,
componentProps: {
placeholder: '基地',
options: [
{
label: '选项2',
value: '1',
key: '1',
},
],
onChange: (e: any) => {
console.log(e);
},
},
},
{
field: 'field1',
component: 'Select',
label: '',
colProps,
componentProps: {
placeholder: '检测点',
options: [
{
label: '选项2',
value: '1',
key: '1',
},
],
onChange: (e: any) => {
console.log(e);
},
},
},
{
field: 'time',
component: 'RangePicker',
label: '',
colProps,
componentProps: {
placeholder: ['开始日期', '结束日期'],
},
},
{
field: 'disclosure',
component: 'RadioButtonGroup',
label: '',
colProps: colProps,
componentProps: {
options: [
{
label: '今天',
value: '1',
},
{
label: '近一周',
value: '2',
},
{
label: '近一个月',
value: '3',
},
],
},
},
];
const earlyWarningList: EarlyWarningItem[] = [
{ {
icon: 'yujing1', icon: 'yujing1',
title: 'Ⅰ级预警', title: 'Ⅰ级预警',
value: '', value: '1',
}, },
{ {
icon: 'yujing2', icon: 'yujing2',
title: 'Ⅱ级预警', title: 'Ⅱ级预警',
value: '', value: '1',
}, },
{ {
icon: 'yujing3', icon: 'yujing3',
title: 'Ⅲ级预警', title: 'Ⅲ级预警',
value: '', value: '1',
}, },
{ {
icon: 'yujing4', icon: 'yujing4',
title: 'Ⅳ级预警', title: 'Ⅳ级预警',
value: '', value: '100',
}, },
] ];
Object.values(earlyNums.value).forEach((v: number | string, index: number) => {
arr[index].value = v
})
return arr
})
const currentActiveLable = computed(
() => tagMenus.find((e) => e.value === activeKey.value)?.lable ?? '',
)
const chartData = computed(() => statisData.value[activeKey.value])
const extra = computed(() => {
const name1 = baseDate.value?.find((e: any) => e.id === formState.base_id)?.name
const name2 = pointDate.value?.find((e: any) => e.value === formState.device_id)?.label ?? ''
return name1 + '-' + name2
})
const tagMenus = [ const tagMenus = [
{
lable: '电导率',
value: 'conductivity',
icon: icon1,
icon1: uicon1,
},
{
lable: '湿度',
value: 'humidity',
icon: icon1,
icon1: uicon1,
},
{ {
lable: '温度', lable: '温度',
value: 'temperature', value: 0,
icon: icon1,
icon1: uicon1,
},
{
lable: '电导率',
value: 1,
icon: icon1,
icon1: uicon1,
},
{
lable: '水分',
value: 2,
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
{ {
lable: '氮', lable: '氮',
value: 'k', value: 3,
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
{ {
lable: '磷', lable: '磷',
value: 'n', value: 4,
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
{ {
lable: '钾', lable: '钾',
value: 'p', value: 5,
icon: icon1, icon: icon1,
icon1: uicon1, icon1: uicon1,
}, },
] ];
const disabledDate = (current) => { export default defineComponent({
return current && current > dayjs().endOf('day') components: {
} [Card.name]: Card,
// [Button.name]: Button,
const getBase = async () => { BasicForm,
const res = await getGriculturalDeviceBasic({ device_type: 2 }) PageWrapper,
baseDate.value = res EarlyWarningItem,
if (!formState.base_id) formState.base_id = res?.[0]?.id ?? undefined LineCharts,
getPoint() FormDrawer,
} },
//
const getPoint = async () => { setup() {
const res = await getaGriculturalDevicePoint({ const activeKey = ref(1);
device_type: 2,
agricultural_basic: formState.base_id, const [registerDrawer, { openDrawer }] = useDrawer();
})
pointDate.value = formatDataByObject(res) const currentActiveLable = computed(
if (!formState.device_id) formState.device_id = pointDate.value?.[0]?.value ?? undefined () => tagMenus.find((e) => e.value == activeKey.value)?.lable ?? '',
getDate() );
getNums()
} function onChangeTag(item) {
// activeKey.value = item.value;
const getDate = async () => {
const params = {
device_id: formState.device_id,
start_time: '',
end_time: '',
}
if (formState.time) {
params.start_time = dayjs(formState.time?.[0]).format('YYYY-MM-DD')
params.end_time = dayjs(formState.time?.[1]).format('YYYY-MM-DD')
}
if (formState.time_interval === 'week') {
const { WeekStartDate, WeekEndDate } = getWeek()
params.start_time = WeekStartDate
params.end_time = WeekEndDate
} else if (formState.time_interval === 'month') {
const { MonthStartDate, MonthEndDate } = getMonth()
params.start_time = MonthStartDate
params.end_time = MonthEndDate
} else if (formState.time_interval === 'day') {
params.start_time = ''
params.end_time = ''
}
const res = await getAmonitoringData(params)
statisData.value = res
}
//
const getNums = async () => {
let res = await getDeviceWarningNums({
base: formState.base_id,
device: formState.device_id,
status: 0,
})
earlyNums.value = res
}
const onChange = (e: string | undefined) => {
if (e === 'base_id') formState.device_id = undefined
if (e === 'time') formState.time_interval = ''
if (e === 'time_interval') formState.time = undefined
getPoint()
} }
const onChangTime = (e) => { function handleSetting() {
if (e === null) formState.time_interval = 'day'
else formState.time_interval = ''
getPoint()
}
const handleSetting = () => {
openDrawer(true, { openDrawer(true, {
isUpdate: false, isUpdate: false,
}) });
} }
const handleSuccess = () => {
message.success('操作成功') function handleSuccess() {
// reload();
console.log('=========');
} }
//
const onChangeTag = (e: string) => { return {
activeKey.value = e activeKey,
} valueSelectA,
onMounted(() => { schemas,
getBase() earlyWarningList,
}) tagMenus,
currentActiveLable,
registerDrawer,
onChangeTag,
handleSetting,
handleSuccess,
};
},
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">