new-map
H 2022-11-11 15:28:29 +08:00
parent 797449b43f
commit c2b1e0e861
2 changed files with 94 additions and 65 deletions

View File

@ -3,16 +3,17 @@
<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 { Card } from 'ant-design-vue'; import dayjs from 'dayjs'
import { Ref, ref, watch } from 'vue'; import { Card } from 'ant-design-vue'
import { useECharts } from '/@/hooks/web/useECharts'; import { Ref, ref, watch, computed } from 'vue'
import echarts from '/@/utils/lib/echarts'; import { useECharts } from '/@/hooks/web/useECharts'
import echarts from '/@/utils/lib/echarts'
const props = defineProps({ const props = defineProps({
loading: Boolean, loading: Boolean,
title: { title: {
@ -27,15 +28,34 @@
type: String as PropType<string>, type: String as PropType<string>,
default: '300px', default: '300px',
}, },
}); data: {
const chartRef = ref<HTMLDivElement | null>(null); type: Object as PropType<object>,
const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>); default: () => {},
watch( },
() => props.loading, company: {
() => { type: String as PropType<string>,
if (props.loading) { default: '',
return; },
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(
() => props.data,
(e) => {
if (e) {
setOptions({ setOptions({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -48,7 +68,7 @@
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',
data: [...new Array(18)].map((_item, index) => `${index + 6}:00`), data: Object.keys(e).map((e) => dayjs(e).format(format.value)),
axisTick: { axisTick: {
show: false, show: false,
}, },
@ -73,7 +93,7 @@
series: [ series: [
{ {
smooth: true, smooth: true,
data: [11, 22, 40, 18, 3, 55, 66, 33, 14, 30, 66, 44, 22, 11, 40, 20, 50, 33, 22, 11], data: Object.values(e),
type: 'line', type: 'line',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -92,12 +112,20 @@
}, },
}, },
], ],
}); dataZoom: [
{
type: 'inside', //sliderinside
show: false,
xAxisIndex: 0,
},
],
})
}
}, },
{ {
immediate: true, immediate: true,
}, },
); )
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -146,12 +146,13 @@
Row, Row,
Col, Col,
RadioGroup, RadioGroup,
RadioButton, Radio,
RangePicker, RangePicker,
Button, Button,
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 [registerDrawer, { openDrawer }] = useDrawer() const [registerDrawer, { openDrawer }] = useDrawer()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const formState = reactive({ const formState = reactive({