From 22d2bf52493e99e895c38cdd2fa7c9c5bf2e4c83 Mon Sep 17 00:00:00 2001 From: betaqi <3188864257@qq.com> Date: Thu, 13 Nov 2025 13:51:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=80=E8=BF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- global.types/components.d.ts | 1 + src/api/module/transfer/index.ts | 2 +- .../stationData/component/newDataChart.vue | 11 ++-- .../topology/components/detailDrawer.vue | 61 +++++++++++++++++-- .../transfer/components/deviceDrawer.vue | 57 +++++++++++++++-- 5 files changed, 117 insertions(+), 15 deletions(-) diff --git a/global.types/components.d.ts b/global.types/components.d.ts index 70d83f7..92ef3a8 100644 --- a/global.types/components.d.ts +++ b/global.types/components.d.ts @@ -29,6 +29,7 @@ declare module 'vue' { ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElHeader: typeof import('element-plus/es')['ElHeader'] ElInput: typeof import('element-plus/es')['ElInput'] + ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElOption: typeof import('element-plus/es')['ElOption'] diff --git a/src/api/module/transfer/index.ts b/src/api/module/transfer/index.ts index 15a9e26..e2ef9f6 100644 --- a/src/api/module/transfer/index.ts +++ b/src/api/module/transfer/index.ts @@ -17,7 +17,7 @@ export const getDeviceDetails = (params: IGetDeviceDataParams) => url: `/api/query`, method: 'POST', data: params, - timeout: 0, + timeout: 1000 * 50, }) export interface ISite { diff --git a/src/views/stationData/component/newDataChart.vue b/src/views/stationData/component/newDataChart.vue index deaf3d3..37c16e0 100644 --- a/src/views/stationData/component/newDataChart.vue +++ b/src/views/stationData/component/newDataChart.vue @@ -7,7 +7,7 @@ :autoresize="autoresize" :loading-options="loadingOpt" :loading="loading" - @legendselectchanged="changeLegend"/> + /> @@ -91,6 +91,7 @@ const chartOption = computed(() => { connectNulls: true, data: entry, sampling: 'lttb', + animation: false, } if (props.smooth) { lineData.smooth = true @@ -149,10 +150,10 @@ const chartOption = computed(() => { itemHeight: 10, pageIconSize: 12, data: props.legends.map(item => item.label), - selected: unCheckArr.value.reduce((acc, cur) => { - acc[cur] = false - return acc - }, {} as Record), + // selected: unCheckArr.value.reduce((acc, cur) => { + // acc[cur] = false + // return acc + // }, {} as Record), }, xAxis: { type: 'time', diff --git a/src/views/stationData/topology/components/detailDrawer.vue b/src/views/stationData/topology/components/detailDrawer.vue index bd83228..ca3efc1 100644 --- a/src/views/stationData/topology/components/detailDrawer.vue +++ b/src/views/stationData/topology/components/detailDrawer.vue @@ -46,8 +46,12 @@ :percentage="progress" status="success" /> -
-
当前加载数据量较大请稍等。。。
+
+ 正在加载数据,请稍等。
+ 当前已查询 + {{ reqPointCount }} / + {{ pointCount }} 个点位,剩余 + {{ remainingPointCount }} 个点位。
@@ -65,6 +69,10 @@ /> 查询数据 + 查询最近 + + 小时 () +const diffHours = ref() +const refreshKey = ref(0) + +const handleInput = debounce(async (val: number) => { + if (diffHours.value && val > diffHours.value) { + num.value = diffHours.value + refreshKey.value++ + await nextTick() + } else if (val < 1) { + num.value = 1 + refreshKey.value++ + await nextTick() + } else { + num.value = val + } + const endTime = + curDevice.value!.end_time ? + dayjs(curDevice.value!.end_time).valueOf() : dayjs().valueOf() + + const startTime = dayjs(endTime).subtract(num.value, 'hour').valueOf() + time.value = [dayjs(startTime).format('YYYY-MM-DD HH:mm:ss'), dayjs(endTime).format('YYYY-MM-DD HH:mm:ss')] +}, 300) + + const isShowDrawer = defineModel() const title = computed(() => ( @@ -133,6 +170,14 @@ async function open(device: IDevice & { message.error('获取点位数据失败') fullscreenLoading.value?.close() }) + const deviceOff = curDevice.value as IOfflineDevice + if (!deviceOff.start_time || !deviceOff.end_time) { + diffHours.value = 168 // 默认一周时间 + return + } + const start = dayjs(deviceOff.start_time) + const end = dayjs(deviceOff.end_time) + diffHours.value = end.diff(start, "hour") + 1; } const selectValue = ref() @@ -212,6 +257,13 @@ const chartLimit = ref(1000) const chartOffset = ref(0) const progress = ref(0) + +const pointCount = computed(() => chartAllTotal.value * checkPointList.value.length) +const reqPointCount = ref(0) + +// 剩余点位数 +const remainingPointCount = computed(() => pointCount.value - reqPointCount.value) + async function loadChardData() { if (!time.value || time.value.length !== 2) { message.error('请选择时间范围') @@ -287,11 +339,11 @@ async function loadChardData() { message.error('获取设备数据失败') return } + reqPointCount.value += res?.data?.results?.length || 0 const pointData = Array.isArray(res.data.results) ? res.data.results : [] setChartData(pointData) - progress.value = Math.min(100, Math.floor(((i + 1) / pageCount) * 100)) + progress.value = Math.min(100, Math.floor(((i + 1) / pageCount) * 100)) - 1 } - resetChartStatus() } @@ -344,6 +396,7 @@ function clearData() { legends.value = [] chartData.clear() axisData.clear() + reqPointCount.value = 0 } function resetChartStatus() { diff --git a/src/views/stationData/transfer/components/deviceDrawer.vue b/src/views/stationData/transfer/components/deviceDrawer.vue index 2c65846..1177715 100644 --- a/src/views/stationData/transfer/components/deviceDrawer.vue +++ b/src/views/stationData/transfer/components/deviceDrawer.vue @@ -30,8 +30,12 @@ :percentage="progress" status="success" /> -
-
当前加载数据量较大请稍等。。。
+
+ 正在加载数据,请稍等。
+ 当前已查询 + {{ reqPointCount }} / + {{ pointCount }} 个点位,剩余 + {{ remainingPointCount }} 个点位。
@@ -49,8 +53,11 @@ /> 查询数据 + 查询最近 + + 小时 - @@ -78,11 +85,36 @@ import dayjs from 'dayjs' import { nextTick } from "vue"; import EdfsWrap from "@/components/Edfs-wrap.vue"; import { bms_cellRewriteName } from "@/views/stationData/utils"; +import { debounce } from 'lodash-es' const time = ref<[string, string]>() const env = import.meta.env +const num = ref() +const diffHours = ref() +const refreshKey = ref(0) + +const handleInput = debounce(async (val: number) => { + if (diffHours.value && val > diffHours.value) { + num.value = diffHours.value + refreshKey.value++ + await nextTick() + } else if (val < 1) { + num.value = 1 + refreshKey.value++ + await nextTick() + } else { + num.value = val + } + const endTime = + curDevice.value!.end_time ? + dayjs(curDevice.value!.end_time).valueOf() : dayjs().valueOf() + + const startTime = dayjs(endTime).subtract(num.value, 'hour').valueOf() + time.value = [dayjs(startTime).format('YYYY-MM-DD HH:mm:ss'), dayjs(endTime).format('YYYY-MM-DD HH:mm:ss')] +}, 300) + const isShowDrawer = defineModel() const title = computed(() => @@ -117,6 +149,14 @@ async function open(device: IOfflineDevice | IOnlineDevice) { message.error('获取点位组数据失败') fullscreenLoading.value?.close() }) + const deviceOff = curDevice.value as IOfflineDevice + if (!deviceOff.start_time || !deviceOff.end_time) { + diffHours.value = 168 // 默认一周时间 + return + } + const start = dayjs(deviceOff.start_time) + const end = dayjs(deviceOff.end_time) + diffHours.value = end.diff(start, "hour") + 1; } @@ -187,6 +227,12 @@ const chartLimit = ref(1000) const chartOffset = ref(0) const progress = ref(0) +const pointCount = computed(() => chartAllTotal.value * checkPointList.value.length) +const reqPointCount = ref(0) + +// 剩余点位数 +const remainingPointCount = computed(() => pointCount.value - reqPointCount.value) + async function loadChardData() { if (!time.value || time.value.length !== 2) { message.error('请选择时间范围') @@ -260,11 +306,11 @@ async function loadChardData() { message.error('获取设备数据失败') return } + reqPointCount.value += res?.data?.results?.length || 0 const pointData = Array.isArray(res.data.results) ? res.data.results : [] setChartData(pointData) - progress.value = Math.min(100, Math.floor(((i + 1) / pageCount) * 100)) + progress.value = Math.min(100, Math.floor(((i + 1) / pageCount) * 100)) - 1 } - resetChartStatus() } @@ -315,6 +361,7 @@ function clearData() { legends.value = [] chartData.clear() axisData.clear() + reqPointCount.value = 0 } function resetChartStatus() {