Files
profitManage1.2/src/views/resource/monitorBoard/monitorBoardView.vue
T
康冉冉 d6fde5d504 监控看板、脚本管理添加新字段、服务器脚本添加执行结果查看列表
1、监控看板_前端开发并联调
2、脚本管理页面_前端开发并联调
3、服务器脚本模块执行结果查看_前端开发并联调
2025-11-18 18:24:04 +08:00

321 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<div class="w100" style="height: 60px;">
<div class="fl" style="text-align: left;">
<el-select v-model="configModel" placeholder="请选择配置" style="margin-right: 10px;" @change="selectValChange">
<el-option
v-for="item in configNameList"
:key="item.id"
:label="item.configName"
:value="item.id">
</el-option>
</el-select>
<el-button type="primary" @click="fnFormHandle('add')">添加配置</el-button>
<el-button @click="fnFormHandle('edit')">修改配置</el-button>
<el-button @click="fnFormHandle('del')">删除配置</el-button>
</div>
<div class="fr" style="text-align: right;">
<el-date-picker
v-model="datetimeModel"
style="width: 360px!important;margin-right: 10px;"
type="datetimerange"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator=""
start-placeholder="开始日期时间"
end-placeholder="结束日期时间"
@change="dateChange">
</el-date-picker>
<el-select v-model="timeModel" placeholder="请选择" style="width: 100px;margin-right: 10px;" @change="fnTimeInter">
<el-option
v-for="item in timeModelOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-button @click="viewMonitorChart">概览视图</el-button>
</div>
</div>
<div style="height: calc(100% - 60px);" class="w100">
<div v-for="(chartItem, key, index) of lineDataParams" class="h40 w100" style="min-height: 300px;">
<div class="w100 h100" style="border: 1px solid #e8e8e8;">
<EchartsLine :lineData="chartItem || {}" :title="chartItem && chartItem.title || ''" class="w100 h100" @chartClickModel="chartClickModel" :chartData="(valData, unit) => chartDataEvent(valData, unit)"></EchartsLine>
</div>
</div>
<div class="w100 mt20" v-if="reserveForm && reserveForm.resourceType !== '3'">
<TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="roleList" @fnClick="callback" @fnRenderList="getList">
<template #tempDay="{ valueKey, row, column }">
<span v-if="row && row[valueKey] || row[valueKey] === 0">{{row[valueKey]}}/{{row.createTime}}</span>
</template>
</TableList>
</div>
</div>
<!-- 弹窗 -->
<el-dialog title="添加配置" :visible.sync="open" width="800px" append-to-body>
<dialogMonitor :formModel="formModel" @dialogResult="fnDialogResult"></dialogMonitor>
</el-dialog>
</div>
</template>
<script>
import dialogMonitor from './dialogMonitor';
import EchartsLine from "@/components/echartsList/line.vue";
import TableList from '@/components/table/index.vue';
import {monitorViewChart, monitorConfigList, delMonitorConfig, getBandWidthList, getSwitchInfoList} from "@/api/disRevenue/resource";
export default {
name: "monitorBoardView",
components: {dialogMonitor, EchartsLine, TableList},
data() {
return {
paramsData: {},
configModel: '',
configNameList: [],
formModel: {},
reserveForm: {},
datetimeModel: [],
timeModel: '30000',
timeInterModel: null,
open: false,
timeModelOptions: [
{value: '30000', label: '30s刷新'},
{value: '10000', label: '10s刷新'},
{value: '0', label: '不刷新'},
],
echartData: {
title: ' ',
yAxisName: ' ',
unitModel: 'Kb',
unitSelList: [{label: 'Kb', value: 'Kb'},{label: 'Mb', value: 'Mb'}, {label: 'Gb', value: 'Gb'}],
legend: {bottom: '0%'},
gridTop: '40px',
gridBotm: '15%',
hiddenTime: true,
lineXData: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sa', 'Sun'],
dataList: [
{name: '入方向总流量', data: []},
{name: '出方向总流量', data: []}
]
},
lineDataParams: {},
btnList: [{title: '详情', value: 'view'}, {title: '修改', value: 'edit'}, {title: '删除', value: 'del'}],
// 列显隐信息
columns: {},
config: {},
roleList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
total: 0
}
}
},
created() {
this.paramsData = this.$route && this.$route.query;
this.configModel = this.paramsData && this.paramsData.id ? Number(this.paramsData.id) : '';
let startData = '';
let endData = '';
const year = new Date().getFullYear();
const month = String(new Date().getMonth() + 1).padStart(2, '0'); // 0=1月,11=12月
const day = String(new Date().getDate()).padStart(2, '0'); // 当前日(如8
const prevDay = String(new Date().getDate() - 1).padStart(2, '0');
startData = `${year}-${month}-${prevDay} 00:00:00`;
endData = `${year}-${month}-${day} 23:59:59`;
this.currTimeList = {startTime: startData, endTime: endData};
this.datetimeModel = [startData, endData];
this.lineDataParams['one'] = this.echartData;
this.fnConfigName();
if (this.configModel) {
this.fnChartView();
}
},
beforeDestroy() {
clearInterval(this.timeInterModel);
this.timeInterModel = null;
},
methods: {
// 查询流量图
fnChartView(unitData) {
this.lineDataParams = {};
monitorViewChart(Object.assign(unitData || {},this.currTimeList, {monitorId: this.configModel})).then(res => {
let dataList = {};
res && res.data.forEach(item => {
let chart = JSON.parse(JSON.stringify(this.echartData));
let modelVal = item && item.rmMonitorConfig || {id: 'one', configName: 'one'};
modelVal['deployDevice'] = item && item.yData && item.yData.deployDevice || [];
this.reserveForm = modelVal;
this.columns = {};
this.config = {};
this.tableShowModel(modelVal);
dataList[modelVal && modelVal.configName + '_' + modelVal.id] = {};
if (item && item.unit) {
chart.unitModel = item.unit;
chart.unitSelList = [{label: 'Kb', value: 'Kb'},{label: 'Mb', value: 'Mb'}, {label: 'Gb', value: 'Gb'}];
}
chart.lineXData = item && item.xData || [];
chart.dataList[0].data = item && item.yData && item.yData.netInSpeedData || [];
chart.dataList[1].data = item && item.yData && item.yData.netOutSpeedData || [];
dataList[modelVal.configName + '_' + modelVal.id] = chart;
});
if (dataList && Object.keys(dataList).length > 0) {
this.lineDataParams = {...dataList};
} else {
this.lineDataParams['one'] = this.echartData;
}
// 循环定时查询
this.fnTimeInter(this.timeModel);
}).catch(() => {
// 循环定时查询
this.fnTimeInter(this.timeModel);
});
},
// 列表数据展示
tableShowModel(modelVal){
if (modelVal && modelVal.resourceType && modelVal.resourceType !== '3') {
if (modelVal && modelVal.resourceType && modelVal.resourceType === '1') {
this.config = {
colTopHiddenIcon: true,
tableButton: {
line: [
{content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'resource:monitorBoardView:details'},
]
}
};
} else if (modelVal && modelVal.resourceType && modelVal.resourceType === '2') {
this.config = {colTopHiddenIcon: true};
}
this.columns = {
id: { label: `ID`,width: '50'},
clientId: { label: `ClientID`, minWidth: '120', visible: modelVal && modelVal.resourceType === '1' ? true : false},
businessName: {label: `业务名称`, minWidth: '150', visible: modelVal && modelVal.resourceType === '1' ? true : false},
bandwidth95Daily: {label: `95带宽值/日(Mbit)`, minWidth: '150', slotName: 'tempDay', visible: modelVal && modelVal.resourceType === '1' ? true : false},
switchName: {label: `交换机名称`, minWidth: '150', visible: modelVal && modelVal.resourceType === '2' ? true : false},
name: {label: `端口名称`, minWidth: '150', visible: modelVal && modelVal.resourceType === '2' ? true : false},
inSpeed: {label: `接收速率值(bits/s)`, minWidth: '150', visible: modelVal && modelVal.resourceType === '2' ? true : false},
outSpeed: {label: `发送速率值(bits/s)`, minWidth: '150', visible: modelVal && modelVal.resourceType === '2' ? true : false},
createTime: {label: `时间`, minWidth: '150', visible: modelVal && modelVal.resourceType === '2' ? true : false},
};
}
},
// 下拉
fnConfigName() {
monitorConfigList({}).then(res => {
if (res && res.data && res.data.length > 0) {
this.configNameList = res && res.data;
let index = 0;
res && res.data.forEach(item => {
if (item.id === this.configModel) {
index = 1;
}
});
if (index === 0) {
this.configModel = this.configNameList[0].id;
this.fnChartView();
}
}
});
},
// 定时刷新下拉
fnTimeInter(val) {
clearInterval(this.timeInterModel);
this.timeInterModel = null;
this.timeInterModel = setInterval(() => {
this.fnChartView();
}, Number(val));
},
// 按钮操作弹窗
fnFormHandle(val) {
if (val === 'add') {
this.open = true;
// 使用$nextTick确保DOM更新完成后再初始化子组件
this.$nextTick(() => {
// 强制更新formModel,确保子组件能接收到
this.formModel = {};
});
} else if (val === 'edit') {
this.open = true;
// 使用$nextTick确保DOM更新完成后再初始化子组件
this.$nextTick(() => {
// 强制更新formModel,确保子组件能接收到
this.formModel = this.reserveForm;
});
} else if (val === 'del') {
let content = '<p style="font-size: 1rem;font-weight: 600;">确认删除 ' + this.reserveForm.configName + '</p>' +
'<p style="height: 0px;margin-bottom: 50px;">删除 ' + this.reserveForm.configName + ' 配置后,相应的服务器/交换机集合的总流量的相关数据都将删除</p>';
this.$modal.confirm(content).then(() => {
delMonitorConfig(this.reserveForm.id).then(res => {
this.fnConfigName();
});
}).catch(() => {});
}
},
// 时间选择器
dateChange() {
this.currTimeList = {startTime: this.datetimeModel[0], endTime: this.datetimeModel[1]};
this.fnChartView({});
},
// 下拉值变化事件
selectValChange(val) {
this.fnChartView();
},
addMonitor() {
this.open = true;
},
fnDialogResult(res){
this.open = false;
this.fnConfigName();
this.fnChartView();
},
// 详细视图
viewMonitorChart() {
this.$router.push({
path: '/resource/monitorBoard',
});
},
// 点击图表
chartClickModel(chart) {
let paramsModel = {clientIds: this.reserveForm.deployDevice.toString(), startTime: chart.params.name, endTime: chart.params.name};
this.getList(paramsModel);
},
getList(val) {
if (this.reserveForm.resourceType === '1') {
getBandWidthList(Object.assign({}, this.queryParams, val)).then(response => {
this.roleList = response.rows;
this.queryParams.total = response.total;
this.loading = false;
});
} else if (this.reserveForm.resourceType === '2') {
getSwitchInfoList(Object.assign({}, this.queryParams, val)).then(response => {
this.roleList = response.rows;
this.queryParams.total = response.total;
this.loading = false;
})
}
},
chartDataEvent(valData, unit) {
if (unit) {
let unitData = {unit: unit};
this.fnChartView(unitData);
}
},
callback(result, rowData) {
if (result && result.fnCode) {
switch (result.fnCode) {
case 'details':
this.$router.push({
path:'/resource/serverRegister/edit',
query: {id: rowData.clientId, readonly: true, type: 'alarmLog'}
});
break;
default:
}
}
},
}
}
</script>
<style scoped>
</style>