|
@@ -1,6 +1,12 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="0">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" plain @click="timeSelect(0)">今天</el-button>
|
|
|
+ <el-button type="primary" plain @click="timeSelect(3)">3天</el-button>
|
|
|
+ <el-button type="primary" plain @click="timeSelect(7)">7天</el-button>
|
|
|
+ <el-button type="primary" plain @click="timeSelect(30)">1月</el-button>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="" style="width: 308px;margin-right:10px">
|
|
|
<el-date-picker
|
|
|
v-model="daterangeAlarmTime"
|
|
@@ -16,36 +22,27 @@
|
|
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
- <el-card>
|
|
|
- <div ref="chartType" style="height: 600px;"></div>
|
|
|
- </el-card>
|
|
|
-<!-- <el-table v-loading="loading" :data="recordList" border >-->
|
|
|
-<!-- <el-table-column label="业务类型" align="center" >-->
|
|
|
-<!-- <template #default="scope">-->
|
|
|
-<!-- <span v-if="biz_type.length">{{ biz_type.find(p=>p.value === scope.row.bizType ).label }}</span>-->
|
|
|
-<!-- </template>-->
|
|
|
-<!-- </el-table-column>-->
|
|
|
-<!-- <el-table-column label="告警值" align="center" prop="num" />-->
|
|
|
-<!-- <el-table-column label="操作" align="center" prop="alarmTime" width="180">-->
|
|
|
-<!-- <template #default="scope">-->
|
|
|
-<!-- <el-button type="text" plain icon="Position" @click="handleDetails(scope.row)">明细</el-button>-->
|
|
|
-<!-- </template>-->
|
|
|
-<!-- </el-table-column>-->
|
|
|
-<!-- </el-table>-->
|
|
|
-<!-- <pagination-->
|
|
|
-<!-- v-show="total>0"-->
|
|
|
-<!-- :total="total"-->
|
|
|
-<!-- v-model:page="queryParams.pageNum"-->
|
|
|
-<!-- v-model:limit="queryParams.pageSize"-->
|
|
|
-<!-- @pagination="getList"-->
|
|
|
-<!-- />-->
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-card>
|
|
|
+ <div ref="chartType" style="height: 600px;"></div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-card>
|
|
|
+ <div ref="chartRightType" style="height: 600px;">请点击左边柱状图</div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup name="Record">
|
|
|
-import {getBizType} from "@/api/alarm/record";
|
|
|
+import {getBizType,getBizObj} from "@/api/alarm/record";
|
|
|
import {useRouter} from "vue-router";
|
|
|
import * as echarts from 'echarts'
|
|
|
+import moment from 'moment'
|
|
|
+
|
|
|
const {proxy} = getCurrentInstance();
|
|
|
const {alarm_level} = proxy.useDict('alarm_level');
|
|
|
const {biz_type} = proxy.useDict('biz_type');
|
|
@@ -56,6 +53,7 @@ const showSearch = ref(true);
|
|
|
const total = ref(0);
|
|
|
const title = ref("");
|
|
|
const chartType = ref();
|
|
|
+const chartRightType = ref();
|
|
|
const daterangeAlarmTime = ref([]);
|
|
|
const router = useRouter();
|
|
|
|
|
@@ -63,30 +61,249 @@ const data = reactive({
|
|
|
form: {},
|
|
|
queryParams: {
|
|
|
start: null,
|
|
|
- end: null
|
|
|
+ end: null,
|
|
|
+ type:null
|
|
|
},
|
|
|
});
|
|
|
|
|
|
const {queryParams, form, rules} = toRefs(data);
|
|
|
|
|
|
-function handleDetails(row){
|
|
|
- console.log(row,router)
|
|
|
+function handleDetails(row) {
|
|
|
+ console.log(row, router)
|
|
|
}
|
|
|
-function initChart(res){
|
|
|
+
|
|
|
+function initChart(res) {
|
|
|
const myChart = echarts.init(chartType.value);
|
|
|
- let colorList = ['#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093','#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093'];
|
|
|
+ let colorList = ['#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093', '#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093'];
|
|
|
+ var ydata = [];
|
|
|
+ var salvProValue = [];
|
|
|
+ for (const i in res.data) {
|
|
|
+ let obj = res.data[i]
|
|
|
+ ydata.push(obj.name);
|
|
|
+ salvProValue.push({id:obj.id,value:obj.num});
|
|
|
+ if (i == 0) {
|
|
|
+ rightData(obj.id,obj.name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let option = {
|
|
|
+ title: {
|
|
|
+ show: true,
|
|
|
+ text: '业务类型统计',
|
|
|
+ textStyle: {
|
|
|
+ fontFamily: 'PingFangSC-Regular, PingFang SC',
|
|
|
+ align: 'center',
|
|
|
+ color: '#515961',
|
|
|
+ fontSize: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ backgroundColor: '#fff',
|
|
|
+ grid: {
|
|
|
+ left: '2%',
|
|
|
+ right: '10%',
|
|
|
+ bottom: '2%',
|
|
|
+ top: '2%',
|
|
|
+ containLabel: true,
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis',
|
|
|
+ axisPointer: {
|
|
|
+ type: 'none'
|
|
|
+ },
|
|
|
+ formatter: '{b}:{c}',
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ show: false,
|
|
|
+ type: 'value',
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "category",
|
|
|
+ data: ydata,
|
|
|
+ axisLine: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ margin: 30,
|
|
|
+ width: 16,
|
|
|
+ align: "left",
|
|
|
+ overflow: "truncate",
|
|
|
+ formatter: function (value, index) {
|
|
|
+ let ind = index + 1;
|
|
|
+ if (ind == ydata.length) {
|
|
|
+ return "{one|" + (ydata.length - index) + "} {a|" + value + "}";
|
|
|
+ } else if (ind + 1 == ydata.length) {
|
|
|
+ return "{two|" + (ydata.length - index) + "} {b|" + value + "}";
|
|
|
+ } else if (ind + 2 == ydata.length) {
|
|
|
+ return (
|
|
|
+ "{three|" + (ydata.length - index) + "} {c|" + value + "}"
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (ydata.length - index > 9) {
|
|
|
+ return (
|
|
|
+ "{five|" + (ydata.length - index) + "} {d|" + value + "}"
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return "{four|" + (ydata.length - index) + "} {d|" + value + "}";
|
|
|
+ },
|
|
|
+ rich: {
|
|
|
+ a: {
|
|
|
+ color: "#59c9f9",
|
|
|
+ },
|
|
|
+ b: {
|
|
|
+ color: "#59c9f9",
|
|
|
+ },
|
|
|
+ c: {
|
|
|
+ color: "#59c9f9",
|
|
|
+ },
|
|
|
+ d: {
|
|
|
+ color: "#59c9f9",
|
|
|
+ },
|
|
|
+ // 第一名
|
|
|
+ one: {
|
|
|
+ backgroundColor: "#E86452",
|
|
|
+ color: "white",
|
|
|
+ width: 12,
|
|
|
+ height: 16,
|
|
|
+ padding: [1, 0, 0, 5],
|
|
|
+ borderRadius: 10,
|
|
|
+ fontSize: 11,
|
|
|
+ },
|
|
|
+ // 第二名
|
|
|
+ two: {
|
|
|
+ backgroundColor: "#FF9845",
|
|
|
+ color: "white",
|
|
|
+ width: 12,
|
|
|
+ height: 16,
|
|
|
+ padding: [1, 0, 0, 5],
|
|
|
+ borderRadius: 10,
|
|
|
+ fontSize: 11,
|
|
|
+ },
|
|
|
+ // 第三名
|
|
|
+ three: {
|
|
|
+ backgroundColor: "#F6BD16",
|
|
|
+ color: "white",
|
|
|
+ width: 12,
|
|
|
+ height: 16,
|
|
|
+ padding: [1, 0, 0, 5],
|
|
|
+ borderRadius: 10,
|
|
|
+ fontSize: 11,
|
|
|
+ },
|
|
|
+ // 一位数
|
|
|
+ four: {
|
|
|
+ backgroundColor: "rgba(0,0,0,0.15)",
|
|
|
+ color: "white",
|
|
|
+ width: 12,
|
|
|
+ height: 16,
|
|
|
+ padding: [1, 0, 0, 5],
|
|
|
+ borderRadius: 10,
|
|
|
+ fontSize: 11,
|
|
|
+ },
|
|
|
+ // 两位数
|
|
|
+ five: {
|
|
|
+ backgroundColor: "rgba(0,0,0,0.15)",
|
|
|
+ color: "white",
|
|
|
+ width: 16,
|
|
|
+ height: 16,
|
|
|
+ padding: [1, 0, 0, 1],
|
|
|
+ borderRadius: 10,
|
|
|
+ fontSize: 11,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: 'value',
|
|
|
+ type: 'bar',
|
|
|
+ zlevel: 1,
|
|
|
+ showBackground: true,
|
|
|
+
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ barBorderRadius: [0, 20, 20, 0], // 圆角(左上、右上、右下、左下)
|
|
|
+ color: (params) => {
|
|
|
+ return colorList[params.dataIndex]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ color: '#000',
|
|
|
+ show: true,
|
|
|
+ position: [0, '-20px'],
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 16,
|
|
|
+ },
|
|
|
+ formatter: '{b}',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ barWidth: 20,
|
|
|
+ data: salvProValue,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '21',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: 20,
|
|
|
+ barGap: '-100%',
|
|
|
+ data: salvProValue,
|
|
|
+ itemStyle: {
|
|
|
+ normal: {
|
|
|
+ color: '#f5f8ff',
|
|
|
+ },
|
|
|
+ emphasis: {
|
|
|
+ color: '#f5f8ff',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ normal: {
|
|
|
+ color: '#000',
|
|
|
+ show: true,
|
|
|
+ position: 'right',
|
|
|
+ distance: 4,
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 16,
|
|
|
+ },
|
|
|
+ formatter: '{c}',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+
|
|
|
+ myChart.setOption(option);
|
|
|
+ myChart.on("click", function (param) {
|
|
|
+ rightData(param.data.id,param.name);
|
|
|
+ // console.error(param,param.data.id,param.data.value,param.name);
|
|
|
+ // let url = '/zabbix/zabbix.php?action=map.view&sysmapid=2&kiosk=1&line';
|
|
|
+ });
|
|
|
+}
|
|
|
+function initChartRight(res,name) {
|
|
|
+ const myChart = echarts.init(chartRightType.value);
|
|
|
+ let colorList = ['#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093', '#fe8019', '#fec429', '#4a90e2', '#9095a7', '#4cb051', '#ec0019', '#dcb093'];
|
|
|
var ydata = [];
|
|
|
var salvProValue = [];
|
|
|
for (const i in res.data) {
|
|
|
- let obj=res.data[i]
|
|
|
- ydata.push(obj.bizType);
|
|
|
- salvProValue.push(obj.num);
|
|
|
+ let obj = res.data[i]
|
|
|
+ ydata.push(obj.name);
|
|
|
+ salvProValue.push({id:obj.id,value:obj.num});
|
|
|
}
|
|
|
let option = {
|
|
|
+ title: {
|
|
|
+ show: true,
|
|
|
+ text: name+' 业务组件统计',
|
|
|
+ textStyle: {
|
|
|
+ fontFamily: 'PingFangSC-Regular, PingFang SC',
|
|
|
+ align: 'center',
|
|
|
+ color: '#515961',
|
|
|
+ fontSize: 18,
|
|
|
+ },
|
|
|
+ },
|
|
|
backgroundColor: '#fff',
|
|
|
grid: {
|
|
|
left: '2%',
|
|
|
- right: '4%',
|
|
|
+ right: '10%',
|
|
|
bottom: '2%',
|
|
|
top: '2%',
|
|
|
containLabel: true,
|
|
@@ -247,7 +464,7 @@ function initChart(res){
|
|
|
normal: {
|
|
|
color: '#000',
|
|
|
show: true,
|
|
|
- position:'right',
|
|
|
+ position: 'right',
|
|
|
distance: 4,
|
|
|
textStyle: {
|
|
|
fontSize: 16,
|
|
@@ -259,8 +476,23 @@ function initChart(res){
|
|
|
],
|
|
|
};
|
|
|
|
|
|
- myChart.setOption(option)
|
|
|
+ myChart.setOption(option);
|
|
|
+ myChart.on("click", function (param) {
|
|
|
+ console.log(param)
|
|
|
+ // console.error(param,param.data.id,param.data.value,param.name);
|
|
|
+ // let url = '/zabbix/zabbix.php?action=map.view&sysmapid=2&kiosk=1&line';
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function rightData(type,name){
|
|
|
+ queryParams.value.type=type;
|
|
|
+ getBizObj(queryParams.value).then(response => {
|
|
|
+ loading.value = false;
|
|
|
+ initChartRight(response,name);
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
/** 查询告警记录列表 */
|
|
|
function getList() {
|
|
|
loading.value = true;
|
|
@@ -278,6 +510,14 @@ function getList() {
|
|
|
/** 搜索按钮操作 */
|
|
|
function handleQuery() {
|
|
|
queryParams.value.pageNum = 1;
|
|
|
+ getList();
|
|
|
+}
|
|
|
+
|
|
|
+function timeSelect(v) {
|
|
|
+ let end = new Date();
|
|
|
+ let start = new Date().setDate(end.getDate() - v);
|
|
|
+ daterangeAlarmTime.value[0] = moment(start).format('YYYY-MM-DD');
|
|
|
+ daterangeAlarmTime.value[1] = moment(end).format('YYYY-MM-DD');
|
|
|
}
|
|
|
|
|
|
/** 重置按钮操作 */
|