From d693885f7a84a9d41de5129bbfa7c6cf8771d6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Tue, 27 Aug 2024 17:10:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201=E3=80=81=E4=BC=98=E5=8C=96detection?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=8A=98=E7=BA=BF=E5=9B=BEy=E5=91=A8?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E8=BF=87=E5=A4=A7=E8=BD=AC=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=9B2=E3=80=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=8B=A5=E4=B8=BAactive=EF=BC=8C=E6=97=B6=E9=97=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BALast=20Time=EF=BC=8C=E5=90=A6=E5=88=99=E4=BD=8DEnd=20T?= =?UTF-8?q?ime=EF=BC=9B3=E3=80=81=E5=88=97=E8=A1=A8=E6=8C=81=E7=BB=AD?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B0=8F=E4=BA=8E10s=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=20lasting=20a=20few=20seconds=EF=BC=9B4=E3=80=81unord?= =?UTF-8?q?ered=EF=BC=89sequence=20=E4=B8=A4=E7=A7=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=BF=9D=E7=95=99Time?= =?UTF-8?q?=EF=BC=8C=E5=8F=96Recv=5Ftime=E7=9A=84=E5=80=BC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/detections/detection-overview.scss | 5 ++ src/views/detections/DetectionRow.vue | 6 ++- src/views/detections/DetectionRowEvents.vue | 3 +- .../detections/options/detectionOptions.js | 19 ++++++++ .../detections/overview/EventsTimeline.vue | 7 ++- .../detections/overview/SequenceOverview.vue | 4 +- .../detections/overview/ThresholdOverview.vue | 2 +- .../overview/detectionDetailMixin.js | 47 +++++++++++++++++-- 8 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/assets/css/components/views/detections/detection-overview.scss b/src/assets/css/components/views/detections/detection-overview.scss index 36220fbc..0bec52fb 100644 --- a/src/assets/css/components/views/detections/detection-overview.scss +++ b/src/assets/css/components/views/detections/detection-overview.scss @@ -176,6 +176,11 @@ $color-regular: var(--el-text-color-regular); .overview__left-new { flex: 0 0 100%; } + + .detection-detail__loading { + width: 100%; + padding-bottom: 60px; + } } .overview__row-timeline { display: flex; diff --git a/src/views/detections/DetectionRow.vue b/src/views/detections/DetectionRow.vue index c568dd34..184a3b76 100644 --- a/src/views/detections/DetectionRow.vue +++ b/src/views/detections/DetectionRow.vue @@ -34,15 +34,17 @@
- {{$t('detection.list.endTime')}} :   + {{$t('detection.lastTime')}} :   + {{$t('detection.list.endTime')}} :   {{dateFormatByAppearance(detection.endTime) || '-'}}
{{$t('overall.duration')}} :   - + {{unitConvert(parseInt(detection.durationS), 'time', 's', null, 0).join(' ') || '-'}} + {{ $t('detection.list.lastingSeconds')}}
{{$t('detections.active')}}
diff --git a/src/views/detections/DetectionRowEvents.vue b/src/views/detections/DetectionRowEvents.vue index 011480a8..ef32ec1c 100644 --- a/src/views/detections/DetectionRowEvents.vue +++ b/src/views/detections/DetectionRowEvents.vue @@ -34,7 +34,8 @@
- {{$t('detection.lastTime')}} :   + {{$t('detection.lastTime')}} :   + {{$t('detection.list.endTime')}} :   {{dateFormatByAppearance(detection.endTime) || '-'}}
diff --git a/src/views/detections/options/detectionOptions.js b/src/views/detections/options/detectionOptions.js index 0f504cdc..b8ac3379 100644 --- a/src/views/detections/options/detectionOptions.js +++ b/src/views/detections/options/detectionOptions.js @@ -487,6 +487,25 @@ export const lineOption = { yAxis: { splitLine: { show: false + }, + scale: true, + axisLabel: { + formatter: function (value) { + switch (true) { + case (value < 1000): { + return value + } + case ((value / (1000)) >= 1): { + return (value / (1000)).toFixed(1) + 'k' + } + case (value / (10000)) >= 1: { + return (value / (10000)).toFixed(1) + 'w' + } + case (value / (10000000)) >= 1: { + return (value / (10000000)).toFixed(1) + 'kw' + } + } + } } }, grid: { diff --git a/src/views/detections/overview/EventsTimeline.vue b/src/views/detections/overview/EventsTimeline.vue index e49c2018..93b788e1 100644 --- a/src/views/detections/overview/EventsTimeline.vue +++ b/src/views/detections/overview/EventsTimeline.vue @@ -35,14 +35,17 @@ export default { timeFilter: { type: Object }, - timeData: Array + timeData: Array, + lineWidth: { // 时间轴宽度 + type: Number, + default: 520 + } }, data () { return { timeLine: [], myTimeData: [], activeCircle: 0, - lineWidth: 520, // 时间轴宽度 isTransform: false // 时间轴label是否旋转标识,文字高度超出16即为换行,将文字旋转角度 } }, diff --git a/src/views/detections/overview/SequenceOverview.vue b/src/views/detections/overview/SequenceOverview.vue index 5df8c8eb..e8796266 100644 --- a/src/views/detections/overview/SequenceOverview.vue +++ b/src/views/detections/overview/SequenceOverview.vue @@ -16,7 +16,7 @@
{{ $t('detection.detail.stage') }}{{ index + 1 }}
-
+
{{ fields }}
@@ -35,7 +35,7 @@
Time
- {{ myDetection.startTime ? dateFormatByAppearance(myDetection.startTime) : '-' }} + {{ obj.recv_time ? dateFormatByAppearance(obj.recv_time) : '-' }}
diff --git a/src/views/detections/overview/ThresholdOverview.vue b/src/views/detections/overview/ThresholdOverview.vue index 82638358..6aff0ffe 100644 --- a/src/views/detections/overview/ThresholdOverview.vue +++ b/src/views/detections/overview/ThresholdOverview.vue @@ -29,7 +29,7 @@
{{ $t('detection.timeOfOccurrences') }}
- +
diff --git a/src/views/detections/overview/detectionDetailMixin.js b/src/views/detections/overview/detectionDetailMixin.js index 7bfa0bb8..ad1a3e40 100644 --- a/src/views/detections/overview/detectionDetailMixin.js +++ b/src/views/detections/overview/detectionDetailMixin.js @@ -6,6 +6,7 @@ import { getSeverityNumberColor, lineOption } from '@/views/detections/options/d import { markRaw } from 'vue' import * as echarts from 'echarts' import { getSeverityByCode } from '@/utils/tools' +import Loading from '@/components/common/Loading' export default { props: { @@ -25,9 +26,15 @@ export default { lineOption: lineOption, seriesDataNum: 0, mapColor: [], - markLineData: [] + markLineData: [], + mapWidth: 550, // 折线图底部色条宽度 + lineWidth: 520, // 时间轴宽度 + loading: true } }, + components: { + Loading + }, computed: { // 下拉详情的描述 handleDescription () { @@ -67,6 +74,7 @@ export default { }, methods: { initData () { + this.loading = true this.myDetection = this.detection if (this.eventFlag === detectionEventType.aggregation) { this.isGroup = 1 @@ -90,6 +98,8 @@ export default { } }).catch(e => { this.$message.error(this.errorMsgHandler(e)) + }).finally(() => { + this.loading = false }) } else { this.isGroup = 0 @@ -115,7 +125,7 @@ export default { } else { const data = res.data.data.result if (data && data.length > 0) { - const detailData = res.data.data.result.pop() + const detailData = this.$_.cloneDeep(res.data.data.result).pop() if (detailData?.eventInfo) { detailData.eventInfoList = JSON.parse(detailData.eventInfo) } @@ -126,9 +136,12 @@ export default { }).catch(e => { console.error(e) this.$message.error(this.errorMsgHandler(e)) + }).finally(() => { + this.loading = false }) }, changeTimeline (e) { + this.loading = true const params = { startTime: getSecond(this.timeFilter.startTime), endTime: getSecond(this.timeFilter.endTime), @@ -160,6 +173,8 @@ export default { }).catch(e => { console.error(e) this.$message.error(this.errorMsgHandler(e)) + }).finally(() => { + this.loading = false }) }, // 挂载echarts折线图 @@ -194,6 +209,32 @@ export default { } } }) + + // 计算折线图左侧宽度 + const maxValue = Math.max(...data.map(obj => obj.recordsNum)) + if (maxValue >= 1000) { + let yAxisLabel = '' // y轴显示的值 + if ((maxValue / (1000)) >= 1) { + yAxisLabel = (maxValue / (1000)).toFixed(1) + 'k' + } else if ((maxValue / (10000)) >= 1) { + yAxisLabel = (maxValue / (10000)).toFixed(1) + 'w' + } else if ((maxValue / (10000000)) >= 1) { + yAxisLabel = (maxValue / (10000000)).toFixed(1) + 'kw' + } + + const labelLength = yAxisLabel.length - 4 + if (labelLength > 0) { + // 默认显示最大的9.9w,即距离左边距30px,超出部分的每个字符8px宽度 + this.lineOption.grid.left = (30 + labelLength * 8) + 'px' + this.mapWidth = 550 - (labelLength * 8) + this.lineWidth = 520 - (labelLength * 8) + } + } else { + this.lineOption.grid.left = '30px' + this.mapWidth = 550 + this.lineWidth = 520 + } + this.lineOption.series[0].data = seriesData this.seriesDataNum = seriesData.length @@ -228,7 +269,7 @@ export default { data.forEach((item, index) => { let width = 0 if (index > 0) { - width = ((item.startTime - data[index - 1].startTime) / diffTime) * 550 + width = ((item.startTime - data[index - 1].startTime) / diffTime) * this.mapWidth } this.mapColor.push({ color: getSeverityNumberColor(item.severity),