123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110 |
- <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"
- value-format="YYYY-MM-DD"
- type="daterange"
- range-separator="-"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- ></el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
- <el-button icon="Refresh" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- <el-row>
- <el-col :span="15">
- <div ref="chartAccess" style="height: 600px;"></div>
- </el-col>
- <el-col :span="9">
- <template #header>
- <Tickets style="width: 1em; height: 1em; vertical-align: middle;"/>
- <span style="vertical-align: middle;">{{ title }}</span></template>
- <el-table v-loading="loading" :data="leftList" v-show="sl" border style="height:300px;overflow-y: auto;">
- <el-table-column label="序号" align="center" width="60">
- <template #default="scope">
- <span>{{ scope.$index + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="组件名称" align="left" prop="modelName" width="150"/>
- <el-table-column label="应用编码" align="left" prop="code" width="150">
- <template #default="scope">
- <el-button link type="primary" @click="jumpPP(scope.row)">{{ scope.row.code }}</el-button>
- </template>
- </el-table-column>
- <el-table-column label="系统压力值TPS/QPS" align="center" prop="access" width="150"/>
- <el-table-column label="访问错误次数" align="center" prop="num" width="120"/>
- </el-table>
- <el-table v-loading="loading" :data="rightList" v-show="sr" border style="height:555px;overflow-y: auto;">
- <el-table-column label="序号" align="center" width="120">
- <template #default="scope">
- <span>{{ scope.$index + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="组件名称" align="left" prop="objName"/>
- <el-table-column label="告警数量" align="center" prop="num" width="120">
- <template #default="scope">
- <el-button link type="primary" @click="msDetail(scope.row)">{{ scope.row.num }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div ref="asLine" v-show="axx" style="height: 400px;padding-top: 20px;"></div>
- </el-col>
- </el-row>
- <!-- 添加或修改应用程序管理对话框 -->
- <el-dialog :title="title" v-model="open" width="800px" append-to-body>
- <div ref="alarmMs" style="height: 250px;"></div>
- <el-table v-loading="loading" :data="msList" border style="height:500px;overflow-y: auto;">
- <!-- <el-table-column label="风险对象" align="left" prop="objName"/>-->
- <!-- <el-table-column label="风险指标" align="center" prop="metricsName"/>-->
- <el-table-column label="序号" align="center" width="120">
- <template #default="scope">
- <span>{{ scope.$index + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="指标名称" align="center" prop="metricsName"/>
- <el-table-column label="风险级别" align="center" prop="alarmLevel">
- <template #default="scope">
- <dict-tag :options="alarm_level" :value="scope.row.alarmLevel"/>
- </template>
- </el-table-column>
- <el-table-column label="风险状态" align="center" prop="alarmType">
- <template #default="scope">
- <dict-tag :options="alarm_type" :value="scope.row.alarmType"/>
- </template>
- </el-table-column>
- <el-table-column label="风险值" align="center" prop="alarmValue" :formatter="rounding"/>
- <el-table-column label="事件时间" align="center" prop="alarmTime" width="220">
- <template #default="scope">
- <span>{{ parseTime(scope.row.alarmTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>
- </template>
- </el-table-column>
- </el-table>
- </el-dialog>
- </div>
- </template>
- <script setup name="Record">
- import {calcMs, getBizAccess} from "@/api/alarm/record";
- import {useRoute, useRouter} from "vue-router";
- import * as echarts from "echarts";
- import moment from "moment";
- import {getObjAccess, getObjAlarm} from "../../../api/alarm/record.js";
- const {proxy} = getCurrentInstance();
- const {alarm_level} = proxy.useDict('alarm_level');
- const {biz_type} = proxy.useDict('biz_type');
- const {alarm_type} = proxy.useDict('alarm_type');
- const leftList = ref([]);
- const rightList = ref([]);
- const open = ref(false);
- const sl = ref(true);
- const axx = ref(true);
- const sr = ref(false);
- const loading = ref(true);
- const showSearch = ref(true);
- const msList = ref([]);
- const ids = ref([]);
- const single = ref(true);
- const multiple = ref(true);
- const total = ref(0);
- const title = ref("");
- const daterangeAlarmTime = ref([]);
- const router = useRouter();
- const route = useRoute();
- const chartAccess = ref();
- const asLine = ref();
- const alarmMs = ref();
- const data = reactive({
- form: {},
- queryParams: {
- start: null,
- end: null,
- modeId: null
- },
- });
- function jumpPP(row) {
- const today = new Date();
- today.setHours(0, 0, 0, 0);
- const now = new Date();
- now.setHours(now.getHours(), now.getMinutes(), 0, 0);
- let num = (now - today) / (1000 * 60);
- num = num.toFixed(0);
- const last = formatDate(now);
- const suffix = '/main/' + row.code + '@SPRING_BOOT/' + num + '分钟/' + last;
- router.push({path: '/link/pp-link/', query: {suffix: suffix}})
- }
- function formatDate(date) {
- const day = date.getDate().toString().padStart(2, '0');
- const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份是从0开始的
- const year = date.getFullYear();
- const hours = date.getHours().toString().padStart(2, '0');
- const minutes = date.getMinutes().toString().padStart(2, '0');
- const seconds = date.getSeconds().toString().padStart(2, '0');
- return `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;
- }
- function handleDetails(row) {
- console.log(row, router)
- }
- function msDetail(row) {
- open.value = true;
- title.value = "[" + row.objName + "]详情";
- let msParams = {
- objId: row.objId,
- params: {}
- };
- if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
- msParams.params["beginAlarmTime"] = daterangeAlarmTime.value[0];
- msParams.params["endAlarmTime"] = daterangeAlarmTime.value[1];
- }
- console.error(msParams)
- calcMs(msParams).then(response => {
- initMs(response.data.hour);
- msList.value = response.data.detail;
- });
- }
- const {queryParams, form} = toRefs(data);
- function initChart(res) {
- let myChart = echarts.init(chartAccess.value);
- let img = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNjUzOTAwNTEzMjYyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxNjkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mYWNlIHsgZm9udC1mYW1pbHk6IGZlZWRiYWNrLWljb25mb250OyBzcmM6IHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUud29mZjI/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmMiIpLCB1cmwoIi8vYXQuYWxpY2RuLmNvbS90L2ZvbnRfMTAzMTE1OF91Njl3OHloeGR1LndvZmY/dD0xNjMwMDMzNzU5OTQ0IikgZm9ybWF0KCJ3b2ZmIiksIHVybCgiLy9hdC5hbGljZG4uY29tL3QvZm9udF8xMDMxMTU4X3U2OXc4eWh4ZHUudHRmP3Q9MTYzMDAzMzc1OTk0NCIpIGZvcm1hdCgidHJ1ZXR5cGUiKTsgfQo8L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDBoMzJ2MTYwaC0zMnpNNTEyIDI1NmgzMnYxNjBoLTMyek01MTIgNTEyaDMydjE2MGgtMzJ6TTUxMiA3NjhoMzJ2MTYwaC0zMnoiIGZpbGw9IiNkODFlMDYiIHAtaWQ9IjIxNzAiPjwvcGF0aD48L3N2Zz4=";
- let datas = [];
- let legendData1 = [];
- let legendData2 = [];
- let legendData3 = [];
- let legendData4 = [];
- let legendData5 = [];
- let dataheng = [];
- let xMax1 = 50;
- let xMax2 = 1;
- let xMax3 = 10000;
- let xMax4 = 10000;
- let xMax5 = 10000;
- for (let i in res.data) {
- let obj = res.data[i];
- datas.push(obj.modelName);
- //访问次数
- legendData1.push({id: obj.modelId, value: obj.access});
- //访问错误
- legendData2.push({id: obj.modelId, value: obj.num});
- //告警
- legendData3.push({id: obj.modelId, value: obj.n1});
- //服务数量
- legendData4.push({id: obj.modelId, value: obj.n2});
- //容器数量
- legendData5.push({id: obj.modelId, value: obj.n3});
- if (i == 0) {
- dl(obj.modelId, obj.modelName);
- }
- if (obj.access > xMax1) {
- xMax1 = obj.access;
- }
- if (obj.num > xMax2) {
- xMax2 = obj.num;
- }
- if (obj.n1 > xMax3) {
- xMax3 = obj.n1;
- }
- if (obj.n2 > xMax4) {
- xMax4 = obj.n2;
- }
- if (obj.n3 > xMax5) {
- xMax5 = obj.n3;
- }
- }
- for (let i in res.data) {
- dataheng.push(xMax1 + 2);
- }
- // let dataheng = [xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2, xMax1 + 2];
- let option = {
- backgroundColor: '#fff',
- tooltip: {
- show: true,
- trigger: 'axis',
- axisPointer: {
- type: 'shadow',
- shadowStyle: {
- color: 'rgba(210,219,238,0.2)',
- },
- },
- },
- legend: {},
- grid: [{
- show: false,
- left: '0',
- top: 30,
- bottom: 22,
- width: '14%',
- },
- {
- containLabel: true,
- top: 30,
- left: '20%',
- bottom: '0%',
- width: '30%',
- show: false
- },
- {
- left: '52%',
- right: '10%',
- top: 30,
- bottom: '0%',
- width: '10%',
- containLabel: true,
- show: false
- },
- {
- left: '70%',
- // right: '2%',
- top: 30,
- bottom: '0%',
- width: '10%',
- containLabel: true,
- show: false
- },
- {
- left: '80%',
- // right: '2%',
- width: '10%',
- top: 30,
- bottom: '0%',
- containLabel: true,
- show: false
- },
- {
- left: '90%',
- // right: '2%',
- width: '10%',
- top: 30,
- bottom: '0%',
- containLabel: true,
- show: false
- },
- ],
- xAxis: [{
- gridIndex: 0,
- show: false,
- },
- {
- gridIndex: 1,
- show: false,
- max: xMax1,
- },
- {
- gridIndex: 2,
- show: false,
- max: xMax2,
- },
- {
- gridIndex: 3,
- show: false,
- max: xMax3,
- },
- {
- gridIndex: 4,
- show: false,
- max: xMax4,
- },
- {
- gridIndex: 5,
- show: false,
- max: xMax5,
- },
- ],
- yAxis: [{
- gridIndex: 0,
- type: 'category',
- inverse: true,
- position: 'right',
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- data: datas.map(function (value) {
- return {
- value: value,
- textStyle: {
- align: 'right',
- },
- };
- }),
- axisLabel: {
- fontSize: 14,
- align: 'left',
- rich: {
- a: {
- color: '#fff',
- backgroundColor: '#49a2ff',
- width: 24,
- height: 24,
- align: 'center',
- borderRadius: 3,
- },
- a1: {
- color: '#fff',
- backgroundColor: '#f5576c',
- width: 24,
- height: 24,
- align: 'center',
- borderRadius: 3,
- },
- a2: {
- color: '#fff',
- backgroundColor: '#fee140',
- width: 24,
- height: 24,
- align: 'center',
- borderRadius: 3,
- },
- a3: {
- color: '#fff',
- backgroundColor: '#96fbc4',
- width: 24,
- height: 24,
- align: 'center',
- borderRadius: 3,
- },
- b: {
- color: '#333',
- width: 100,
- height: 30,
- align: 'right',
- },
- },
- formatter: function (params) {
- let index = datas.map((item) => item).indexOf(params);
- index = index + 1;
- if (index < 4) {
- return [`{a${index}|${index}}{b|${params}}`].join('\n');
- } else {
- return [`{a|${index}}{b|${params}}`].join('\n');
- }
- },
- },
- },
- {
- inverse: true,
- gridIndex: 1,
- data: datas,
- // max:10,
- axisLabel: {
- // margin: 80,
- show: false
- },
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisPointer: {
- label: {
- show: false,
- margin: 30,
- },
- },
- },
- {
- gridIndex: 2,
- inverse: true,
- data: datas,
- // max:10,
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- axisPointer: {
- label: {
- show: false,
- margin: 30,
- },
- },
- },
- {
- gridIndex: 3,
- inverse: true,
- data: datas,
- // max:10,
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- axisPointer: {
- label: {
- show: false,
- margin: 30,
- },
- },
- },
- {
- gridIndex: 4,
- inverse: true,
- data: datas,
- // max:10,
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- axisPointer: {
- label: {
- show: false,
- margin: 30,
- },
- },
- },
- {
- gridIndex: 5,
- inverse: true,
- data: datas,
- // max:10,
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- show: false,
- },
- axisPointer: {
- label: {
- show: false,
- margin: 30,
- },
- },
- },
- ],
- series: [{
- type: 'bar',
- name: '系统压力值(次)',
- stack: '2',
- barWidth: 20,
- z: 10,
- barCategoryGap: 15,
- // barGap:i==1?'-100%':'0',
- xAxisIndex: 1,
- yAxisIndex: 1,
- itemStyle: {
- color: '#419491',
- barBorderRadius: [0, 10, 10, 0],
- // barBorderRadius: legendData[i].barBorderRadius,
- emphasis: {
- color: '#419491',
- },
- },
- // 数字
- label: {
- show: true,
- position: 'inside',
- right: 0,
- color: '#fff',
- formatter: function (params) {
- if (params.value == 0) {
- return '';
- } else {
- return params.value;
- }
- },
- },
- data: legendData1,
- },
- //虚线
- {
- name: '',
- type: 'pictorialBar',
- xAxisIndex: 1,
- yAxisIndex: 1,
- symbolSize: [7, 30],
- symbolOffset: [15, 0],
- symbol: 'image://' + img,
- symbolPosition: 'end',
- barWidth: "20",
- z: 999,
- color: '#fe5959',
- data: dataheng,
- tooltip: {
- show: false,
- },
- },
- //右边的柱状图
- {
- xAxisIndex: 2,
- yAxisIndex: 2,
- type: 'bar',
- name: '访问错误(次)',
- stack: '3',
- barWidth: 20,
- barCategoryGap: 15,
- // barGap:i==1?'-100%':'0',
- itemStyle: {
- color: '#FFB25C',
- barBorderRadius: [0, 20, 20, 0],
- emphasis: {
- color: '#FFB25C',
- },
- },
- // 数字
- label: {
- normal: {
- color: '#FFB25C',
- show: true,
- position: 'right',
- distance: 4,
- textStyle: {
- fontSize: 16,
- },
- formatter: '{c}',
- },
- },
- data: legendData2,
- },
- //右边的柱状图
- {
- xAxisIndex: 3,
- yAxisIndex: 3,
- type: 'bar',
- name: '告警(次)',
- barWidth: 1,
- barCategoryGap: 15,
- // barGap:i==1?'-100%':'0',
- itemStyle: {
- color: '#333333',
- barBorderRadius: [0, 20, 20, 0],
- emphasis: {
- color: '#333333',
- },
- },
- // 数字
- label: {
- normal: {
- color: '#333333',
- show: true,
- position: 'right',
- distance: 4,
- textStyle: {
- fontSize: 16,
- },
- formatter: '{c}',
- },
- },
- data: legendData3,
- },
- //右边的柱状图
- {
- xAxisIndex: 4,
- yAxisIndex: 4,
- type: 'bar',
- name: '服务数量(个)',
- barWidth: 1,
- barCategoryGap: 15,
- // barGap:i==1?'-100%':'0',
- itemStyle: {
- color: '#555555',
- barBorderRadius: [0, 20, 20, 0],
- emphasis: {
- color: '#555555',
- },
- },
- // 数字
- label: {
- normal: {
- color: '#555555',
- show: true,
- position: 'right',
- distance: 4,
- textStyle: {
- fontSize: 16,
- },
- formatter: '{c}',
- },
- },
- data: legendData4,
- },
- //右边的柱状图
- {
- xAxisIndex: 5,
- yAxisIndex: 5,
- type: 'bar',
- name: '容器数量(个)',
- barWidth: 1,
- barCategoryGap: 15,
- // barGap:i==1?'-100%':'0',
- itemStyle: {
- color: '#888888',
- barBorderRadius: [0, 20, 20, 0],
- emphasis: {
- color: '#888888',
- },
- },
- // 数字
- label: {
- normal: {
- color: '#888888',
- show: true,
- position: 'right',
- distance: 4,
- textStyle: {
- fontSize: 16,
- },
- formatter: '{c}',
- },
- },
- data: legendData5,
- },
- ],
- };
- // 3.配置项和数据给实例化对象
- myChart.setOption(option);
- myChart.on("click", function (param) {
- switch (param.seriesIndex) {
- case 0:
- case 1:
- case 2:
- dl(param.data.id, param.name);
- break;
- case 3:
- dr(param.data.id, param.name);
- break;
- }
- // if (param.seriesIndex == 0) {
- // dl(param.data.id, param.name);
- // } else {
- // dr(param.data.id, param.name);
- // }
- // 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 initMs(res) {
- let myChart = echarts.init(alarmMs.value);
- let yd = [];
- let xd = [];
- for (let i = 0; i < res.length; i++) {
- xd.push(res[i].hour);
- yd.push(res[i].num);
- }
- let ss = [];
- let xx = {
- // name: xd,
- type: 'line',
- data: yd,
- symbolSize: 1,
- symbol: 'circle',
- smooth: true,
- showSymbol: false,
- }
- ss.push(xx);
- let x_data = xd;
- let option = {
- backgroundColor: '#FFFFFF',
- dataZoom: {
- type: 'inside', // 内置型数据区域缩放组件
- start: 0, // 默认为0,表示从头开始
- end: 100 // 默认为100,表示直到末尾
- },
- title: {
- show: true,
- text: '告警趋势',
- // textStyle: {
- // fontFamily: 'PingFangSC-Regular, PingFang SC',
- // fontSize: 16,
- // fontWeight: 600,
- // color: '#848E98'
- // },
- left: 'left',
- // top: '3%'
- },
- legend: {
- icon: 'rect',
- top: '3%',
- right: '10%',
- itemWidth: 10,
- itemHeight: 10,
- itemGap: 20,
- textStyle: {
- fontFamily: 'PingFangSC-Regular, PingFang SC',
- color: '#848E98'
- }
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- label: {
- show: true,
- backgroundColor: '#fff',
- color: '#556677',
- borderColor: 'rgba(0,0,0,0)',
- shadowColor: 'rgba(0,0,0,0)',
- shadowOffsetY: 0
- },
- lineStyle: {
- width: 0
- }
- },
- backgroundColor: '#fff',
- textStyle: {
- color: '#5c6c7c'
- },
- padding: [10, 10],
- extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
- },
- grid: {
- top: '18%'
- },
- xAxis: [{
- type: 'category',
- data: x_data,
- axisLine: {
- show: false,
- lineStyle: {
- color: '#000000'
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 'auto',
- rotate: 45,
- textStyle: {
- color: '#B7C3CE'
- },
- // 默认x轴字体大小
- fontSize: 12,
- // margin:文字到x轴的距离
- margin: 5,
- hideOverlap: true // 隐藏部分标签避免重叠
- }
- }],
- yAxis: [{
- type: 'value',
- axisTick: {
- show: false
- },
- axisLine: {
- show: false,
- },
- axisLabel: {
- fontSize: 12,
- textStyle: {
- color: '#B7C3CE'
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- type: "dashed"
- }
- }
- }],
- series: ss
- };
- myChart.setOption(option)
- }
- function dl(modelId, name) {
- title.value = "[" + name + "] 组件压力排行";
- sl.value = true;
- axx.value = true;
- sr.value = false;
- queryParams.value.modelId = modelId;
- queryParams.value.params = {};
- if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
- queryParams.value.start = daterangeAlarmTime.value[0];
- queryParams.value.end = daterangeAlarmTime.value[1];
- }
- getObjAccess(queryParams.value).then(response => {
- loading.value = false;
- leftList.value = response.data.objs;
- line(response.data.datas);
- });
- }
- function dr(modelId, name) {
- title.value = "[" + name + "] 组件告警数量排行";
- sl.value = false;
- axx.value = false;
- sr.value = true;
- queryParams.value.modelId = modelId;
- queryParams.value.params = {};
- if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
- queryParams.value.start = daterangeAlarmTime.value[0];
- queryParams.value.end = daterangeAlarmTime.value[1];
- }
- getObjAlarm(queryParams.value).then(response => {
- loading.value = false;
- rightList.value = response.data;
- });
- }
- function line(data) {
- let myChart = echarts.init(asLine.value);
- let colorList = [
- '#419491',
- '#3581F8',
- '#FFB25C',
- ];
- let x_data = [];
- let max_data = [];
- let avg_data = [];
- let err_data = [];
- for (let i = 0; i < data.length; i++) {
- x_data.push(data[i].time);
- max_data.push(data[i].max);
- avg_data.push(data[i].avg);
- err_data.push(data[i].error);
- }
- let option = {
- backgroundColor: '#FFFFFF',
- dataZoom: {
- type: 'inside', // 内置型数据区域缩放组件
- start: 0, // 默认为0,表示从头开始
- end: 50 // 默认为100,表示直到末尾
- },
- title: {
- show: true,
- text: '系统压力值趋势',
- // subtext:'分配总量:18041核\n释放总量:5288核',
- // textStyle: {
- // fontFamily: 'PingFangSC-Regular, PingFang SC',
- // fontSize: 14,
- // fontWeight: 400,
- // color: '#848E98'
- // },
- left: 'left',
- top: '3%'
- },
- legend: {
- icon: 'rect',
- top: '3%',
- right: '10%',
- itemWidth: 10,
- itemHeight: 10,
- itemGap: 20,
- textStyle: {
- fontFamily: 'PingFangSC-Regular, PingFang SC',
- color: '#848E98'
- }
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- label: {
- show: true,
- backgroundColor: '#fff',
- color: '#556677',
- borderColor: 'rgba(0,0,0,0)',
- shadowColor: 'rgba(0,0,0,0)',
- shadowOffsetY: 0
- },
- lineStyle: {
- width: 0
- }
- },
- backgroundColor: '#fff',
- textStyle: {
- color: '#5c6c7c'
- },
- padding: [10, 10],
- extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
- },
- grid: {
- top: '18%'
- },
- xAxis: [{
- type: 'category',
- data: x_data,
- axisLine: {
- show: false,
- lineStyle: {
- color: '#000000'
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 'auto',
- rotate: 45,
- textStyle: {
- color: '#B7C3CE'
- },
- // 默认x轴字体大小
- fontSize: 12,
- // margin:文字到x轴的距离
- margin: 5
- }
- }],
- yAxis: [{
- type: 'value',
- // name: "核数",
- // position: 'left',
- // offset: 55,
- axisTick: {
- show: false
- },
- axisLine: {
- show: false,
- },
- axisLabel: {
- fontSize: 12,
- textStyle: {
- color: '#B7C3CE'
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- type: "dashed"
- }
- }
- }],
- series: [{
- name: '最大值',
- type: 'line',
- data: max_data,
- symbolSize: 1,
- symbol: 'circle',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- width: 1,
- type: 'dotted', //'dotted'虚线 'solid'实线
- },
- itemStyle: {
- normal: {
- color: colorList[0],
- borderColor: colorList[0]
- }
- }
- }, {
- name: '平均值',
- type: 'line',
- data: avg_data,
- symbolSize: 1,
- symbol: 'circle',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- width: 1,
- },
- itemStyle: {
- normal: {
- color: colorList[1],
- borderColor: colorList[1]
- }
- }
- },
- {
- name: '错误次数',
- type: 'line',
- data: err_data,
- symbolSize: 1,
- symbol: 'circle',
- smooth: true,
- showSymbol: false,
- lineStyle: {
- width: 1,
- },
- itemStyle: {
- normal: {
- color: colorList[2],
- borderColor: colorList[2]
- }
- }
- }
- ]
- };
- myChart.setOption(option);
- }
- /** 查询告警记录列表 */
- function getList() {
- loading.value = true;
- queryParams.value.params = {};
- if (null != daterangeAlarmTime && '' != daterangeAlarmTime) {
- queryParams.value.start = daterangeAlarmTime.value[0];
- queryParams.value.end = daterangeAlarmTime.value[1];
- }
- getBizAccess(queryParams.value).then(response => {
- // recordList.value = response.rows;
- // total.value = response.total;
- loading.value = false;
- initChart(response);
- });
- }
- /** 搜索按钮操作 */
- 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');
- }
- /** 重置按钮操作 */
- function resetQuery() {
- daterangeAlarmTime.value = [];
- proxy.resetForm("queryRef");
- handleQuery();
- }
- if (route.query.today) {
- timeSelect(0);
- } else {
- timeSelect(30);
- }
- getList();
- </script>
|