From 82fbd9bda32c3d893b062b49b8a554e497b30bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Tue, 27 Aug 2024 17:49:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webs/sms-web/src/services/system/dashboard.js | 15 ++++ .../new_dashboard_component/AlarmHandling.vue | 38 +++++++--- .../PlatformCapacity.vue | 8 +-- .../StatisticsDisplay.vue | 21 +++--- .../new_dashboard_component/WarningList.vue | 70 +++++++++++++++---- 5 files changed, 115 insertions(+), 37 deletions(-) diff --git a/webs/sms-web/src/services/system/dashboard.js b/webs/sms-web/src/services/system/dashboard.js index e1f7f9e..01589b8 100644 --- a/webs/sms-web/src/services/system/dashboard.js +++ b/webs/sms-web/src/services/system/dashboard.js @@ -109,3 +109,18 @@ export function getAppList(params) { export function getStatisticsDisplay(params) { return request.get(`${dashboardUrl}/userData/static`, { params }) } + +// 七天告警趋势 +export function getSevenDayWarnTrend(params) { + return request.get(`${dashboardUrl}/sevenDayWarnTrend`, { params }) +} + +// 告警统计 +export function getOneDayWarnCount(params) { + return request.get(`${dashboardUrl}/oneDayWarnCount`, { params }) +} + +// 告警列表 +export function getWarnList(params) { + return request.get(`${dashboardUrl}/warnList`, { params }) +} diff --git a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/AlarmHandling.vue b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/AlarmHandling.vue index 07ac874..f0f789a 100644 --- a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/AlarmHandling.vue +++ b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/AlarmHandling.vue @@ -20,7 +20,7 @@ import { ref } from 'vue' import LineCharts from './echarts/LineCharts.vue' import ItemCard from './ItemCard.vue' -import { getAlarmChart } from 'services/monitor/index' +import { getOneDayWarnCount, getSevenDayWarnTrend } from 'services/system/dashboard' import echarts from '@cmp/cmp-echarts/hooks/echarts' export const colorMap = ['rgba(255, 0, 0, 1)', 'rgba(245, 167, 45, 1)', 'rgba(18, 185, 242, 1)', 'rgba(24, 144, 255, 1)'] const chartSetting = { @@ -34,7 +34,7 @@ const chartSetting = { } export default { components: { ItemCard, LineCharts }, - setup(props, context) { + setup() { const countData = ref([ { name: '紧急告警', @@ -54,18 +54,40 @@ export default { } ]) ;(async function () { - const res = await getAlarmChart({ action: 'pieChart' }) - countData.value = res.data + const res = await getOneDayWarnCount() + if (!res.success) return + countData.value[0].value = res.data.critical + countData.value[1].value = res.data.major + countData.value[2].value = res.data.minor + countData.value[3].value = res.data.warning })() const lineData = ref({ keys: [], values: [] }) ;(async function () { - const end = new Date().setHours(0, 0, 0, 0) / 1000 // 一天是86400秒 - const res = await getAlarmChart({ action: 'barChart', start: end - 86400 * 7, end }) - res.data.values = res.data.values.map((item, index) => { + const res = await getSevenDayWarnTrend() + if (!res.success) return + const names = Object.keys(res.data) + const nameMap = { + 1: '紧急告警', + 2: '重要告警', + 3: '次要告警', + 4: '提示告警' + } + if (!names.length) return + + const result = { + keys: res.data[names[0]].map(({ date }) => date), + values: names.map(name => { + return { + name: nameMap[name], + data: res.data[name].map(({ count }) => count) + } + }) + } + result.values = result.values.map((item, index) => { item.series = { areaStyle: { opacity: 0.1, @@ -83,7 +105,7 @@ export default { } return item }) - lineData.value = res.data + lineData.value = result })() return { colorMap, diff --git a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/PlatformCapacity.vue b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/PlatformCapacity.vue index 6794e69..4488c3e 100644 --- a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/PlatformCapacity.vue +++ b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/PlatformCapacity.vue @@ -23,10 +23,10 @@ export default { data() { return { numList: [ - { label: '服务器(台)', value: 36, bgImg: 服务器, background: 'rgba(231, 242, 252, 1)' }, - { label: '虚拟机(台)', value: 20, bgImg: 虚拟机, background: 'rgba(250, 243, 233, 1)' }, - { label: '网络设备(台)', value: 20, bgImg: 网络设备, background: 'rgba(227, 245, 252, 1)' }, - { label: '安全设备(台)', value: 20, bgImg: 安全设备, background: 'rgba(235, 246, 239, 1)' } + { label: '服务器(台)', value: 0, bgImg: 服务器, background: 'rgba(231, 242, 252, 1)' }, + { label: '虚拟机(台)', value: 0, bgImg: 虚拟机, background: 'rgba(250, 243, 233, 1)' }, + { label: '网络设备(台)', value: 0, bgImg: 网络设备, background: 'rgba(227, 245, 252, 1)' }, + { label: '安全设备(台)', value: 0, bgImg: 安全设备, background: 'rgba(235, 246, 239, 1)' } ] } } diff --git a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/StatisticsDisplay.vue b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/StatisticsDisplay.vue index 294d12b..0a2415d 100644 --- a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/StatisticsDisplay.vue +++ b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/StatisticsDisplay.vue @@ -30,13 +30,13 @@ export default { data() { return { numList: [ - { label: '当前用户授权应用数', value: 0, bgImg: 当前用户授权应用数 }, - { label: '数据权限申请数量', value: 0, bgImg: 数据权限申请数量 } + { label: '应用授权个数', value: 0, bgImg: 当前用户授权应用数 }, + { label: '运维任务个数', value: 0, bgImg: 数据权限申请数量 } ], statistics: [ - { label: '数据调度任务量', value: 0 }, - { label: '运维任务申请表', value: 0 }, - { label: '日志审计任务量', value: 0 } + { label: '云资源申请', value: 0 }, + { label: '数据调度申请', value: 0 }, + { label: '数据权限申请', value: 0 } ] } }, @@ -48,12 +48,11 @@ export default { getItemList() { getStatisticsDisplay().then(data => { if (data.success) { - this.numList[0].value = data.data.userAppCount - this.numList[1].value = data.data.userAuthList - // 还有两个数据暂时没找到第三方接口 - // this.statistics[0].value = data.data. - this.statistics[1].value = data.data.taskCount - // this.statistics[2].value = data.data. + this.numList[0].value = data.data.find(item => item.title === '应用授权个数')?.num || 0 + this.numList[1].value = data.data.find(item => item.title === '运维任务个数')?.num || 0 + this.statistics[0].value = data.data.find(item => item.title === '云资源申请')?.num || 0 + this.statistics[1].value = data.data.find(item => item.title === '数据调度申请')?.num || 0 + this.statistics[2].value = data.data.find(item => item.title === '数据权限申请')?.num || 0 } }) } diff --git a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/WarningList.vue b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/WarningList.vue index 3eceda5..206887f 100644 --- a/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/WarningList.vue +++ b/webs/sms-web/src/views/configs/setting_dashboard/new_dashboard_component/WarningList.vue @@ -2,12 +2,16 @@ - - - - - - + + + + + + + + @@ -18,8 +22,12 @@ +