Browse Source

告警测试版

pull/1/head
ljlong_2630 1 year ago
parent
commit
17792a477f
  1. 53
      src/api/model/alertmodel.js
  2. 8
      src/api/model/device.js
  3. 8
      src/api/model/params.js
  4. 55
      src/api/model/policy.js
  5. 2
      src/views/model/alert/addalertconfig.vue
  6. 456
      src/views/model/alert/deviceparamalert.vue
  7. 382
      src/views/model/alert/model.vue
  8. 149
      src/views/model/alert/policy.vue

53
src/api/model/alertmodel.js

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询告警模版列表
export function listModel(query) {
return request({
url: '/model/dcBusiAlertModel/list',
method: 'get',
params: query
})
}
// 查询告警模版详细
export function getModel(id) {
return request({
url: '/model/dcBusiAlertModel/' + id,
method: 'get'
})
}
// 新增告警模版
export function addModel(data) {
return request({
url: '/model/dcBusiAlertModel',
method: 'post',
data: data
})
}
// 修改告警模版
export function updateModel(data) {
return request({
url: '/model/dcBusiAlertModel',
method: 'put',
data: data
})
}
// 删除告警模版
export function delModel(id) {
return request({
url: '/model/dcBusiAlertModel/' + id,
method: 'delete'
})
}
// 导出告警模版
export function exportModel(query) {
return request({
url: '/${baseUrl}/export',
method: 'get',
params: query
})
}

8
src/api/model/device.js

@ -8,6 +8,14 @@ export function listDevice(query) {
params: query
})
}
// 查询设备信息列表无分页
export function listDeviceNoPage(query) {
return request({
url: '/model/dcBaseDeviceinfo/listNoPage',
method: 'get',
params: query
})
}
// 查询设备信息详细
export function getDevice(id) {

8
src/api/model/params.js

@ -8,6 +8,14 @@ export function listParams(query) {
params: query
})
}
// 查询设备参数明细列表不分页
export function listParamsNoPage(query) {
return request({
url: '/model/dcBaseDeviceParam/listNoPage',
method: 'get',
params: query
})
}
// 查询设备参数明细详细
export function getParams(id) {

55
src/api/model/policy.js

@ -50,4 +50,59 @@ export function exportPolicy(query) {
method: 'get',
params: query
})
}
// 导出参数值状态策略
export function selectDeviceParamPolicy(query) {
return request({
url: '/model/dcBusiAlertParamPolicy/selectDeviceParamPolicy',
method: 'post',
params: query
})
}
// 批量新增参数值状态策略
export function addPolicyBatch(data) {
return request({
url: '/model/dcBusiAlertParamPolicy/addBatch',
method: 'post',
data: data
})
}
// 批量查询参数值状态策略列表
export function listPolicyNoPage(query) {
return request({
url: '/model/dcBusiAlertParamPolicy/listNoPage',
method: 'get',
params: query
})
}
// 批量修改参数值状态策略
export function updatePolicyBatch(data) {
return request({
url: '/model/dcBusiAlertParamPolicy/batchUpdate',
method: 'put',
data: data
})
}
// 查询参数值状态策略信息列表
export function listPolicyInfo(data) {
return request({
url: '/model/dcBusiAlertParamPolicy/listInfo',
method: 'post',
data: data
})
}
// 删除参数值状态策略
export function newDelPolicy(ids) {
return request({
url: '/model/dcBusiAlertParamPolicy/newBatchRemove/' + ids,
method: 'delete'
})
}

2
src/views/model/alert/addalertconfig.vue

@ -63,7 +63,7 @@ import { required } from "@vee-validate/rules";
import noalertdevices from "./noalertdevices";
import noalertparams from "./noalertparams";
import { onMounted } from "vue";
import { ElMessage, ElMessageBox } from 'element-plus'
import { ElMessage, ElMessageBox } from 'element-plus';
const { proxy } = getCurrentInstance();
const {dc_class_type, dc_device_partion, dc_model_type} = proxy.useDict('dc_class_type', 'dc_device_partion','dc_model_type');
const router = useRouter();

