资源监控策略、服务器脚本策略

This commit is contained in:
康冉冉
2025-09-25 19:23:33 +08:00
parent 9782011cd2
commit ba698c38e8
10 changed files with 588 additions and 331 deletions

View File

@@ -242,12 +242,11 @@ export function getMonitorPolicy(Id) {
method: 'get' method: 'get'
}) })
} }
// 查询资源监控项 // 下发策略
export function getMonitorPolicyList(query) { export function getMonitorPolicyList(Id) {
return request({ return request({
url: '/rocketmq/monitorPolicy/issuePolicy', url: '/rocketmq/monitorPolicy/issuePolicy?id=' + Id,
method: 'post', method: 'get'
data: query
}) })
} }
@@ -289,3 +288,51 @@ export function getResMonitorGroup() {
method: 'get' method: 'get'
}) })
} }
/** ----------------脚本服务器策略------------ */
// 查询列表
export function listPolicy(query) {
return request({
url: '/rocketmq/policy/list',
method: 'post',
data: query
})
}
// 查询详细
export function getPolicy(Id) {
return request({
url: '/rocketmq/policy/' + Id,
method: 'get'
})
}
// 下发策略
export function getPolicyList(Id) {
return request({
url: '/rocketmq/policy/issueDeploymentPolicy?id=' + Id,
method: 'get'
})
}
// 新增
export function addPolicy(data) {
return request({
url: '/rocketmq/policy',
method: 'post',
data: data
})
}
// 修改
export function updatePolicy(data) {
return request({
url: '/rocketmq/policy',
method: 'put',
data: data
})
}
// 删除
export function delPolicy(Ids) {
return request({
url: '/rocketmq/policy/' + Ids,
method: 'delete'
})
}

View File

@@ -351,7 +351,7 @@ export const dynamicRoutes = [
path: 'index/:id?', path: 'index/:id?',
component: () => import('@/views/disRevenue/resource/monitorTemp/view'), component: () => import('@/views/disRevenue/resource/monitorTemp/view'),
name: 'monitorTempView', name: 'monitorTempView',
meta: { title: '监控模版信息', activeMenu: '/disRevenue/resource/monitorTemp' } meta: { title: '监控模版详情', activeMenu: '/disRevenue/resource/monitorTemp' }
} }
] ]
}, },
@@ -380,7 +380,7 @@ export const dynamicRoutes = [
path: 'index/:id?', path: 'index/:id?',
component: () => import('@/views/disRevenue/resource/monitorStategy/view'), component: () => import('@/views/disRevenue/resource/monitorStategy/view'),
name: 'monitorStategyView', name: 'monitorStategyView',
meta: { title: '监控模版信息', activeMenu: '/disRevenue/resource/monitorStategy' } meta: { title: '资源监控策略详情', activeMenu: '/disRevenue/resource/monitorStategy' }
} }
] ]
}, },

View File

