From cd0323b6bf7f38f53ef6de8f9e333fdc95a5057a 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, 13 Aug 2024 17:01:24 +0800 Subject: [PATCH] =?UTF-8?q?CN-1676=20fix:=201=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=B7=A6=E4=BE=A7filter=E7=9A=84key=E5=8C=85=E5=90=AB=E5=A4=9A?= =?UTF-8?q?=E4=B8=AAkeyFields=E6=97=B6=EF=BC=8C=E7=82=B9=E5=87=BB=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=A4=84=E7=90=86=E6=95=B0=E6=8D=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=9D=9E=E7=A9=BA=E5=88=A4=E6=96=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/css/common/table-common.scss | 4 ++ src/views/detections/DetectionRow.vue | 4 +- src/views/detections/Index.vue | 18 +++++- .../overview/detectionDetailMixin.js | 55 +++++++++++-------- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/src/assets/css/common/table-common.scss b/src/assets/css/common/table-common.scss index 094c6656..e4ceaf16 100644 --- a/src/assets/css/common/table-common.scss +++ b/src/assets/css/common/table-common.scss @@ -230,6 +230,10 @@ margin-bottom: 10px; } +.margin-l-16 { + margin-left: 16px; +} + .padding-r-20 { padding-right: 20px; } diff --git a/src/views/detections/DetectionRow.vue b/src/views/detections/DetectionRow.vue index 449ceea7..cfcdda93 100644 --- a/src/views/detections/DetectionRow.vue +++ b/src/views/detections/DetectionRow.vue @@ -11,7 +11,7 @@
- {{ detection.eventName || '-' }} + {{ detection.eventName || '-' }}
{{item.key}} ({{ item.type }}) @@ -22,7 +22,7 @@
-
+
{{$t('detections.eventType')}} :   {{detection.eventType || '-'}} diff --git a/src/views/detections/Index.vue b/src/views/detections/Index.vue index 436e5581..f3c08991 100644 --- a/src/views/detections/Index.vue +++ b/src/views/detections/Index.vue @@ -701,10 +701,24 @@ export default { this.$refs.search.changeParams([params]) } else if (topColumn === 'keyFields') { const nameList = name.split(',') + + // 多个keyField、keyValues时进行拆分匹配 + const mid = Math.ceil(nameList.length / 2) + const fieldsList = nameList.slice(0, mid) + const valuesList = nameList.slice(mid) + const columnList = this.filterData[2].topColumn.split(',') - nameList.forEach((item, index) => { + fieldsList.forEach(item => { const params = { - column: columnList[index], + column: columnList[0], + operator: '=', + value: item + } + this.$refs.search.changeParams([params]) + }) + valuesList.forEach(item => { + const params = { + column: columnList[1], operator: '=', value: item } diff --git a/src/views/detections/overview/detectionDetailMixin.js b/src/views/detections/overview/detectionDetailMixin.js index d3f95d31..6b82a313 100644 --- a/src/views/detections/overview/detectionDetailMixin.js +++ b/src/views/detections/overview/detectionDetailMixin.js @@ -110,29 +110,35 @@ export default { if (res.status === 200) { // 类型为Threshold时处理折线图 if (this.detection.ruleType === detectionRuleType.threshold.key) { - const seriesData = [] - res.data.data.result.forEach(item => { - seriesData.push([getMillisecond(JSON.parse(item.statTime)), item.recordsNums]) - }) - this.lineOption.series[0].data = seriesData - this.lineOption.series[0].color = getSeverityNumberColor(res.data.data.result[0].severity) || '#ff9a79' + const data = res.data.data.result + if (data && data.length > 0) { + const seriesData = [] + data.forEach(item => { + seriesData.push([getMillisecond(JSON.parse(item.statTime)), item.recordsNums]) + }) + this.lineOption.series[0].data = seriesData + this.lineOption.series[0].color = getSeverityNumberColor(res.data.data.result[0].severity) || '#ff9a79' - this.seriesDataNum = seriesData.length - if (this.seriesDataNum <= 1) { - this.lineOption.series[0].symbol = 'circle' - this.lineOption.series[0].symbolSize = 9 - } else { - this.lineOption.series[0].symbol = 'none' + this.seriesDataNum = seriesData.length + if (this.seriesDataNum <= 1) { + this.lineOption.series[0].symbol = 'circle' + this.lineOption.series[0].symbolSize = 9 + } else { + this.lineOption.series[0].symbol = 'none' + } + + this.myChart = markRaw(echarts.init(document.getElementById('myChart' + this.detection.eventId))) + this.myChart.setOption(this.lineOption) } - - this.myChart = markRaw(echarts.init(document.getElementById('myChart' + this.detection.eventId))) - this.myChart.setOption(this.lineOption) } else { - const detailData = res.data.data.result.pop() - if (detailData?.eventInfo) { - detailData.eventInfoList = JSON.parse(detailData.eventInfo) + const data = res.data.data.result + if (data && data.length > 0) { + const detailData = res.data.data.result.pop() + if (detailData?.eventInfo) { + detailData.eventInfoList = JSON.parse(detailData.eventInfo) + } + this.myDetection = { ...detailData, ...this.detection } } - this.myDetection = { ...detailData, ...this.detection } } } }).catch(e => { @@ -150,11 +156,14 @@ export default { } axios.get(api.detection.event.detail, { params }).then(res => { if (res.status === 200) { - const detailData = res.data.data.result[0] - if (detailData.eventInfo) { - detailData.eventInfoList = JSON.parse(detailData.eventInfo) + const data = res.data.data.result + if (data && data.length > 0) { + const detailData = data[0] + if (detailData.eventInfo) { + detailData.eventInfoList = JSON.parse(detailData.eventInfo) + } + this.myDetection = { ...this.myDetection, ...detailData } } - this.myDetection = { ...this.myDetection, ...detailData } } }).catch(e => { this.$message.error(this.errorMsgHandler(e))