456
src/views/model/alert/deviceparamalert.vue

@ -77,14 +77,18 @@
<!-- <el-table-column label="主键" align="center" prop="id" /> -->
<el-table-column label="中台设备ID" align="center" prop="deviceUuid" />
<el-table-column label="设备名称" align="center" prop="deviceName" :width="120"/>
<el-table-column label="通讯来源类型" align="center" prop="deviceSource" :width="120"/>
<el-table-column label="参数名称" align="center" prop="paramName" :width="120"/>
<el-table-column label="参数类型" align="center" prop="paramType" :width="120">
<template #default="scope">
<dict-tag :options="dc_param_value_type" :value="scope.row.paramType"/>
</template>
</el-table-column>
<el-table-column label="参数编码" align="center" prop="paramCode" />
<el-table-column label="是否可用" align="center" prop="enabledFlag" :width="120">
<template #default="scope">
<dict-tag :options="enabledFlagTable" :value="scope.row.enabledFlag"/>
</template>
</el-table-column>
<el-table-column label="参数编码" align="center" prop="paramCode" />
<el-table-column label="参数名称" align="center" prop="paramName" :width="120"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<!-- <el-button
@ -119,8 +123,8 @@
<el-form ref="alertRef" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
<el-form-item label="中台设备" prop="deviceUuid">
<el-select v-model="form.deviceUuid" placeholder="请选择中台设备" @change="getParamsList" clearable>
<el-form-item label="告警设备" prop="deviceUuid">
<el-select v-model="form.deviceUuid" filterable placeholder="请选择参数" clearable @change="getParamsList">
<el-option
v-for="item in deviceList"
:key="item.uuid"
@ -131,8 +135,8 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="参数" prop="paramCode">
<el-select v-model="form.paramCode" placeholder="请选择参数" clearable>
<el-form-item label="告警参数" prop="paramCode">
<el-select v-model="form.paramCode" filterable placeholder="请选择参数" clearable>
<el-option
v-for="item in paramsList"
:key="item.paramCode"
@ -155,16 +159,11 @@
<el-dialog :title="titlePolicy" v-model="openPolicy" width="800px" append-to-body>
<el-form ref="policyRef" :model="formPolicy" :rules="rulesPolicy" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="开始值" prop="beginValue">
<el-col :span="12" v-show="beginValueVisiable">
<el-form-item label="告警值" prop="beginValue">
<el-input v-model="formPolicy.beginValue" placeholder="请输入开始值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束值" prop="endValue">
<el-input v-model="formPolicy.endValue" placeholder="请输入结束值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否告警" prop="alertFlag">
<el-select v-model="formPolicy.alertFlag" placeholder="请选择是否告警">
@ -177,17 +176,29 @@
</el-select>
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="策略ID" prop="alertId" hidden>
<el-input v-model="formPolicy.alertId" placeholder="请输入策略ID" />
<el-col :span="12" v-show="methodIdVisiable">
<el-form-item label="告警方式" prop="methodId">
<el-select v-model="formPolicy.methodId" placeholder="请选择告警方式">
<el-option
v-for="item in methodList"
:key="item.id"
:label="item.methodName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-show="sortIdVisiable">
<el-form-item label="排序" prop="sortId">
<el-input-number v-model="formPolicy.sortId" :min="1" :max="1000" />
</el-form-item>
</el-col> -->
<el-col :span="12">
</el-col>
<el-col :span="12" v-show="statusValueVisiable">
<el-form-item label="状态值" prop="statusValue">
<el-input v-model="formPolicy.statusValue" placeholder="请输入状态值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col :span="12" v-show="statusTypeVisiable">
<el-form-item label="状态类型" prop="statusType">
<el-select v-model="formPolicy.statusType" placeholder="请选择状态类型">
<el-option
@ -199,26 +210,32 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="中台设备ID" prop="deviceId">
<el-input v-model="formPolicy.deviceId" placeholder="请输入中台设备ID" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序" prop="sortId">
<el-input-number v-model="formPolicy.sortId" :min="1" :max="1000" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="告警方式ID" prop="methodId">
<el-select v-model="formPolicy.methodId" placeholder="请选择告警方式ID">
<el-option
v-for="item in methodList"
:key="item.id"
:label="item.methodName"
:value="item.id"
/>
</el-select>
<el-col :span="24" v-show="policyModelVisiable">
<el-form-item label="告警算法" prop="policyModel">
<el-table ref="policyTable" v-loading="loading" :data="modelList" :row-key="getRowKey">
<el-table-column type="selection" reserve-selection="true" width="55" align="center" />
<el-table-column label="名称" align="center" prop="name">
<template #default="scope">
<el-input v-model="scope.row.name"></el-input>
</template>
</el-table-column>
<el-table-column label="符号" align="center" prop="code" :width="120"/>
<el-table-column label="运算符" align="center" prop="operator" :width="120">
<template #default="scope">
<dict-tag :options="operator_sign" :value="scope.row.operator"/>
</template>
</el-table-column>
<el-table-column label="限值" align="center" prop="value">
<template #default="scope">
<el-input v-model="scope.row.value"></el-input>
</template>
</el-table-column>
<el-table-column label="级别" align="center" prop="level">
<template #default="scope">
<el-input v-model="scope.row.level"></el-input>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-col>
</el-row>
@ -237,12 +254,15 @@
</style>
<script setup name="Alert">
import { getDeviceParamsAlertInfo, listAlert, getAlert, delAlert, addAlert, updateAlert } from "@/api/model/alert";
import { listDevice } from "@/api/model/device";
import { listParams } from "@/api/model/params";
import { listDeviceNoPage } from "@/api/model/device";
import { listParamsNoPage } from "@/api/model/params";
import { listMethod } from "@/api/model/method";
import { listPolicy,updatePolicy,addPolicy } from "@/api/model/policy";
import { listModel } from "@/api/model/alertmodel";
import { ElMessageBox } from 'element-plus';
import { listPolicy,listPolicyInfo,updatePolicy,updatePolicyBatch,addPolicy,addPolicyBatch,newDelPolicy } from "@/api/model/policy";
const { proxy } = getCurrentInstance();
const router = useRouter();
const { operator_sign,dc_param_value_type } = proxy.useDict('operator_sign','dc_param_value_type');
const alertList = ref([]);
const open = ref(false);
const openPolicy = ref(false);
@ -256,17 +276,33 @@ const title = ref("");
const deviceList = ref([]);
const paramsList = ref([]);
const methodList = ref([]);
const modelList = ref([]);
const selectedRows = ref([]);
const deletePolicyRows = ref([]);
const oldPolicyRows = ref([]);
const addPolicyRows = ref([]);
const policyParamsUpdateAdd = ref([]);
const beginValueVisiable = ref(false);
const statusValueVisiable = ref(false);
const statusTypeVisiable = ref(false);
const sortIdVisiable = ref(false);
const methodIdVisiable = ref(false);
const policyModelVisiable = ref(false);
const policyParams = ref([]);
const policyAlertId = ref("");
const policyDeviceUuid = ref("");
const paramTypeValue = ref("");
const enabledFlagTable = ref([
{label: '可用', value: 'true', elTagType: 'default', elTagClass: null},
{label: '不可用', value: 'false', elTagType: 'default', elTagClass: null}
]);
const alertFlag = ref([
{label: '告警', value: true, elTagType: 'default', elTagClass: null},
{label: '不告警', value: false, elTagType: 'default', elTagClass: null}
{label: '告警', value: '1', elTagType: 'default', elTagClass: null},
{label: '不告警', value: '0', elTagType: 'default', elTagClass: null}
]);
const status = ref([
{label: '状态1', value: 1, elTagType: 'default', elTagClass: null},
{label: '状态2', value: 2, elTagType: 'default', elTagClass: null}
{label: '状态1', value: '1', elTagType: 'default', elTagClass: null},
{label: '状态2', value: '2', elTagType: 'default', elTagClass: null}
]);
const data = reactive({
form: {},
@ -278,6 +314,13 @@ const data = reactive({
paramCode: null,
note: null
},
queryParamsDevice: {
deviceUuid: null,
},
queryParamsParam: {
deviceUuid: null,
paramCode: null,
},
queryParamsPolicy:{
pageNum: 1,
pageSize: 10,
@ -291,6 +334,9 @@ const data = reactive({
sortId: null,
methodId: null
},
queryPolicy:{
alertId: null,
},
rules: {
deviceUuid: [
{ required: true, message: "中台设备UUID不能为空", trigger: "blur" }
@ -309,7 +355,7 @@ const data = reactive({
}
});
const { queryParams, form, rules,queryParamsPolicy, formPolicy, rulesPolicy } = toRefs(data);
const { queryParamsDevice, queryParamsParam, queryParams, form, rules,queryParamsPolicy,queryPolicy, formPolicy, rulesPolicy } = toRefs(data);
/** 查询设备告警列表 */
function getList() {
@ -402,40 +448,35 @@ function handleAdd() {
title.value = "添加设备告警";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getAlert(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改设备告警";
});
}
/** 维护告警策略 */
function handlePolicy(row) {
resetPolicy();
selectedRows.value=[];
deletePolicyRows.value=[];
if(row.paramType==4){
getModelListSwitch(row);
beginValueVisiable.value=true;
policyModelVisiable.value=false;
statusValueVisiable.value=false;
statusTypeVisiable.value=false;
sortIdVisiable.value=false;
methodIdVisiable.value=true;
}else{
getModelList(row);
policyModelVisiable.value=true;
beginValueVisiable.value=false;
statusValueVisiable.value=true;
statusTypeVisiable.value=true;
sortIdVisiable.value=false;
methodIdVisiable.value=true;
}
getMethodList();
queryParamsPolicy.value.alertId = row.id;
listPolicy(queryParamsPolicy.value).then(response => {
if(response.total != 0){
formPolicy.value = response.rows[0];
}else{
formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid;
}
openPolicy.value = true;
title.value = "维护告警策略";
});
// router.push({
// path:'policy',
// query:{
// id:row.id,
// deviceUuid:row.deviceUuid,
// paramCode:row.paramCode
// }
// })
policyAlertId.value = row.id;
policyDeviceUuid.value = row.deviceUuid;
paramTypeValue.value = row.paramType;
openPolicy.value = true;
title.value = "维护告警策略";
}
/** 提交按钮 */
@ -478,18 +519,18 @@ function handleExport() {
}
function getDeviceList(){
listDevice(queryParams.value).then(response => {
deviceList.value = response.rows;
total.value = response.total;
loading.value = false;
listDeviceNoPage(queryParamsDevice.value).then(response => {
deviceList.value = response.data;
loading.value = false;
});
}
function getParamsList(deviceUuid){
queryParams.value.deviceUuid = deviceUuid;
listParams(queryParams.value).then(response => {
paramsList.value = response.rows;
total.value = response.total;
loading.value = true;
queryParamsParam.value.deviceUuid = deviceUuid;
listParamsNoPage(queryParamsParam.value).then(response => {
paramsList.value = response.data;
loading.value = false;
});
}
@ -500,21 +541,65 @@ function getMethodList(){
});
}
//
function submitFormPolicy() {
proxy.$refs["policyRef"].validate(valid => {
if (valid) {
//
if (formPolicy.value.id != null) {
updatePolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
//
if(paramTypeValue.value != 4 ){
if(proxy.$refs.policyTable.getSelectionRows().length==0){
ElMessageBox.alert('请确保至少勾选了一条告警算法', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
}
mapFormTableUpdate();
computeDelPolicy();
computeAddPolicy();
updatePolicyBatch(policyParams.value).then(response => {
if(deletePolicyRows.value.length>0){
newHandleDeletePolicy();
}
if(addPolicyRows.value.length>0){
handleAddPolicy();
}
proxy.$modal.msgSuccess("修改成功");
openPolicy.value = false;
getList();
});
}else{
addPolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
getList();
});
}
} else {
addPolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
//
if(paramTypeValue.value != 4 ){
if(proxy.$refs.policyTable.getSelectionRows().length==0){
ElMessageBox.alert('请确保至少勾选了一条告警算法', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
}
mapFormTable();
addPolicyBatch(policyParams.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
getList();
});
}else{
addPolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
getList();
});
}
}
}
});
@ -525,6 +610,189 @@ function cancelPolicy() {
resetPolicy();
}
//
function getModelListSwitch(row){
queryPolicy.value.alertId = row.id;
listPolicyInfo(queryPolicy.value).then(response=>{
//
if(response.data && response.data.length>0){
formPolicy.value.statusValue = response.data[0].statusValue;
formPolicy.value.statusType = response.data[0].statusType;
formPolicy.value.methodId = response.data[0].methodId;
formPolicy.value.alertFlag = response.data[0].alertFlag;
formPolicy.value.value = response.data[0].beginValue;
formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid;
formPolicy.value.id = 1;
//
}else{
formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid;
}
});
}
//
function getModelList(row){
queryPolicy.value.alertId = row.id;
listModel().then(response => {
modelList.value = response.rows;
formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid;
proxy.$refs.policyTable.clearSelection();
console.log(queryPolicy.value);
listPolicyInfo(queryPolicy.value).then(response=>{
//
if(response.data && response.data.length>0){
console.log(response.data);
oldPolicyRows.value = response.data;
formPolicy.value.statusValue = response.data[0].statusValue;
formPolicy.value.statusType = response.data[0].statusType;
formPolicy.value.methodId = response.data[0].methodId;
formPolicy.value.alertFlag = response.data[0].alertFlag;
formPolicy.value.alertId = response.data[0].alertId;
formPolicy.value.deviceId = response.data[0].deviceId;
formPolicy.value.id = 1;
modelList.value.map(element=>{
response.data.forEach(item=>{
if(item.alertModelId == element.id){
policyDeviceUuid.value = item.deviceId;
policyAlertId.value = item.alertId;
element.value = item.beginValue;
element.level = item.sortId;
element.name = item.name;
element.id = item.id;
proxy.$refs.policyTable.toggleRowSelection(element,true);
return element;
}
})
})
}
});
});
}
//
function mapFormTable(){
const policyTableRows = proxy.$refs.policyTable.getSelectionRows();
policyParams.value=[];
policyTableRows.forEach(item=>{
let policyParam = {};
policyParam.statusValue = formPolicy.value.statusValue;
policyParam.statusType = formPolicy.value.statusType;
policyParam.methodId = formPolicy.value.methodId;
policyParam.alertFlag = formPolicy.value.alertFlag;
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = policyAlertId.value;
policyParam.beginValue = item.value;
policyParam.sortId = item.level;
policyParam.alertModelId = item.id;
policyParam.name = item.name;
policyParams.value.push(policyParam);
})
}
//
function mapFormTableUpdate(){
const policyTableRows = proxy.$refs.policyTable.getSelectionRows();
policyParams.value=[];
policyTableRows.forEach(item=>{
let policyParam = {};
policyParam.id = item.id;
policyParam.statusValue = formPolicy.value.statusValue;
policyParam.statusType = formPolicy.value.statusType;
policyParam.methodId = formPolicy.value.methodId;
policyParam.alertFlag = formPolicy.value.alertFlag;
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = item.alertId;
policyParam.beginValue = item.value;
policyParam.sortId = item.level;
policyParam.alertModelId = item.alertModelId;
policyParam.name = item.name;
policyParams.value.push(policyParam);
})
}
function getRowKey(row){
//
// 使 id
return row.id;
}
/** 删除按钮操作 */
function newHandleDeletePolicy(){
const _names = deletePolicyRows.value.map(item=>{
return item.name;
});
const _ids = deletePolicyRows.value.map(item=>{
return item.id;
});
proxy.$modal.confirm('是否确认删除告警算法"' + _names + '"的数据项?').then(function() {
return newDelPolicy(_ids);
}).then(() => {
}).catch(() => {});
}
function computeDelPolicy() {
const newSeletedRows = proxy.$refs.policyTable.getSelectionRows();
oldPolicyRows.value.forEach(item=>{
let flag = false;
newSeletedRows.forEach(element=>{
if(item.id == element.id){
flag = true;
}
})
if(!flag){
deletePolicyRows.value.push(item);
}
})
}
function computeAddPolicy() {
const newSeletedRows = proxy.$refs.policyTable.getSelectionRows();
newSeletedRows.forEach(item=>{
let flag = false;
oldPolicyRows.value.forEach(element=>{
if(item.id == element.id){
flag = true;
}
})
if(!flag){
addPolicyRows.value.push(item);
}
})
}
/** 新增方法 */
function handleAddPolicy(){
mapFormTableUpdataAdd();
addPolicyBatch(policyParamsUpdateAdd.value);
}
//
function mapFormTableUpdataAdd(){
policyParamsUpdateAdd.value=[];
addPolicyRows.value.forEach(item=>{
let policyParam = {};
policyParam.statusValue = formPolicy.value.statusValue;
policyParam.statusType = formPolicy.value.statusType;
policyParam.methodId = formPolicy.value.methodId;
policyParam.alertFlag = formPolicy.value.alertFlag;
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = policyAlertId.value;
policyParam.beginValue = item.value;
policyParam.sortId = item.level;
policyParam.alertModelId = item.id;
policyParam.name = item.name;
policyParamsUpdateAdd.value.push(policyParam);
})
}
getList();
</script>

382
src/views/model/alert/model.vue

@ -0,0 +1,382 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="参数据类型" prop="paramType">
<el-select v-model="queryParams.paramType" placeholder="请选择参数据类型" clearable>
<el-option
v-for="dict in dc_param_value_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="代码" prop="code">
<el-input
v-model="queryParams.code"
placeholder="请输入代码"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="是否有效" prop="flagEnabled">
<el-select v-model="queryParams.flagEnabled" placeholder="请选择是否有效" clearable>
<el-option
v-for="dict in flagEnabled"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="级别" prop="level">
<el-input
v-model="queryParams.level"
placeholder="请输入级别"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="运算符" prop="operator">
<el-select v-model="queryParams.operator" placeholder="请选择运算符" clearable>
<el-option
v-for="dict in operator_sign"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="值" prop="value">
<el-input
v-model="queryParams.value"
placeholder="请输入值"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item class="childTextAlignCenter">
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="success"
icon="Plus"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="Edit"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="Delete"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="Download"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="modelList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<el-table-column label="参数据类型" align="center" prop="paramType" >
<template #default="scope">
<dict-tag :options="dc_param_value_type" :value="scope.row.paramType"/>
</template>
</el-table-column>
<el-table-column label="代码" align="center" prop="code" />
<el-table-column label="是否有效" align="center" prop="flagEnabled" >
<template #default="scope">
<dict-tag :options="flagEnabledTable" :value="scope.row.flagEnabled"/>
</template>
</el-table-column>
<el-table-column label="级别" align="center" prop="level" />
<el-table-column label="运算符" align="center" prop="operator" >
<template #default="scope">
<dict-tag :options="operator_sign" :value="scope.row.operator"/>
</template>
</el-table-column>
<el-table-column label="名称" align="center" prop="name" />
<el-table-column label="值" align="center" prop="value" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button
type="text"
icon="Edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
type="text"
icon="Delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改告警模版对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="modelRef" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="参数据类型" prop="paramType">
<el-select v-model="form.paramType" placeholder="请选择参数据类型">
<el-option
v-for="dict in dc_param_value_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="代码" prop="code">
<el-input v-model="form.code" placeholder="请输入代码" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否有效" prop="flagEnabled">
<el-select v-model="form.flagEnabled" placeholder="请选择是否有效">
<el-option
v-for="dict in flagEnabled"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="级别" prop="level">
<el-input v-model="form.level" placeholder="请输入级别" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="运算符" prop="operator">
<el-select v-model="form.operator" placeholder="请选择运算符">
<el-option
v-for="dict in operator_sign"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="值" prop="value">
<el-input v-model="form.value" placeholder="请输入值" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<style lang="scss" >
@import "@/assets/styles/self-defined.scss";
</style>
<script setup name="Model">
import { listModel, getModel, delModel, addModel, updateModel } from "@/api/model/alertmodel";
const { proxy } = getCurrentInstance();
const { dc_param_value_type,operator_sign } = proxy.useDict('dc_param_value_type','operator_sign');
const modelList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const flagEnabled = ref([
{label: '有效', value: 1, elTagType: 'default', elTagClass: null},
{label: '无效', value: 0, elTagType: 'default', elTagClass: null}
]);
const flagEnabledTable = ref([
{label: '有效', value: '1', elTagType: 'default', elTagClass: null},
{label: '无效', value: '0', elTagType: 'default', elTagClass: null}
]);
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
paramType: null,
code: null,
flagEnabled: null,
level: null,
operator: null,
name: null,
value: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询告警模版列表 */
function getList() {
loading.value = true;
listModel(queryParams.value).then(response => {
modelList.value = response.rows;
total.value = response.total;
loading.value = false;
});
}
//
function cancel() {
open.value = false;
reset();
}
//
function reset() {
form.value = {
tentantId: null,
version: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
deptId: null,
userId: null,
deleteBy: null,
deleteTime: null,
id: null,
paramType: null,
code: null,
flagEnabled: null,
level: null,
operator: null,
name: null,
value: null
};
proxy.resetForm("modelRef");
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm("queryRef");
handleQuery();
}
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加告警模版";
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getModel(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改告警模版";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["modelRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateModel(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addModel(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
getList();
});
}
}
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除告警模版编号为"' + _ids + '"的数据项?').then(function() {
return delModel(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('model/model/export', {
...queryParams.value
}, `model_${new Date().getTime()}.xlsx`)
}
getList();
</script>

149
src/views/model/alert/policy.vue

@ -76,27 +76,6 @@
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="success"
icon="Plus"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="Edit"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="Delete"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
@ -110,20 +89,31 @@
<el-table v-loading="loading" :data="policyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" />
<el-table-column label="中台设备ID" align="center" prop="deviceUuid" />
<el-table-column label="设备名称" align="center" prop="deviceName" :width="120"/>
<el-table-column label="中台设备ID" align="center" prop="deviceId" />
<el-table-column label="参数名称" align="center" prop="paramName" :width="120"/>
<el-table-column label="参数编码" align="center" prop="paramCode" />
<el-table-column label="参数名称" align="center" prop="paramName" :width="120"/>
<el-table-column label="开始值" align="center" prop="beginValue" />
<el-table-column label="结束值" align="center" prop="endValue" />
<el-table-column label="是否告警" align="center" prop="alertFlag" />
<el-table-column label="控制值" align="center" prop="beginValue" />
<!-- <el-table-column label="结束值" align="center" prop="endValue" /> -->
<el-table-column label="是否告警" align="center" prop="alertFlag" >
<template #default="scope">
<dict-tag :options="alertFlag" :value="scope.row.alertFlag"/>
</template>
</el-table-column>
<el-table-column label="策略ID" align="center" prop="alertId" />
<el-table-column label="状态值" align="center" prop="statusValue" />
<el-table-column label="状态类型" align="center" prop="statusType" />
<el-table-column label="中台设备ID" align="center" prop="deviceId" />
<el-table-column label="状态类型" align="center" prop="statusType" >
<template #default="scope">
<dict-tag :options="statusType" :value="scope.row.statusType"/>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sortId" />
<el-table-column label="告警方式ID" align="center" prop="methodId" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column label="告警方式" align="center" prop="methodId" >
<template #default="scope">
<span>{{ getMethodName(scope.row.methodId) }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button
type="text"
@ -136,7 +126,7 @@
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table-column> -->
</el-table>
<pagination
@ -152,15 +142,10 @@
<el-form ref="policyRef" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="开始值" prop="beginValue">
<el-form-item label="告警值" prop="beginValue">
<el-input v-model="form.beginValue" placeholder="请输入开始值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="结束值" prop="endValue">
<el-input v-model="form.endValue" placeholder="请输入结束值" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否告警" prop="alertFlag">
<el-select v-model="form.alertFlag" placeholder="请选择是否告警">
@ -186,20 +171,15 @@
<el-col :span="12">
<el-form-item label="状态类型" prop="statusType">
<el-select v-model="form.statusType" placeholder="请选择状态类型">
<el-option label="请选择字典生成" value="" />
<el-option
v-for="item in statusType"
:key="item.id"
:label="item.methodName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="中台设备ID" prop="deviceId">
<el-input v-model="form.deviceId" placeholder="请输入中台设备ID" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序" prop="sortId">
<el-input-number v-model="form.sortId" :min="1" :max="1000" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="告警方式ID" prop="methodId">
<el-select v-model="form.methodId" placeholder="请选择告警方式ID">
@ -225,7 +205,7 @@
</template>
<script setup name="Policy">
import { listPolicy, getPolicy, delPolicy, addPolicy, updatePolicy } from "@/api/model/policy";
import { selectDeviceParamPolicy, listPolicy, getPolicy, delPolicy, addPolicy, updatePolicy } from "@/api/model/policy";
import { listMethod } from "@/api/model/method";
const { proxy } = getCurrentInstance();
const router = useRouter();
@ -241,13 +221,13 @@ const title = ref("");
const methodList = ref([]);
const deviceUuid = ref("");
const alertFlag = ref([
{label: '告警', value: true, elTagType: 'default', elTagClass: null},
{label: '不告警', value: false, elTagType: 'default', elTagClass: null}
]);
const alertFlagTable = ref([
{label: '告警', value: 'true', elTagType: 'default', elTagClass: null},
{label: '不告警', value: 'false', elTagType: 'default', elTagClass: null}
]);
const statusType = ref([
{label: '状态1', value: '1', elTagType: 'default', elTagClass: null},
{label: '状态2', value: '2', elTagType: 'default', elTagClass: null}
]);
const data = reactive({
form: {},
queryParams: {
@ -273,7 +253,7 @@ const { queryParams, form, rules } = toRefs(data);
function getList() {
loading.value = true;
queryParams.value.deviceId = deviceUuid;
listPolicy(queryParams.value).then(response => {
selectDeviceParamPolicy(queryParams.value).then(response => {
policyList.value = response.rows;
total.value = response.total;
loading.value = false;
@ -332,23 +312,23 @@ function handleSelectionChange(selection) {
multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
reset();
open.value = true;
title.value = "添加参数值状态策略";
}
// /** */
// function handleAdd() {
// reset();
// open.value = true;
// title.value = "";
// }
/** 修改按钮操作 */
function handleUpdate(row) {
reset();
const _id = row.id || ids.value
getPolicy(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改参数值状态策略";
});
}
// /** */
// function handleUpdate(row) {
// reset();
// const _id = row.id || ids.value
// getPolicy(_id).then(response => {
// form.value = response.data;
// open.value = true;
// title.value = "";
// });
// }
/** 提交按钮 */
function submitForm() {
@ -371,16 +351,16 @@ function submitForm() {
});
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value;
proxy.$modal.confirm('是否确认删除参数值状态策略编号为"' + _ids + '"的数据项?').then(function() {
return delPolicy(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
// /** */
// function handleDelete(row) {
// const _ids = row.id || ids.value;
// proxy.$modal.confirm('"' + _ids + '"').then(function() {
// return delPolicy(_ids);
// }).then(() => {
// getList();
// proxy.$modal.msgSuccess("");
// }).catch(() => {});
// }
/** 导出按钮操作 */
function handleExport() {
@ -400,6 +380,15 @@ function initializeDeviceUuid(){
form.value.alertId = router.currentRoute._value.query.id;
}
function getMethodName(methodId){
let methodNameTable = "";
methodList.value.forEach(item=>{
if(item.id == methodId){
methodNameTable = item.methodName;
};
})
return methodNameTable;
}
initializeDeviceUuid();
getList();

Loading…
Cancel
Save