@@ -181,30 +181,20 @@
// 第二节点 1栏 // 第二节点 1栏
option: [], option: [],
linuxSystem: { linuxSystem: {
monitorItem: [{ monitorItem: [
firstTitle: 'Linux系统', secondTitle: '监控项', title: 'CPU监控', modelName: 'cpu',time: '', {firstTitle: 'Linux系统', secondTitle: '监控项', title: 'CPU监控', modelName: 'cpu',time: '', checkList: []},
checkList: [] {firstTitle: 'Linux系统', secondTitle: '监控项', title: '其他监控', modelName: 'other', checkList: []}
},{ ],
firstTitle: 'Linux系统', secondTitle: '监控项', title: '其他监控', modelName: 'other', autodiscoverItem: [
checkList: [] {firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现挂载文件系统', modelName: 'vfs', time: '', checkList: []},
}], {firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现网络接口', modelName: 'net', time: '300', checkList: []},
autodiscoverItem: [{ {firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现硬盘设备', modelName: 'disk', time: '', checkList: []},
firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现挂载文件系统', modelName: 'vfs', time: '', {firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现docker', modelName: 'docker', time: '', checkList: []}
checkList: [] ],
},{
firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现网络接口', modelName: 'net', time: '300',
checkList: []
},{
firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现硬盘设备', modelName: 'disk', time: '',
checkList: []
}, {
firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现docker', modelName: 'docker', time: '',
checkList: []
}],
}, },
// 第二节点 2栏 列显隐信息 // 第二节点 2栏 列显隐信息
monitorTable: { monitorTable: {
nodeOne: [{firstTitle: '华为交换机', secondTitle: '监控项', modelName: 'other', checkList: []}], nodeOne: [{firstTitle: '华为交换机', secondTitle: '监控项', modelName: 'switchOther', checkList: []}],
nodeTow: [ nodeTow: [
{firstTitle: '华为交换机', secondTitle: '自动发现项', title: '网络端口发现', modelName: 'switchNet', time: '300', checkList: []}, {firstTitle: '华为交换机', secondTitle: '自动发现项', title: '网络端口发现', modelName: 'switchNet', time: '300', checkList: []},
{firstTitle: '华为交换机', secondTitle: '自动发现项',title: '光模块发现', modelName: 'switchModule', time: '', checkList: []}, {firstTitle: '华为交换机', secondTitle: '自动发现项',title: '光模块发现', modelName: 'switchModule', time: '', checkList: []},
@@ -264,13 +254,10 @@
getFormDataList(id) { getFormDataList(id) {
this.tempContent = {}; this.tempContent = {};
getMonitorPolicy(id).then(val => { getMonitorPolicy(id).then(val => {
console.log('val===',val);
if (val && val.data) { if (val && val.data) {
// this.activeTypeName = val.data.template.resourcyType;
this.ruleFormData = val.data.policy; this.ruleFormData = val.data.policy;
this.resourceType = val.data.resourceType; this.resourceType = val.data.resourceType;
this.tempContent[val.data.resourceType] = val.data[val.data.resourceType]; this.tempContent[val.data.resourceType] = val.data[val.data.resourceType];
console.log('tempContent====',this.tempContent);
} }
}).catch(() => { }).catch(() => {
// this.$modal.msgError("操作失败") // this.$modal.msgError("操作失败")
@@ -279,7 +266,6 @@
// 通过监控模版选项 查询监控策略展示项 // 通过监控模版选项 查询监控策略展示项
fnGetMonitorTempList(id) { fnGetMonitorTempList(id) {
getMonitorTemp(id).then(res => { getMonitorTemp(id).then(res => {
console.log('res===',res);
if (res && res.data) { if (res && res.data) {
if (this.resourceType === 'linux') { if (this.resourceType === 'linux') {
// cpu 详情 // cpu 详情
@@ -298,6 +284,7 @@
} }
}); });
this.linuxSystem.monitorItem[1].checkList = this.tempContent['linux'].other; this.linuxSystem.monitorItem[1].checkList = this.tempContent['linux'].other;
this.handleCheckedCitiesChange(null, this.linuxSystem.monitorItem[1]);
} else { } else {
this.linuxSystem.monitorItem[1].checkList = res.data && res.data['linux'] && res.data['linux'].other || []; this.linuxSystem.monitorItem[1].checkList = res.data && res.data['linux'] && res.data['linux'].other || [];
} }
@@ -350,12 +337,27 @@
} else { } else {
// one // one
if (res.data && res.data['switch'] && res.data['switch'].switchOther && res.data['switch'].switchOther.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchOther && res.data['switch'].switchOther.length > 0) {
this.monitorTable.nodeOne[0].checkList = res.data && res.data['switch'] && res.data['switch'].switchOther; if (this.tempContent['switch'] && this.tempContent['switch'].switchOther && this.tempContent['switch'].switchOther.length > 0) {
this.tempContent['switch'].switchOther.forEach(item => {
if (item && item.collectionCycle) {
item.time = item.collectionCycle.toString();
}
});
this.monitorTable.nodeOne[0].checkList = this.tempContent['switch'].switchOther;
this.handleCheckedCitiesChange(null, this.monitorTable.nodeOne[0]);
} else {
this.monitorTable.nodeOne[0].checkList = res.data && res.data['switch'] && res.data['switch'].switchOther || [];
}
} }
let newArr = []; let newArr = [];
// tow-1 // tow-1
if (res.data && res.data['switch'] && res.data['switch'].switchNet && res.data['switch'].switchNet.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchNet && res.data['switch'].switchNet.length > 0) {
this.monitorTable.nodeTow[0].checkList = res.data && res.data['switch'] && res.data['switch'].switchNet; this.monitorTable.nodeTow[0].checkList = res.data && res.data['switch'] && res.data['switch'].switchNet;
if (this.tempContent['switch'] && this.tempContent['switch'].switchNet && this.tempContent['switch'].switchNet.length > 0) {
if (this.tempContent['switch'].switchNet[0] && this.tempContent['switch'].switchNet[0].collectionCycle) {
this.monitorTable.nodeTow[0].time = this.tempContent['switch'].switchNet[0].collectionCycle.toString();
}
}
newArr.push(this.monitorTable.nodeTow[0]); newArr.push(this.monitorTable.nodeTow[0]);
if (this.monitorTable.nodeTow[0].time) { if (this.monitorTable.nodeTow[0].time) {
this.handleCheckedCitiesChange(this.monitorTable.nodeTow[0].time, this.monitorTable.nodeTow[0]); this.handleCheckedCitiesChange(this.monitorTable.nodeTow[0].time, this.monitorTable.nodeTow[0]);
@@ -364,21 +366,45 @@
// tow-2 // tow-2
if (res.data && res.data['switch'] && res.data['switch'].switchModule && res.data['switch'].switchModule.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchModule && res.data['switch'].switchModule.length > 0) {
this.monitorTable.nodeTow[1].checkList = res.data && res.data['switch'] && res.data['switch'].switchModule; this.monitorTable.nodeTow[1].checkList = res.data && res.data['switch'] && res.data['switch'].switchModule;
if (this.tempContent['switch'] && this.tempContent['switch'].switchModule && this.tempContent['switch'].switchModule.length > 0) {
if (this.tempContent['switch'].switchModule[0] && this.tempContent['switch'].switchModule[0].collectionCycle) {
this.monitorTable.nodeTow[1].time = this.tempContent['switch'].switchModule[0].collectionCycle.toString();
this.handleCheckedCitiesChange(this.monitorTable.nodeTow[1].time, this.monitorTable.nodeTow[1]);
}
}
newArr.push(this.monitorTable.nodeTow[1]); newArr.push(this.monitorTable.nodeTow[1]);
} }
// tow-3 // tow-3
if (res.data && res.data['switch'] && res.data['switch'].switchMpu && res.data['switch'].switchMpu.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchMpu && res.data['switch'].switchMpu.length > 0) {
this.monitorTable.nodeTow[2].checkList = res.data && res.data['switch'] && res.data['switch'].switchMpu; this.monitorTable.nodeTow[2].checkList = res.data && res.data['switch'] && res.data['switch'].switchMpu;
if (this.tempContent['switch'] && this.tempContent['switch'].switchMpu && this.tempContent['switch'].switchMpu.length > 0) {
if (this.tempContent['switch'].switchMpu[0] && this.tempContent['switch'].switchMpu[0].collectionCycle) {
this.monitorTable.nodeTow[2].time = this.tempContent['switch'].switchMpu[0].collectionCycle.toString();
this.handleCheckedCitiesChange(this.monitorTable.nodeTow[2].time, this.monitorTable.nodeTow[2]);
}
}
newArr.push(this.monitorTable.nodeTow[2]); newArr.push(this.monitorTable.nodeTow[2]);
} }
// tow-4 // tow-4
if (res.data && res.data['switch'] && res.data['switch'].switchPwr && res.data['switch'].switchPwr.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchPwr && res.data['switch'].switchPwr.length > 0) {
this.monitorTable.nodeTow[3].checkList = res.data && res.data['switch'] && res.data['switch'].switchPwr; this.monitorTable.nodeTow[3].checkList = res.data && res.data['switch'] && res.data['switch'].switchPwr;
if (this.tempContent['switch'] && this.tempContent['switch'].switchPwr && this.tempContent['switch'].switchPwr.length > 0) {
if (this.tempContent['switch'].switchPwr[0] && this.tempContent['switch'].switchPwr[0].collectionCycle) {
this.monitorTable.nodeTow[3].time = this.tempContent['switch'].switchPwr[0].collectionCycle.toString();
this.handleCheckedCitiesChange(this.monitorTable.nodeTow[3].time, this.monitorTable.nodeTow[3]);
}
}
newArr.push(this.monitorTable.nodeTow[3]); newArr.push(this.monitorTable.nodeTow[3]);
} }
// tow-5 // tow-5
if (res.data && res.data['switch'] && res.data['switch'].switchNet && res.data['switch'].switchNet.length > 0) { if (res.data && res.data['switch'] && res.data['switch'].switchFan && res.data['switch'].switchFan.length > 0) {
this.monitorTable.nodeTow[4].checkList = res.data && res.data['switch'] && res.data['switch'].switchFan; this.monitorTable.nodeTow[4].checkList = res.data && res.data['switch'] && res.data['switch'].switchFan;
if (this.tempContent['switch'] && this.tempContent['switch'].switchFan && this.tempContent['switch'].switchFan.length > 0) {
if (this.tempContent['switch'].switchFan[0] && this.tempContent['switch'].switchFan[0].collectionCycle) {
this.monitorTable.nodeTow[4].time = this.tempContent['switch'].switchFan[0].collectionCycle.toString();
this.handleCheckedCitiesChange(this.monitorTable.nodeTow[4].time, this.monitorTable.nodeTow[4]);
}
}
newArr.push(this.monitorTable.nodeTow[4]); newArr.push(this.monitorTable.nodeTow[4]);
} }
this.monitorTable.nodeTow = newArr; this.monitorTable.nodeTow = newArr;
@@ -387,7 +413,6 @@
}); });
}, },
async next(num) { async next(num) {
console.log('num==',num,'active====',this.active);
if (num === '-1') { if (num === '-1') {
this.active--; this.active--;
} else { } else {
@@ -469,15 +494,14 @@
} }
} }
}); });
console.log('params===',this.paramsList);
this.synthesisList = Object.assign({}, this.checkAllParams); this.synthesisList = Object.assign({}, this.checkAllParams);
}, },
// 单个选择按钮 // 单个选择按钮
handleCheckedCitiesChange(changeVal,iteListAll) { handleCheckedCitiesChange(changeVal,iteListAll) {
console.log('changeVal==',changeVal, 'iteListAll===',iteListAll, 'cvvvv===','time' in iteListAll);
if ('time' in iteListAll) { if ('time' in iteListAll) {
if (changeVal) { if (changeVal) {
this.checkAllParams[iteListAll.modelName].time = iteListAll && iteListAll.time; this.checkAllParams[iteListAll.modelName]['time'] = iteListAll && iteListAll.time;
this.checkAllParams[iteListAll.modelName].data = iteListAll['checkList'];
} else { } else {
delete this.checkAllParams[iteListAll.modelName]; delete this.checkAllParams[iteListAll.modelName];
} }
@@ -487,9 +511,7 @@
}, },
// 提交 // 提交
submit() { submit() {
console.log('ruleFormData==',this.ruleFormData); let params = Object.assign(this.ruleFormData, {resourceType: this.resourceType}, {collectionAndIdList: this.paramsList});
console.log('synthesisList==',this.synthesisList);
let params = Object.assign({resourceType: this.resourceType}, {collectionAndIdList: this.paramsList}, this.ruleFormData);
let fnType = addMonitorPolicy; let fnType = addMonitorPolicy;
if (this.paramsData && this.paramsData.id) { if (this.paramsData && this.paramsData.id) {
fnType = updateMonitorPolicy; fnType = updateMonitorPolicy;
@@ -501,7 +523,6 @@
this.$modal.closeLoading(); this.$modal.closeLoading();
}).catch(error => { }).catch(error => {
this.$modal.closeLoading(); this.$modal.closeLoading();
this.$modal.msgError("操作失败")
}); });
}, },
// 返回 // 返回

View File

@@ -2,10 +2,10 @@
<div class="app-container pageTopForm"> <div class="app-container pageTopForm">
<el-form :model="queryParams" ref="queryRef" size="small" v-show="showSearch" label-width="auto"> <el-form :model="queryParams" ref="queryRef" size="small" v-show="showSearch" label-width="auto">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="搜索" prop="switchName"> <el-form-item label="搜索" prop="queryName">
<el-input <el-input
v-model="queryParams.switchName" v-model="queryParams.queryName"
placeholder="请输入模版名称/资源组名/监控模版名称" placeholder="请输入策略名称/资源组名/监控模版名称"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
@@ -18,7 +18,7 @@
placeholder="请选择策略状态" placeholder="请选择策略状态"
clearable> clearable>
<el-option <el-option
v-for="dict in dict.type.eps_bandwidth_type" v-for="dict in dict.type.policy_status"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value"/> :value="dict.value"/>
@@ -33,8 +33,8 @@
</el-col> </el-col>
</el-form> </el-form>
<TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="tableList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange"> <TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="tableList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange">
<template #tempType="{ row, column }"> <template #tempStatus="{ row, column }">
<dict-tag :options="dict.type.rm_topology_type" :value="row.connectedDeviceType"/> <dict-tag :options="dict.type.policy_status" :value="row.status"/>
</template> </template>
</TableList> </TableList>
</div> </div>
@@ -42,11 +42,11 @@
<script setup> <script setup>
import TableList from "@/components/table/index.vue" import TableList from "@/components/table/index.vue"
import {listMonitorPolicy, delMonitorPolicy} from "@/api/disRevenue/resource" import {listMonitorPolicy, delMonitorPolicy, getMonitorPolicyList} from "@/api/disRevenue/resource"
export default { export default {
name: 'MonitorStategy', name: 'MonitorStategy',
components: {TableList}, components: {TableList},
dicts: ['rm_topology_type','eps_bandwidth_type'], dicts: ['rm_topology_type','eps_bandwidth_type', 'policy_status'],
data() { data() {
return { return {
loading: true, loading: true,
@@ -62,11 +62,11 @@
id: { label: `ID`,width: '50'}, id: { label: `ID`,width: '50'},
policyName: { label: `策略名称`, minWidth: '250', visible: true }, policyName: { label: `策略名称`, minWidth: '250', visible: true },
description: { label: `描述`,minWidth: '200',visible: false}, description: { label: `描述`,minWidth: '200',visible: false},
resourceGroupId: { label: `关联资源组`,minWidth: '150', visible: true }, resourceGroupName: { label: `关联资源组`,minWidth: '150', visible: true },
includedDevicesName: { label: `包含设备`,minWidth: '200'}, includedDevicesName: { label: `包含设备`,minWidth: '200'},
templateId: { label: `关联监控模版`,minWidth: '150', visible: true }, templateName: { label: `关联监控模版`,minWidth: '150', visible: true },
connected: { label: `策略内容`,minWidth: '200'}, connected: { label: `策略内容`,minWidth: '200'},
status: { label: `策略状态`, minWidth: '100', visible: true }, status: { label: `策略状态`, minWidth: '100', slotName: 'tempStatus', visible: true },
deployTime: { label: `下发策略时间`,minWidth: '160'}, deployTime: { label: `下发策略时间`,minWidth: '160'},
createTime: { label: `创建时间`,minWidth: '160'}, createTime: { label: `创建时间`,minWidth: '160'},
updateTime:{ label: `修改时间`,minWidth: '160'} updateTime:{ label: `修改时间`,minWidth: '160'}
@@ -85,7 +85,7 @@
{content: '修改', fnCode: 'edit', type: 'text', icon: 'el-icon-edit', hasPermi: 'disRevenue:resource:monitorStategy:edit'}, {content: '修改', fnCode: 'edit', type: 'text', icon: 'el-icon-edit', hasPermi: 'disRevenue:resource:monitorStategy:edit'},
{content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'disRevenue:resource:monitorStategy:details'}, {content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'disRevenue:resource:monitorStategy:details'},
// {content: '复制', fnCode: 'copy', type: 'text', icon: 'el-icon-document-copy', hasPermi: 'disRevenue:resource:monitorStategy:copy'}, // {content: '复制', fnCode: 'copy', type: 'text', icon: 'el-icon-document-copy', hasPermi: 'disRevenue:resource:monitorStategy:copy'},
{content: '下发策略', fnCode: 'strategy', type: 'text', icon: 'el-icon-sort-down', hasPermi: 'disRevenue:resource:monitorStategy:strategy'}, {content: '下发策略', fnCode: 'strategy', type: 'text', showName: 'status', showVal: '0', icon: 'el-icon-sort-down', hasPermi: 'disRevenue:resource:monitorStategy:strategy'},
{} {}
] ]
} }
@@ -149,7 +149,8 @@
this.$router.push({ this.$router.push({
path:'/disRevenue/resource/monitorStategy/view/index', path:'/disRevenue/resource/monitorStategy/view/index',
query:{ query:{
id: rowData.id id: rowData.id,
readonly: true
} }
}); });
break; break;
@@ -165,6 +166,18 @@
this.$modal.msgSuccess("删除成功") this.$modal.msgSuccess("删除成功")
}).catch(() => {}); }).catch(() => {});
break; break;
case 'strategy':
this.$modal.confirm('是否确认下发策略?').then(() => {
this.$modal.loading();
getMonitorPolicyList(rowData.id).then(res => {
this.getList();
this.$modal.msgSuccess(res.msg);
this.$modal.closeLoading();
}).catch(error => {
this.$modal.closeLoading();
});
}).catch(() => {});
break;
case 'export': case 'export':
// let dataList = []; // let dataList = [];
// Object.keys(this.columns).forEach(item => { // Object.keys(this.columns).forEach(item => {

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<Form :config="{buttonGroup: []}" :formList="formList" :ruleFormData="ruleForm" @fnClick="callback"></Form> <Form :config="{buttonGroup: []}" :formList="formList" :ruleFormData="this.paramsData && this.paramsData.readonly ? ruleFormData : ruleForm" @fnClick="callback"></Form>
<div v-for="(item, key, index) of otherList" style="margin-top: 50px"> <div v-for="(item, key, index) of renderList" style="margin-top: 50px">
<div v-if="item.data && item.data.length > 0"> <div v-if="item.data && item.data.length > 0">
<!-- {{item}}--> <!-- {{item}}-->
<div class="form-header h4" style="background: #d4e3fc;padding: 15px 10px;border-radius: 5px"> <div class="form-header h4" style="background: #d4e3fc;padding: 15px 10px;border-radius: 5px">
@@ -32,9 +32,10 @@
<script setup> <script setup>
import Form from '@/components/form/index.vue'; import Form from '@/components/form/index.vue';
import TableList from "@/components/table/index.vue" import TableList from "@/components/table/index.vue"
import {getMonitorPolicyTemp, getResMonitorGroup} from "@/api/disRevenue/resource" import {getMonitorPolicyTemp, getResMonitorGroup,getMonitorPolicy} from "@/api/disRevenue/resource"
export default { export default {
name: 'MonitorStategyView', name: 'MonitorStategyView',
dicts: ['collection_cycle'],
components: {Form,TableList}, components: {Form,TableList},
props: { props: {
ruleForm: { ruleForm: {
@@ -50,23 +51,53 @@
return { return {
formList: [], formList: [],
paramsData: {}, paramsData: {},
columns: { ruleFormData: {},
id: { label: `ID`, visible: false }, option: [],
ident: { label: `监控标识`, visible: true}, resourceType: '',
name: { label: `监控名称`, visible: true}, checkAllParams: {},
monitor: { label: `监控OID`, visible: true }, otherListData: {},
filter: { label: `过滤值`}, linuxSystem: {
explain: { label: `监控说明`, visible: true} monitorItem: [
{firstTitle: 'Linux系统', secondTitle: '监控项', title: 'CPU监控', modelName: 'cpu',time: '', checkList: []},
{firstTitle: 'Linux系统', secondTitle: '监控项', title: '其他监控', modelName: 'other', checkList: []}
],
autodiscoverItem: [
{firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现挂载文件系统', modelName: 'vfs', time: '', checkList: []},
{firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现网络接口', modelName: 'net', time: '300', checkList: []},
{firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现硬盘设备', modelName: 'disk', time: '', checkList: []},
{firstTitle: 'Linux系统', secondTitle: '自动发现项', title: '发现docker', modelName: 'docker', time: '', checkList: []}
],
}, },
config: {colHiddenCheck: true} // 第二节点 2栏 列显隐信息
monitorTable: {
nodeOne: [{firstTitle: '华为交换机', secondTitle: '监控项', modelName: 'switchOther', checkList: []}],
nodeTow: [
{firstTitle: '华为交换机', secondTitle: '自动发现项', title: '网络端口发现', modelName: 'switchNet', time: '300', checkList: []},
{firstTitle: '华为交换机', secondTitle: '自动发现项',title: '光模块发现', modelName: 'switchModule', time: '', checkList: []},
{firstTitle: '华为交换机', secondTitle: '自动发现项',title: 'MPU发现', modelName: 'switchMpu', time: '', checkList: []},
{firstTitle: '华为交换机', secondTitle: '自动发现项',title: '电源发现', modelName: 'switchPwr', time: '', checkList: []},
{firstTitle: '华为交换机', secondTitle: '自动发现项',title: '风扇发现', modelName: 'switchFan', time: '', checkList: []},
]},
}
},
computed: {
renderList() {
// 优先用 props 传入的 otherList其次用接口加载的 otherListData
const sourceList = this.paramsData && this.paramsData.readonly ? this.otherListData : this.otherList;
// 将 Object 转为 Array键名作为 key值作为 item避免循环顺序问题
return sourceList;
} }
}, },
created() { created() {
this.option = this.dict.type.collection_cycle;
this.paramsData = this.$route && this.$route.query; this.paramsData = this.$route && this.$route.query;
console.log('otherList=',this.otherList); if (this.paramsData && this.paramsData.readonly) {
this.fnFormList(); this.getFormDataList(this.paramsData.id);
this.fnResMonitorGroup(); } else {
this.fnMonitorPolicyTemp(); this.fnFormList();
this.fnResMonitorGroup();
}
// this.fnMonitorPolicyTemp();
}, },
methods: { methods: {
fnFormList(){ fnFormList(){
@@ -74,13 +105,95 @@
config: {title: '', readonly: true}, config: {title: '', readonly: true},
controls: { controls: {
id: {label: 'ID',hidden: true}, id: {label: 'ID',hidden: true},
policyName: {label: '策略名称', span: 24, type: 'input', required: true}, policyName: {label: '策略名称', span: this.paramsData && this.paramsData.readonly ? 12 : 24, type: 'input', required: true},
// templateId: {label: '关联监控模版', span: 24, type: 'select',options: [], eventName: 'change', style: 'display: block;margin: 0 auto;'},
resourceGroupId: {label: '关联资源组', span: this.paramsData && this.paramsData.readonly ? 12 : 24, type: 'select', options:[]},
updateTime: {label: '修改时间', span: this.paramsData && this.paramsData.readonly ? 12 : 24, type: 'date'},
deployTime: {label: '下发策略时间', span: 12, type: 'date',hidden: !(this.resourceType === 'switch' && this.paramsData && this.paramsData.readonly)},
includedDevicesName: {label: '包含设备', span: 24, type: 'input', hidden: !(this.resourceType === 'switch' && this.paramsData && this.paramsData.readonly)},
description: {label: '描述', span: 24, type: 'textarea'}, description: {label: '描述', span: 24, type: 'textarea'},
templateId: {label: '关联监控模版', span: 24, type: 'select',options: [], eventName: 'change', style: 'display: block;margin: 0 auto;'},
resourceGroupId: {label: '关联资源组', span: 24, type: 'select', options:[]}
} }
}]; }];
}, },
// 获取详情
getFormDataList(id) {
getMonitorPolicy(id).then(val => {
if (val && val.data) {
this.ruleFormData = val.data.policy;
this.resourceType = val.data.resourceType;
this.fnFormList();
this.fnResMonitorGroup();
this.dataProcess();
let obj = {};
this.option.forEach(item => {
obj[item.value] = item.label;
});
if (val.data.resourceType === 'linux') {
Object.keys(this.checkAllParams).forEach(item => {
if (item === 'other' && val.data['linux'] && val.data['linux'][item] && val.data['linux'][item].length > 0) {
let otherTimes = [];
val.data['linux'] && val.data['linux'][item].forEach(timeVal => {
if (timeVal && timeVal.collectionCycle) {
timeVal['timeLabel'] = obj[timeVal.collectionCycle.toString()];
otherTimes.push(timeVal);
}
});
this.checkAllParams[item].data = otherTimes || [];
} else {
if(item && val.data['linux'][item] && val.data['linux'][item].length > 0) {
if (val.data['linux'][item][0] && val.data['linux'][item][0].collectionCycle) {
this.checkAllParams[item]['timeLabel'] = obj[val.data['linux'][item][0].collectionCycle.toString()];
this.checkAllParams[item].data = val.data['linux'][item];
}
}
}
});
} else {
Object.keys(this.checkAllParams).forEach(item => {
if (item === 'switchOther' && val.data['switch'] && val.data['switch'][item] && val.data['switch'][item].length > 0) {
let switchOtherTime = [];
val.data['switch'] && val.data['switch'][item].forEach(timeVal => {
if (timeVal && timeVal.collectionCycle) {
timeVal['timeLabel'] = obj[timeVal.collectionCycle.toString()];
switchOtherTime.push(timeVal);
}
});
this.checkAllParams[item].data = switchOtherTime || [];
} else {
if(item && val.data['switch'][item] && val.data['switch'][item].length > 0) {
if (val.data['switch'][item][0] && val.data['switch'][item][0].collectionCycle) {
this.checkAllParams[item]['timeLabel'] = obj[val.data['switch'][item][0].collectionCycle.toString()];
this.checkAllParams[item].data = val.data['switch'][item];
}
}
}
});
}
this.otherListData = {...this.checkAllParams};
}
}).catch(() => {
// this.$modal.msgError("操作失败")
});
},
// 数据处理
dataProcess() {
let typeVal = {};
if (this.resourceType === 'linux') {
typeVal = this.linuxSystem;
} else {
typeVal = this.monitorTable;
}
Object.keys(typeVal).forEach(res => {
typeVal[res].forEach(item => {
this.checkAllParams[item.modelName] = {
firstTitle: item.firstTitle,
secondTitle: item.secondTitle,
lastTitle: item.title,
data: []
};
});
})
},
// 资源组 // 资源组
fnResMonitorGroup(){ fnResMonitorGroup(){
getResMonitorGroup().then(res => { getResMonitorGroup().then(res => {
@@ -91,18 +204,18 @@
} }
}); });
}, },
// 监控模版 // // 监控模版
fnMonitorPolicyTemp(){ // fnMonitorPolicyTemp(){
getMonitorPolicyTemp().then(res => { // getMonitorPolicyTemp().then(res => {
if (res && res.data) { // if (res && res.data) {
this.policyTemp = {}; // this.policyTemp = {};
this.formList[0].controls['templateId']['options']= res && res.data.map(item => { // this.formList[0].controls['templateId']['options']= res && res.data.map(item => {
this.policyTemp[item.id] = item; // this.policyTemp[item.id] = item;
return Object.assign({label: item.templateName, value: item.id}); // return Object.assign({label: item.templateName, value: item.id});
}); // });
} // }
}); // });
}, // },
// 返回 // 返回
handleReset() { handleReset() {
this.$router.push("/resource/monitorStategy"); this.$router.push("/resource/monitorStategy");

View File

@@ -359,14 +359,41 @@
},500); },500);
} }
} else { } else {
this.monitorTable.nodeTow[0].tableList = res.data.switchNet; if (this.paramsData && this.paramsData.id) {
this.monitorTable.nodeTow[1].tableList = res.data.switchModule; if (this.tempContent['switch'] && this.tempContent['switch'].switchNet && this.tempContent['switch'].switchNet.length > 0) {
this.monitorTable.nodeTow[2].tableList = res.data.switchFan; this.monitorTable.nodeTow[0].tableList = this.tempContent['switch'].switchNet;
setTimeout(() => { setTimeout(() => {
this.$refs[`tableRef_web1`][0].selectAllRows(); this.$refs[`tableRef_web1`][0].selectAllRows();
this.$refs[`tableRef_web2`][0].selectAllRows(); },500);
this.$refs[`tableRef_web3`][0].selectAllRows(); } else {
},500); this.monitorTable.nodeTow[0].tableList = res.data.switchNet;
}
if (this.tempContent['switch'] && this.tempContent['switch'].switchModule && this.tempContent['switch'].switchModule.length > 0) {
this.monitorTable.nodeTow[1].tableList = this.tempContent['switch'].switchModule;
setTimeout(() => {
this.$refs[`tableRef_web2`][0].selectAllRows();
},500);
} else {
this.monitorTable.nodeTow[1].tableList = res.data.switchModule;
}
if (this.tempContent['switch'] && this.tempContent['switch'].switchFan && this.tempContent['switch'].switchFan.length > 0) {
this.monitorTable.nodeTow[2].tableList = this.tempContent['switch'].switchFan;
setTimeout(() => {
this.$refs[`tableRef_web3`][0].selectAllRows();
},500);
} else {
this.monitorTable.nodeTow[2].tableList = res.data.switchFan;
}
} else {
this.monitorTable.nodeTow[0].tableList = res.data.switchNet;
this.monitorTable.nodeTow[1].tableList = res.data.switchModule;
this.monitorTable.nodeTow[2].tableList = res.data.switchFan;
setTimeout(() => {
this.$refs[`tableRef_web1`][0].selectAllRows();
this.$refs[`tableRef_web2`][0].selectAllRows();
this.$refs[`tableRef_web3`][0].selectAllRows();
},500);
}
} }
} }
}); });

