fix: 首页接口对接
parent
a9d4bbc24d
commit
82fbd9bda3
|
@ -109,3 +109,18 @@ export function getAppList(params) {
|
||||||
export function getStatisticsDisplay(params) {
|
export function getStatisticsDisplay(params) {
|
||||||
return request.get(`${dashboardUrl}/userData/static`, { 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 })
|
||||||
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import LineCharts from './echarts/LineCharts.vue'
|
import LineCharts from './echarts/LineCharts.vue'
|
||||||
import ItemCard from './ItemCard.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'
|
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)']
|
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 = {
|
const chartSetting = {
|
||||||
|
@ -34,7 +34,7 @@ const chartSetting = {
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
components: { ItemCard, LineCharts },
|
components: { ItemCard, LineCharts },
|
||||||
setup(props, context) {
|
setup() {
|
||||||
const countData = ref([
|
const countData = ref([
|
||||||
{
|
{
|
||||||
name: '紧急告警',
|
name: '紧急告警',
|
||||||
|
@ -54,18 +54,40 @@ export default {
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
;(async function () {
|
;(async function () {
|
||||||
const res = await getAlarmChart({ action: 'pieChart' })
|
const res = await getOneDayWarnCount()
|
||||||
countData.value = res.data
|
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({
|
const lineData = ref({
|
||||||
keys: [],
|
keys: [],
|
||||||
values: []
|
values: []
|
||||||
})
|
})
|
||||||
;(async function () {
|
;(async function () {
|
||||||
const end = new Date().setHours(0, 0, 0, 0) / 1000
|
|
||||||
// 一天是86400秒
|
// 一天是86400秒
|
||||||
const res = await getAlarmChart({ action: 'barChart', start: end - 86400 * 7, end })
|
const res = await getSevenDayWarnTrend()
|
||||||
res.data.values = res.data.values.map((item, index) => {
|
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 = {
|
item.series = {
|
||||||
areaStyle: {
|
areaStyle: {
|
||||||
opacity: 0.1,
|
opacity: 0.1,
|
||||||
|
@ -83,7 +105,7 @@ export default {
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
lineData.value = res.data
|
lineData.value = result
|
||||||
})()
|
})()
|
||||||
return {
|
return {
|
||||||
colorMap,
|
colorMap,
|
||||||
|
|
|
@ -23,10 +23,10 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
numList: [
|
numList: [
|
||||||
{ label: '服务器(台)', value: 36, bgImg: 服务器, background: 'rgba(231, 242, 252, 1)' },
|
{ label: '服务器(台)', value: 0, bgImg: 服务器, background: 'rgba(231, 242, 252, 1)' },
|
||||||
{ label: '虚拟机(台)', value: 20, bgImg: 虚拟机, background: 'rgba(250, 243, 233, 1)' },
|
{ label: '虚拟机(台)', value: 0, bgImg: 虚拟机, background: 'rgba(250, 243, 233, 1)' },
|
||||||
{ label: '网络设备(台)', value: 20, bgImg: 网络设备, background: 'rgba(227, 245, 252, 1)' },
|
{ label: '网络设备(台)', value: 0, bgImg: 网络设备, background: 'rgba(227, 245, 252, 1)' },
|
||||||
{ label: '安全设备(台)', value: 20, bgImg: 安全设备, background: 'rgba(235, 246, 239, 1)' }
|
{ label: '安全设备(台)', value: 0, bgImg: 安全设备, background: 'rgba(235, 246, 239, 1)' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
numList: [
|
numList: [
|
||||||
{ label: '当前用户授权应用数', value: 0, bgImg: 当前用户授权应用数 },
|
{ label: '应用授权个数', value: 0, bgImg: 当前用户授权应用数 },
|
||||||
{ label: '数据权限申请数量', value: 0, bgImg: 数据权限申请数量 }
|
{ label: '运维任务个数', value: 0, bgImg: 数据权限申请数量 }
|
||||||
],
|
],
|
||||||
statistics: [
|
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() {
|
getItemList() {
|
||||||
getStatisticsDisplay().then(data => {
|
getStatisticsDisplay().then(data => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
this.numList[0].value = data.data.userAppCount
|
this.numList[0].value = data.data.find(item => item.title === '应用授权个数')?.num || 0
|
||||||
this.numList[1].value = data.data.userAuthList
|
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[0].value = data.data.
|
this.statistics[1].value = data.data.find(item => item.title === '数据调度申请')?.num || 0
|
||||||
this.statistics[1].value = data.data.taskCount
|
this.statistics[2].value = data.data.find(item => item.title === '数据权限申请')?.num || 0
|
||||||
// this.statistics[2].value = data.data.
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
<ItemCard title="告警列表" v-bind="$attrs">
|
<ItemCard title="告警列表" v-bind="$attrs">
|
||||||
<cb-table :data="tableList" :params="params" :get-list="getItemList" :total="total">
|
<cb-table :data="tableList" :params="params" :get-list="getItemList" :total="total">
|
||||||
<el-table-column type="index" width="50" label="序号"> </el-table-column>
|
<el-table-column type="index" width="50" label="序号"> </el-table-column>
|
||||||
<el-table-column show-overflow-tooltip label="标题" prop="name"></el-table-column>
|
<el-table-column show-overflow-tooltip label="标题" prop="alarmName"></el-table-column>
|
||||||
<el-table-column show-overflow-tooltip label="级别" prop="level"></el-table-column>
|
<el-table-column show-overflow-tooltip label="级别">
|
||||||
<el-table-column show-overflow-tooltip label="告警类型" prop="type"></el-table-column>
|
<template slot-scope="scope">
|
||||||
<el-table-column show-overflow-tooltip label="告警来源" prop="time"></el-table-column>
|
<div class="flex"><img :src="getSeverity(scope.row.severity).icon" alt="" /> {{ getSeverity(scope.row.severity).text }}</div>
|
||||||
<el-table-column show-overflow-tooltip label="时间" prop="time"></el-table-column>
|
</template>
|
||||||
<el-table-column show-overflow-tooltip label="操作" width="50">
|
</el-table-column>
|
||||||
|
<el-table-column show-overflow-tooltip label="告警类型" prop="typeName"></el-table-column>
|
||||||
|
<el-table-column show-overflow-tooltip label="告警来源" prop="sourceName"></el-table-column>
|
||||||
|
<el-table-column show-overflow-tooltip label="时间" prop="createTime"></el-table-column>
|
||||||
|
<el-table-column show-overflow-tooltip label="操作" width="80">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<cb-link @click="handleWarningOperation(scope.row)">查看工单</cb-link>
|
<cb-link @click="handleWarningOperation(scope.row)">查看工单</cb-link>
|
||||||
</template>
|
</template>
|
||||||
|
@ -18,8 +22,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ItemCard from './ItemCard.vue'
|
import ItemCard from './ItemCard.vue'
|
||||||
// import { mockHttp } from 'services/system/dashboard'
|
import { getWarnList } from 'services/system/dashboard'
|
||||||
|
import 严重 from './images/警告级别-严重.png'
|
||||||
|
import 重要 from './images/警告级别-重要.png'
|
||||||
|
import 次要 from './images/警告级别-次要.png'
|
||||||
|
import 常规 from './images/警告级别-常规.png'
|
||||||
|
import dayjs from 'utils/day'
|
||||||
export default {
|
export default {
|
||||||
components: { ItemCard },
|
components: { ItemCard },
|
||||||
data() {
|
data() {
|
||||||
|
@ -32,14 +40,41 @@ export default {
|
||||||
total: 0
|
total: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.getItemList()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getSeverity(val) {
|
||||||
|
const map = {
|
||||||
|
1: {
|
||||||
|
text: '严重告警',
|
||||||
|
icon: 严重
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
text: '重要告警',
|
||||||
|
icon: 重要
|
||||||
|
},
|
||||||
|
3: {
|
||||||
|
text: '次要告警',
|
||||||
|
icon: 次要
|
||||||
|
},
|
||||||
|
4: {
|
||||||
|
text: '常规告警',
|
||||||
|
icon: 常规
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map[val] || { text: '未知', icon: '' }
|
||||||
|
},
|
||||||
getItemList() {
|
getItemList() {
|
||||||
// mockHttp(this.params).then(data => {
|
getWarnList(this.params).then(data => {
|
||||||
// if (data.success) {
|
if (data.success) {
|
||||||
// this.tableList = data.data.rows
|
this.tableList = data.data.map(item => {
|
||||||
// this.total = data.data.total
|
item.createTime = dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss')
|
||||||
// }
|
return item
|
||||||
// })
|
})
|
||||||
|
// this.total = data.data.total
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleWarningOperation(row) {
|
handleWarningOperation(row) {
|
||||||
console.log('处理告警', row)
|
console.log('处理告警', row)
|
||||||
|
@ -47,3 +82,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 13px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue