diff --git a/src/components/ChartsTimeLine/index.vue b/src/components/ChartsTimeLine/index.vue new file mode 100644 index 0000000..de4f515 --- /dev/null +++ b/src/components/ChartsTimeLine/index.vue @@ -0,0 +1,367 @@ + + + + + \ No newline at end of file diff --git a/src/components/ZhengBian/index.vue b/src/components/ZhengBian/index.vue index d7e5f85..3ac6c08 100644 --- a/src/components/ZhengBian/index.vue +++ b/src/components/ZhengBian/index.vue @@ -68,7 +68,8 @@
- + +
@@ -121,7 +122,8 @@ Pane } from 'splitpanes' import 'splitpanes/dist/splitpanes.css' - import TimeBarChart from '@/components/ChartsDataZoom/index.vue' + import DataZoomChart from '@/components/ChartsDataZoom/index.vue' + import TimeBarChart from '@/components/ChartsTimeLine/index.vue' import ESelectSingle from '@/components/ESelectSingle/index.vue' import { getToken } from "@/utils/auth"; import useAppStore from '@/store/modules/app' @@ -180,7 +182,6 @@ return options; }); - const textTitle = computed(() => { switch (props.stationType) { case 'A': @@ -509,8 +510,13 @@ const legendData = ref([]) const xAxisData = ref([]) const seriesData = ref([]) + const baseOptionData = ref([]) const echartsLoading = ref(false) const getEchartsData = async () => { + legendData.value = [] + seriesData.value = [] + baseOptionData.value = [] + xAxisData.value = [] echartsLoading.value = true let baseUrl = '/chartdata' if (staticType.value == '1' && props.stationType != 'A') { @@ -521,22 +527,34 @@ let res = await proxy.axiosPost2(url, queryParams); if (res.code === 0) { legendData.value = res.data.legend - // 提取每个series中data的第一个元素并格式化时间 - if (res.data.series && res.data.series.length > 0) { - // 假设第一个series的data包含完整的时间点 - xAxisData.value = res.data.series[0].data.map(item => { - // 如果item是对象且包含时间字段 - if (typeof item === 'object' && item !== null) { - // 假设时间字段可能是tm, time, or the first element - const timeValue = item.tm || item.time || item[0]; - return dayjs(timeValue).format('YYYY-MM-DD HH:mm'); - } else { - // 如果item直接就是时间值 - return dayjs(item).format('YYYY-MM-DD HH:mm'); - } - }); + + if (props.stationType !== 'A' && staticType.value == '1') { + + seriesData.value = res.data.data + baseOptionData.value = res.data.baseOptionData + xAxisData.value = ['08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00'] + console.log(props.stationType, staticType.value,) + console.log('seriesData.value', seriesData.value) + console.log('baseOptionData.value', baseOptionData.value) + console.log('xAxisData.value', xAxisData.value) + } else { + // 提取每个series中data的第一个元素并格式化时间 + if (res.data.series && res.data.series.length > 0) { + // 假设第一个series的data包含完整的时间点 + xAxisData.value = res.data.series[0].data.map(item => { + // 如果item是对象且包含时间字段 + if (typeof item === 'object' && item !== null) { + // 假设时间字段可能是tm, time, or the first element + const timeValue = item.tm || item.time || item[0]; + return dayjs(timeValue).format('YYYY-MM-DD HH:mm'); + } else { + // 如果item直接就是时间值 + return dayjs(item).format('YYYY-MM-DD HH:mm'); + } + }); + } + seriesData.value = res.data.series } - seriesData.value = res.data.series } } catch (error) { console.log(error) @@ -545,7 +563,15 @@ } }; + watch(staticType.value, (newVal, oldVal) => { + if (oldVal !== undefined) { // 避免首次初始化时触发 + // 更新查询参数中的 dataType + queryParams.dataType = newVal + // 重新获取图表数据 + getEchartsData() + } + }) // 预处理数据导出 const yclExport = () => { let url = `${props.requestPrefix}/exportoriginaldata?stnmId=${queryParams.stnmId}&startTime=${queryParams.startTime}&endTime=${queryParams.endTime}`