View File

@@ -149,7 +149,7 @@
}, },
created() { created() {
this.paramsData = this.$route && this.$route.query; this.paramsData = this.$route && this.$route.query;
if (this.paramsData && this.paramsData.id) { if (this.paramsData && this.paramsData.readonly) {
this.getFormDataList(this.paramsData.id); this.getFormDataList(this.paramsData.id);
} }
this.fnFormList(); this.fnFormList();

View File

@@ -1,69 +1,84 @@
<template> <template>
<div> <div>
<el-form :model="form" label-width="120px" class="dynamic-form"> <el-form :model="form" ref="form" label-width="130px" class="dynamic-form">
<!-- 动态源文件部分 --> <el-col :span="14">
<div v-for="(source, index) in form.sources" :key="index" class="source-item"> <el-form-item :label="`源文件1地址格式`" prop="sourceFilePathType" :rules="[{ required: true, message: '请选择地址格式', trigger: 'change' }]">
<!-- 源文件地址格式 --> <el-radio-group v-model="form.sourceFilePathType" :disabled="readonly">
<el-form-item :label="`源文件${index + 1}地址格式`" :prop="`sources.${index}.format`" :rules="[{ required: true, message: '请选择地址格式', trigger: 'change' }]"> <!-- <el-radio label="platform">平台文件地址</el-radio>-->
<el-radio-group v-model="source.format"> <el-radio label="1">外网HTTP(S)</el-radio>
<el-radio label="platform">平台文件地址</el-radio>
<el-radio label="external">外网HTTP(S)</el-radio>
</el-radio-group> </el-radio-group>
<div class="tip">注意当文件大小超过100M时请选择外网HTTP(S)地址格式</div> <div class="tip">注意当文件大小超过100M时请选择外网HTTP(S)地址格式</div>
<div class="error-tip" v-if="source.sizeError">您选择的文件已经超过100M请更改文件地址格式选择</div> <!-- <div class="error-tip" v-if="source.sizeError">您选择的文件已经超过100M请更改文件地址格式选择</div>-->
</el-form-item> </el-form-item>
</el-col>
<!-- 添加源文件按钮 -->
<el-col :span="10" style="vertical-align: top;" v-if="!readonly">
<el-form-item style="margin-left: -130px;">
<el-button type="primary" @click="addSource" class="add-btn">添加</el-button>
</el-form-item>
</el-col>
<!-- 源文件地址 -->
<el-col :span="12">
<el-form-item :label="`源文件1地址`" prop="sourceFilePath" :rules="[{ required: true, message: '请输入外网地址', trigger: 'change' }]">
<el-input v-model="form.sourceFilePath" :disabled="readonly" placeholder="请输入外网地址" clearable></el-input>
</el-form-item>
</el-col>
<!-- 动态源文件部分 循环多个源文件地址 -->
<div v-for="(source, index) in form.sources" :key="index" class="source-item">
<!-- 源文件地址格式 -->
<el-col :span="14">
<el-form-item :label="`源文件${index + 2}地址格式`" prop="sourceFilePathType" :rules="[{ required: true, message: '请选择地址格式', trigger: 'change' }]">
<el-radio-group v-model="source.sourceFilePathType" :disabled="readonly">
<!-- <el-radio label="platform">平台文件地址</el-radio>-->
<el-radio label="1">外网HTTP(S)</el-radio>
</el-radio-group>
<div class="tip">注意当文件大小超过100M时请选择外网HTTP(S)地址格式</div>
<!-- <div class="error-tip" v-if="source.sizeError">您选择的文件已经超过100M请更改文件地址格式选择</div>-->
</el-form-item>
</el-col>
<!-- 添加源文件按钮 -->
<el-col :span="10" v-if="!readonly">
<el-form-item style="margin-left: -130px;">
<el-button type="danger" @click="removeSource(index)" class="delete-btn">删除</el-button>
</el-form-item>
</el-col>
<!-- 源文件地址 --> <!-- 源文件地址 -->
<el-form-item :label="`源文件${index + 1}地址`" :prop="`sources.${index}.address`" :rules="[{ required: true, message: '请选择文件地址', trigger: 'change' }]"> <el-col :span="12">
<el-select v-model="source.address" placeholder="请选择或输入地址" filterable clearable> <el-form-item :label="`源文件${index + 2}地址`" prop="sourceFilePath" :rules="[{ required: true, message: '请输入外网地址', trigger: 'change' }]">
<el-option label="系统默认文件1" value="system-default-1"></el-option> <el-input v-model="source.sourceFilePath" :disabled="readonly" placeholder="请输入外网地址" clearable></el-input>
<el-option label="系统默认文件2" value="system-default-2"></el-option> </el-form-item>
<el-option label="用户上传文件1" value="user-upload-1"></el-option> </el-col>
<el-option label="用户上传文件2" value="user-upload-2"></el-option>
</el-select>
</el-form-item>
<!-- 删除按钮 - 至少保留一个源文件 -->
<el-button type="danger" icon="el-icon-delete" @click="removeSource(index)" v-if="form.sources.length > 1" class="delete-btn">删除源文件{{ index + 1 }}</el-button>
</div> </div>
<!-- 添加源文件按钮 --> <el-col :span="24">
<el-form-item> <!-- 目标目录 -->
<el-button type="primary" icon="el-icon-plus" @click="addSource" class="add-btn">添加源文件</el-button> <el-form-item label="目标目录" prop="targetDirectory">
</el-form-item> <el-input v-model="form.targetDirectory" :disabled="readonly" placeholder="请输入目标目录路径" clearable></el-input>
</el-form-item>
</el-col>
<!-- 目标目录 --> <el-col :span="24">
<el-form-item label="目标目录" prop="targetDir" :rules="[{ required: true, message: '请输入目标目录', trigger: 'blur' }]"> <!-- 命令内容部分 -->
<el-input v-model="form.targetDir" placeholder="请输入目标目录路径" clearable></el-input> <el-form-item label="命令内容">
</el-form-item> <div v-for="(cmd, index) in form.commands" :key="index" class="command-item">
{{index + 1}}. <el-input v-model="cmd.commandContent" :disabled="readonly" class="ml5" placeholder="请输入命令" clearable></el-input>
<!-- 命令内容部分 --> <el-button type="primary" @click="addCommand" v-if="readonly ? !readonly : index === 0" class="command-btn">添加</el-button>
<el-form-item label="命令内容"> <el-button type="danger" @click="removeCommand(index)" v-if="readonly ? !readonly : index >= 1" class="command-btn">删除</el-button>
<div v-for="(cmd, index) in form.commands" :key="index" class="command-item"> </div>
<!-- <el-input v-model="cmd" placeholder="请输入命令" clearable></el-input>--> </el-form-item>
<el-button type="primary" icon="el-icon-plus" @click="addCommand" v-if="index === form.commands.length - 1" class="command-btn">添加</el-button> </el-col>
<el-button type="danger" icon="el-icon-delete" @click="removeCommand(index)" v-if="form.commands.length > 1" class="command-btn">删除</el-button>
</div>
</el-form-item>
<!-- 执行方式 --> <!-- 执行方式 -->
<el-form-item label="执行方式" prop="executionMode" :rules="[{ required: true, message: '请选择执行方式', trigger: 'change' }]"> <el-form-item label="执行方式" prop="executionMethod">
<el-select v-model="form.executionMode" placeholder="请选择执行方式" clearable> <el-select v-model="form.executionMethod" placeholder="请选择执行方式" :disabled="readonly" clearable>
<el-option label="立即执行" value="immediate"></el-option> <el-option v-for="dict in dict.type.policy_method" :key="dict.value" :label="dict.label" :value="dict.value"/>
<el-option label="定时执行" value="scheduled"></el-option>
<el-option label="手动触发" value="manual"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- 定时时间 --> <!-- 定时时间 -->
<el-form-item label="定时时间" v-if="form.executionMode === 'scheduled'" prop="scheduleTime" :rules="[{ required: true, message: '请选择定时时间', trigger: 'change' }]"> <el-form-item label="定时时间" v-if="form.executionMethod === '1'" prop="scheduledTime" :rules="[{ required: true, message: '请选择定时时间', trigger: 'change' }]">
<el-date-picker v-model="form.scheduleTime" type="datetime" placeholder="选择日期时间" style="width: 100%;"></el-date-picker> <el-date-picker v-model="form.scheduledTime" :disabled="readonly" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 100%;"></el-date-picker>
</el-form-item>
<!-- 提交按钮 -->
<el-form-item>
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
@@ -72,36 +87,46 @@
<script> <script>
export default { export default {
name: 'DynamicForm', name: 'DynamicForm',
dicts: ['policy_method'],
props: {
formData: {
type: Object,
default: () => ({
sourceFilePathType: '1',
sources: [], // 源文件数组,初始为空
commands: [{commandContent: ''}], // 命令内容数组
})
},
readonly: {
type: Boolean,
default: false
}
},
watch: {
// 监听 props 变化,实时更新内部数据
formData: {
immediate: true, // 初始化时立即执行一次
handler(newVal) {
if (newVal && typeof newVal === 'object' && Object.keys(newVal).length === 0) {
this.form = {sourceFilePathType: '1', sources: [], commands: [{commandContent: ''}]};
} else {
this.form = newVal;
}
},
},
},
data() { data() {
return { return {
form: { form: this.formData
// 源文件数组,初始包含两个源文件
sources: [
{
format: '', // 地址格式platform/external
address: '', // 文件地址
sizeError: false // 文件大小错误标记
},
{
format: '',
address: '',
sizeError: false
}
],
targetDir: '', // 目标目录
commands: [''], // 命令内容数组
executionMode: '', // 执行方式
scheduleTime: '' // 定时时间
}
}; };
}, },
methods: { methods: {
// 添加源文件 // 添加源文件
addSource() { addSource() {
this.form.sources.push({ this.form.sources.push({
format: '', sourceFilePathType: '1',
address: '', sourceFilePath: '',
sizeError: false // sizeError: false
}); });
}, },
@@ -112,7 +137,7 @@
// 添加命令 // 添加命令
addCommand() { addCommand() {
this.form.commands.push(''); this.form.commands.push({commandContent: ''});
}, },
// 删除命令 // 删除命令
@@ -122,26 +147,30 @@
// 提交表单 // 提交表单
submitForm() { submitForm() {
this.$refs.form.validate((valid) => { return new Promise((resolve, reject) => {
if (valid) { this.$refs.form.validate((valid) => {
// 在这里可以添加自定义验证逻辑,例如检查大文件是否使用了正确的地址格式 console.log('valid===',valid);
const hasError = this.form.sources.some(source => { if (valid) {
// 假设这里有判断文件大小的逻辑 resolve(this.form);
const fileSize = this.getFileSize(source.address); // 假设的方法 // // 在这里可以添加自定义验证逻辑,例如检查大文件是否使用了正确的地址格式
source.sizeError = fileSize > 100 && source.format === 'platform'; // const hasError = this.form.sources.some(source => {
return source.sizeError; // // 假设这里有判断文件大小的逻辑
}); // const fileSize = this.getFileSize(source.address); // 假设的方法
// source.sizeError = fileSize > 100 && source.format === 'platform';
if (!hasError) { // return source.sizeError;
this.$message.success('表单提交成功'); // });
console.log('表单数据:', this.form); // if (!hasError) {
// this.$message.success('表单提交成功');
// console.log('表单数据:', this.form);
// } else {
// this.$message.error('存在文件大小与地址格式不匹配的问题,请检查');
// }
} else { } else {
this.$message.error('存在文件大小与地址格式不匹配的问题,请检查'); this.$message.error('表单验证失败,请检查必填项');
reject(new Error('验证失败')); // 失败时返回错误
return false;
} }
} else { });
this.$message.error('表单验证失败,请检查必填项');
return false;
}
}); });
}, },
@@ -172,14 +201,14 @@
</script> </script>
<style scoped> <style scoped>
.dynamic-form { /*.dynamic-form {*/
max-width: 800px; /* max-width: 800px;*/
margin: 20px auto; /* margin: 20px auto;*/
padding: 20px; /* padding: 20px;*/
background-color: #fff; /* background-color: #fff;*/
border-radius: 4px; /* border-radius: 4px;*/
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); /* box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);*/
} /*}*/
.tip { .tip {
color: #faad14; color: #faad14;
@@ -195,11 +224,11 @@
line-height: 1.5; line-height: 1.5;
} }
.source-item { /*.source-item {*/
padding-bottom: 15px; /* padding-bottom: 15px;*/
margin-bottom: 15px; /* margin-bottom: 15px;*/
border-bottom: 1px dashed #e8e8e8; /* border-bottom: 1px dashed #e8e8e8;*/
} /*}*/
.source-item:last-child { .source-item:last-child {
border-bottom: none; border-bottom: none;

View File

@@ -2,9 +2,9 @@
<div class="app-container pageTopForm"> <div class="app-container pageTopForm">
<el-form :model="queryParams" ref="queryRef" size="small" v-show="showSearch" label-width="auto"> <el-form :model="queryParams" ref="queryRef" size="small" v-show="showSearch" label-width="auto">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="策略名称" prop="switchName"> <el-form-item label="策略名称" prop="policyName">
<el-input <el-input
v-model="queryParams.switchName" v-model="queryParams.policyName"
placeholder="请输入策略名称" placeholder="请输入策略名称"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
@@ -12,13 +12,13 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="策略状态" prop="bandwidthType"> <el-form-item label="策略状态" prop="policyStatus">
<el-select <el-select
v-model="queryParams.bandwidthType" v-model="queryParams.policyStatus"
placeholder="请选择策略状态" placeholder="请选择策略状态"
clearable> clearable>
<el-option <el-option
v-for="dict in dict.type.eps_bandwidth_type" v-for="dict in dict.type.policy_status"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value"/> :value="dict.value"/>
@@ -34,7 +34,7 @@
</el-form> </el-form>
<TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="tableList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange"> <TableList :columns="columns" :config="config" :queryParams="queryParams" :tableList="tableList" @fnClick="callback" @fnRenderList="getList" @value-change="handleValueChange">
<template #tempType="{ row, column }"> <template #tempType="{ row, column }">
<dict-tag :options="dict.type.rm_topology_type" :value="row.connectedDeviceType"/> <dict-tag :options="dict.type.policy_status" :value="row.policyStatus"/>
</template> </template>
</TableList> </TableList>
</div> </div>
@@ -42,11 +42,11 @@
<script setup> <script setup>
import TableList from "@/components/table/index.vue" import TableList from "@/components/table/index.vue"
import {listMonitorTemp, delMonitorTemp} from "@/api/disRevenue/resource" import {listPolicy, delPolicy} from "@/api/disRevenue/resource"
export default { export default {
name: 'ServerScript', name: 'ServerScript',
components: {TableList}, components: {TableList},
dicts: ['rm_topology_type','eps_bandwidth_type'], dicts: ['policy_status'],
data() { data() {
return { return {
loading: true, loading: true,
@@ -60,17 +60,17 @@
// 列显隐信息 // 列显隐信息
columns: { columns: {
id: { label: `ID`,width: '50'}, id: { label: `ID`,width: '50'},
switchName: { label: `策略名称`, minWidth: '250', visible: true }, policyName: { label: `策略名称`, minWidth: '250', visible: true },
state: { label: `执行方式`,minWidth: '200',visible: true}, executionMethod: { label: `执行方式`,minWidth: '200',visible: true},
interfaceName: { label: `关联资源组`,minWidth: '150', visible: true }, resourceGroupId: { label: `关联资源组`,minWidth: '150', visible: true },
serverName: { label: `包含设备`,minWidth: '200', visible: true}, includedDevicesName: { label: `包含设备`,minWidth: '200', visible: true},
type: { label: `策略状态`, minWidth: '100', visible: true }, policyStatus: { label: `策略状态`, minWidth: '100', slotName: 'tempType', visible: true },
connectedDeviceType: { label: `源文件路径`,minWidth: '150'}, sourceFilePath: { label: `源文件路径`,minWidth: '150'},
connected: { label: `目标目录`,minWidth: '200'}, targetDirectory: { label: `目标目录`,minWidth: '200'},
content: { label: `命令内容`,minWidth: '200'}, commandContent: { label: `命令内容`,minWidth: '200'},
time: { label: `定时时间`,minWidth: '200'}, scheduledTime: { label: `定时时间`,minWidth: '200'},
conType: { label: `下发策略时间`,minWidth: '160'}, deployTime: { label: `下发策略时间`,minWidth: '160'},
switchSn: { label: `描述`,minWidth: '200'}, description: { label: `描述`,minWidth: '200'},
createTime: { label: `创建时间`,minWidth: '160'}, createTime: { label: `创建时间`,minWidth: '160'},
updateTime:{ label: `修改时间`,minWidth: '160'} updateTime:{ label: `修改时间`,minWidth: '160'}
}, },
@@ -87,7 +87,7 @@
line: [ line: [
{content: '修改', fnCode: 'edit', type: 'text', icon: 'el-icon-edit', hasPermi: 'disRevenue:resource:monitorStategy:edit'}, {content: '修改', fnCode: 'edit', type: 'text', icon: 'el-icon-edit', hasPermi: 'disRevenue:resource:monitorStategy:edit'},
{content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'disRevenue:resource:monitorStategy:details'}, {content: '详情', fnCode: 'details', type: 'text', icon: 'el-icon-view', hasPermi: 'disRevenue:resource:monitorStategy:details'},
{content: '复制', fnCode: 'copy', type: 'text', icon: 'el-icon-document-copy', hasPermi: 'disRevenue:resource:monitorStategy:copy'}, // {content: '复制', fnCode: 'copy', type: 'text', icon: 'el-icon-document-copy', hasPermi: 'disRevenue:resource:monitorStategy:copy'},
{content: '下发策略', fnCode: 'strategy', type: 'text', icon: 'el-icon-sort-down', hasPermi: 'disRevenue:resource:monitorStategy:strategy'}, {content: '下发策略', fnCode: 'strategy', type: 'text', icon: 'el-icon-sort-down', hasPermi: 'disRevenue:resource:monitorStategy:strategy'},
{content: '删除', fnCode: 'delete', type: 'text', icon: 'el-icon-delete', hasPermi: 'disRevenue:resource:monitorStategy:detele'}, {content: '删除', fnCode: 'delete', type: 'text', icon: 'el-icon-delete', hasPermi: 'disRevenue:resource:monitorStategy:detele'},
] ]
@@ -102,7 +102,7 @@
/** 查询列表 */ /** 查询列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listMonitorTemp(this.queryParams).then(response => { listPolicy(this.queryParams).then(response => {
this.tableList = response.rows; this.tableList = response.rows;
this.queryParams.total = response.total; this.queryParams.total = response.total;
this.loading = false; this.loading = false;
@@ -145,7 +145,8 @@
this.$router.push({ this.$router.push({
path:'/disRevenue/resource/serverScript/view', path:'/disRevenue/resource/serverScript/view',
query:{ query:{
id: rowData.id id: rowData.id,
readonly: true
} }
}); });
break; break;
@@ -157,7 +158,7 @@
delList = selectChange; delList = selectChange;
} }
this.$modal.confirm('是否确认删除该数据?').then(function() { this.$modal.confirm('是否确认删除该数据?').then(function() {
return delMonitorTemp(delList) return delPolicy(delList)
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功") this.$modal.msgSuccess("删除成功")
@@ -172,7 +173,7 @@
// }); // });
// this.download("/system/monitorStategy/export", {properties: dataList,}, `拓扑管理_${new Date().getTime()}.xlsx`); // this.download("/system/monitorStategy/export", {properties: dataList,}, `拓扑管理_${new Date().getTime()}.xlsx`);
let paramsList = Object.assign({}, this.queryParams,rowData); let paramsList = Object.assign({}, this.queryParams,rowData);
this.download("system/serverScript/export", paramsList, `资源监控策略_${new Date().getTime()}.xlsx`, null, 'json'); this.download("rocketmq/policy/export", paramsList, `服务器脚本策略_${new Date().getTime()}.xlsx`, null, 'json');
break; break;
default: default:
} }

View File

@@ -14,15 +14,11 @@
</div> </div>
<!-- active:2 --> <!-- active:2 -->
<div v-show="active === 1"> <div v-show="active === 1">
<Form v-for="item of formListTow" ref="formTowRef" :formList="[item]" :ruleFormData="item.ruleFormData" :config="item.config" @fnClick="callback"> <DynamicForm ref="dyncForm" :formData="ruleFormDataTow"></DynamicForm>
<template v-slot:btnType="scope">
<el-button type="primary" @click="btnClick(scope)">{{scope.field.btnName}}</el-button>
</template>
</Form>
</div> </div>
<!-- active:3 --> <!-- active:3 -->
<div v-show="active === 2"> <div v-show="active === 2">
<!-- <MonitorStategyView :ruleForm="ruleFormData" :otherList="synthesisList"></MonitorStategyView>--> <DynamicForm :formData="ruleFormDataTow" :readonly="true"></DynamicForm>
</div> </div>
</div> </div>
</div> </div>
@@ -36,10 +32,11 @@
<script setup> <script setup>
import Form from '@/components/form/index.vue'; import Form from '@/components/form/index.vue';
import TableList from "@/components/table/index.vue" import TableList from "@/components/table/index.vue"
// import MonitorStategyView from './view' import DynamicForm from './dynamicForm'
import {getPolicy, addPolicy, updatePolicy, getResMonitorGroup, resNameList} from "@/api/disRevenue/resource"
export default { export default {
name: 'ServerScriptDetails', name: 'ServerScriptDetails',
components: {Form, TableList}, components: {Form, TableList, DynamicForm},
data() { data() {
return { return {
active: 0, active: 0,
@@ -51,83 +48,74 @@
config: { config: {
buttonGroup: [] buttonGroup: []
}, },
formList: [{ formList: [],
config: {title: '', colSpan: 'disBlock m0Auto'},
controls: {
id: {label: 'ID',hidden: true},
switchName: {label: '策略名称', span: 12, type: 'input', rules: [{required: true, message: '请输入模版名称', trigger: 'blur'}]},
serverPort: {label: '描述', span: 12, type: 'textarea'},
monitorTemp: {label: '关联资源组', span: 12, type: 'select'},
resourceGroup: {label: '包含设备', span: 12, type: 'select', multiple: true}
}
}],
// 第二节点 1栏 // 第二节点 1栏
formListTow: [],
ruleFormDataTow: {}, ruleFormDataTow: {},
addNum: 0 groupFormList: {},
includedDevicesList: {}
} }
}, },
created() { created() {
this.paramsData = this.$route && this.$route.query;
// console.log('paramsData===',this.paramsData);
if (this.paramsData && this.paramsData.id) {
this.getFormDataList(this.paramsData.id);
}
this.formRender(); this.formRender();
this.fnResMonitorGroup();
this.getResNameList();
}, },
methods: { methods: {
formRender(){ formRender(){
this.formListTow = [ this.formList = [{
{ config: {title: '', colSpan: 'disBlock m0Auto'},
config: {title: '', key: Math.floor(Math.random() * 9000),buttonGroup: []}, controls: {
controls: { id: {label: 'ID',hidden: true},
id: {label: 'ID',hidden: true}, policyName: {label: '策略名称', span: 12, type: 'input', rules: [{required: true, message: '请输入模版名称', trigger: 'blur'}]},
localAddress: {label: '源文件1地址格式', span: 12, type: 'radio', required: true, description: {label: '描述', span: 12, type: 'textarea'},
warningTitle: '注意当文件大小超过100M时请选择【外网HTTP(S)】地址格式', resourceGroupId: {label: '关联资源组', span: 12, type: 'select', options:[]},
options: [{value: '1', label: '平台文件地址'}, {value: '2', label: '外网HTTP(s)'}]}, includedDevicesId: {label: '包含设备', span: 12, type: 'select', options:[], multiple: true}
btn: {label: '', span: 12, slotName: 'btnType', btnName: '添加', btnType: 'add'},
serverPort: {label: '源文件1地址', span: 12, type: 'select'}
},
ruleFormData: {
id: '',
localAddress: '',
serverPort: ''
}
},{
config: {title: '', key: Math.floor(Math.random() * 9000),buttonGroup: []},
controls: {
id: {label: 'ID',hidden: true},
fileAddress: {label: '目标目录', span: 12, type: 'input'},
},
ruleFormData: {
id: '',
fileAddress: ''
}
},{
config: {title: '', key: Math.floor(Math.random() * 9000),buttonGroup: []},
controls: {
id: {label: 'ID',hidden: true},
content: {label: '命令内容1', span: 24, type: 'input'},
// btn: {label: '添加', span: 12, type: 'btn'},
},
ruleFormData: {
id: '',
content: ''
}
},
{
config: {title: '', key: Math.floor(Math.random() * 9000),buttonGroup: []},
controls: {
id: {label: 'ID',hidden: true},
type: {label: '执行方式', span: 24, type: 'select'},
date: {label: '定时时间', span: 12, type: 'date'},
time: {label: '', span: 12, type: 'time'},
},
ruleFormData: {
id: '',
type: '',
date: '',
time: ''
}
} }
]; }];
},
// 资源组
fnResMonitorGroup(){
getResMonitorGroup().then(res => {
if (res && res.data) {
this.formList[0].controls['resourceGroupId']['options']= res && res.data.map(item => {
return Object.assign({label: item.groupName, value: item.id});
});
}
});
},
getResNameList() {
resNameList().then(val => {
if (val) {
this.formList[0].controls['includedDevicesId']['options']= val && val.map(item => {
this.includedDevicesList[item.id] = item;
return Object.assign({label: item.resourceName, value: item.id});
});
}
}).catch(() => {
this.$modal.msgError("操作失败")
});
},
// 获取详情
getFormDataList(id) {
getPolicy(id).then(val => {
// console.log('val==',val);
if (val && val.data) {
val.data.includedDevicesId = val.data.includedDevicesId.split(',').map(id => Number(id));
this.ruleFormData = val.data;
// this.resourceType = val.data.resourceType;
// this.tempContent[val.data.resourceType] = val.data[val.data.resourceType];
}
}).catch(() => {
// this.$modal.msgError("操作失败")
});
}, },
async next(num) { async next(num) {
// console.log('num==',num, 'active==',this.active);
if (num === '-1') { if (num === '-1') {
this.active--; this.active--;
} else { } else {
@@ -136,6 +124,9 @@
return; return;
} }
} }
if (this.active === 1) {
this.formDataTow();
}
this.active++; this.active++;
} }
}, },
@@ -147,6 +138,14 @@
// 3. 操作form如验证 // 3. 操作form如验证
formValid.validate((valid) => { formValid.validate((valid) => {
if (valid) { if (valid) {
formValid.model['includedDevicesName'] = [];
if (formValid.model && formValid.model.includedDevicesId && formValid.model.includedDevicesId.length > 0) {
formValid.model.includedDevicesId.forEach(item => {
formValid.model['includedDevicesName'].push(this.includedDevicesList[item].resourceName);
});
}
formValid.model['includedDevicesId'] = formValid.model['includedDevicesId'].join();
formValid.model['includedDevicesName'] = formValid.model['includedDevicesName'].join();
this.ruleFormData = formValid.model; this.ruleFormData = formValid.model;
resolve(true); resolve(true);
} else { } else {
@@ -155,48 +154,55 @@
}); });
}); });
}, },
// 插槽按钮操作 // 第二节点下的form值
btnClick(row){ formDataTow() {
const { field } = row; let newFormVal = {commandContent: [], sourceFilePath: [], sourceFilePathType: []};
// 找到当前点击项在 formListTow 中的索引 this.$refs.dyncForm.submitForm().then(formData => {
const currentIndex = this.formListTow.findIndex( this.ruleFormDataTow = formData;
item => item.config.key === field.parentKey // 需在子组件传递当前项的key newFormVal['sourceFilePath'].push(formData.sourceFilePath);
); newFormVal['sourceFilePathType'].push(formData.sourceFilePathType);
console.log('field===',field,'currentIndex===',currentIndex); if (formData && formData.commands && formData.commands.length > 0) {
if (field.btnType === 'add') { formData.commands.forEach(item => {
this.addNum++; newFormVal['commandContent'].push(item.commandContent);
const newKey = Math.floor(Math.random() * 9000); });
let slotForm = { }
config: {title: '', key: newKey,buttonGroup: []}, if (formData && formData.sources && formData.sources.length > 0) {
index: this.addNum, formData.sources.forEach(item => {
controls: { newFormVal['sourceFilePath'].push(item.sourceFilePath);
id: {label: 'ID',hidden: true}, newFormVal['sourceFilePathType'].push(item.sourceFilePathType);
localAddress: {label: `源文件${currentIndex + 1 + this.addNum}地址格式`, span: 12, type: 'radio', required: true, });
warningTitle: '注意当文件大小超过100M时请选择【外网HTTP(S)】地址格式', options: [{value: '1', label: '平台文件地址'}, {value: '2', label: '外网HTTP(s)'}]}, }
btn: {label: '', span: 12, slotName: 'btnType', btnName: '删除', btnType: 'delete', parentKey: newKey}, newFormVal['sourceFilePath'] = newFormVal['sourceFilePath'].join();
serverPort: {label: `源文件${currentIndex + 1 + this.addNum}地址`, span: 12, type: 'input'} newFormVal['sourceFilePathType'] = newFormVal['sourceFilePathType'].join();
}, newFormVal['commandContent'] = newFormVal['commandContent'].join();
ruleFormData: { this.groupFormList = Object.assign({},formData, newFormVal);
localAddress: '', // console.log('vvvv=====',formData,'newFormVal====',this.groupFormList);
serverPort: '' }).catch(error => {
} // 处理验证失败的情况
}; console.error('表单提交失败:', error);
this.formListTow.splice(currentIndex + 1 + this.addNum, 0, slotForm); });
} else if (row && row.field.btnType === 'delete'){
// this.addNum--;
this.formListTow = this.formListTow.filter(
item => item.config.key !== field.parentKey
);
}
}, },
// 提交 // 提交
submit() { submit() {
console.log('ruleFormData==',this.ruleFormData); let params = Object.assign({}, this.ruleFormData, this.groupFormList);
console.log('synthesisList==',this.synthesisList); // console.log('params==',params);
// return;
let fnType = addPolicy;
if (this.paramsData && this.paramsData.id) {
fnType = updatePolicy;
}
this.$modal.loading();
fnType(params).then(response => {
this.$modal.msgSuccess(response.msg);
this.$router.push("/resource/serverScript");
this.$modal.closeLoading();
}).catch(error => {
this.$modal.closeLoading();
});
}, },
// 返回 // 返回
goBack() { goBack() {
this.$router.push({path:'/resource/monitorStategy'}); this.$router.push({path:'/resource/serverScript'});
}, },
// 监听事件 // 监听事件
callback(result, dataVal, formVal) { callback(result, dataVal, formVal) {