Browse Source

告警策略配置修改添加级别名称默认值

pull/1/head
ljlong_2630 1 year ago
parent
commit
41e67f13d8
  1. 10
      src/api/model/alertmodel.js
  2. 5
      src/assets/styles/self-defined.scss
  3. 79
      src/views/model/alert/deviceparamalert.vue
  4. 222
      src/views/model/alert/model.vue
  5. 183
      src/views/model/alert/policy.vue

10
src/api/model/alertmodel.js

@ -50,4 +50,14 @@ export function exportModel(query) {
method: 'get', method: 'get',
params: query params: query
}) })
}
// 查询告警模版列表
export function listModelEnabledNoPage(query) {
return request({
url: '/model/dcBusiAlertModel/listEnabledNoPage',
method: 'get',
params: query
})
} }

5
src/assets/styles/self-defined.scss

@ -34,7 +34,7 @@
} }
.textaligncenter{ .textaligncenter{
text-align:center; text-align: center!important;
} }
.textalignleft{ .textalignleft{
text-align:left; text-align:left;
@ -195,4 +195,5 @@
.el-input__wrapper { .el-input__wrapper {
box-shadow: 0 0 0 1px var(--el-color-danger) inset; box-shadow: 0 0 0 1px var(--el-color-danger) inset;
} }
} }

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

@ -185,7 +185,7 @@
</el-col> </el-col>
<el-col :span="12" v-show="methodIdsVisiable"> <el-col :span="12" v-show="methodIdsVisiable">
<el-form-item label="告警方式" prop="methodIds"> <el-form-item label="告警方式" prop="methodIds">
<el-select v-model="formPolicy.methodIds" placeholder="请选择告警方式"> <el-select v-model="formPolicy.methodIds" multiple placeholder="请选择告警方式">
<el-option <el-option
v-for="item in methodList" v-for="item in methodList"
:key="item.id" :key="item.id"
@ -195,6 +195,23 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-show="levelVisiable">
<el-form-item label="级别" prop="level">
<el-select v-model="formPolicy.level" placeholder="请选择告警级别" @change="levelChange">
<el-option
v-for="dict in dc_alert_level"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-show="nameVisiable">
<el-form-item label="名称" prop="name">
<el-input disabled v-model="formPolicy.name" placeholder="请选择告警级别"/>
</el-form-item>
</el-col>
<el-col :span="12" v-show="sortIdVisiable"> <el-col :span="12" v-show="sortIdVisiable">
<el-form-item label="排序" prop="sortId"> <el-form-item label="排序" prop="sortId">
<el-input-number v-model="formPolicy.sortId" :min="1" :max="1000" /> <el-input-number v-model="formPolicy.sortId" :min="1" :max="1000" />
@ -224,6 +241,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row style="margin-bottom: 10px;" v-show="tableVisiable"> <el-row style="margin-bottom: 10px;" v-show="tableVisiable">
<el-col> <el-col>
@ -252,7 +270,7 @@
<el-table-column label="排序" align="center" prop="sort"/> <el-table-column label="排序" align="center" prop="sort"/>
<el-table-column label="告警方式" align="center" prop="methodIds" > <el-table-column label="告警方式" align="center" prop="methodIds" >
<template #default="scope"> <template #default="scope">
<el-form-item :class="{'is-error': isInvalid(scope.row.methodIds,scope.row)}" label-width="0px" > <el-form-item label-width="0px" >
<el-select v-model="scope.row.methodIds" multiple @change="methodIdsChange" placeholder="请选择告警方式"> <el-select v-model="scope.row.methodIds" multiple @change="methodIdsChange" placeholder="请选择告警方式">
<el-option <el-option
v-for="item in methodList" v-for="item in methodList"
@ -309,12 +327,12 @@
import { getDeviceParamsAlertInfo,delAlert, addAlert, updateAlert } from "@/api/model/alert"; import { getDeviceParamsAlertInfo,delAlert, addAlert, updateAlert } from "@/api/model/alert";
import { listDeviceNoPage } from "@/api/model/device"; import { listDeviceNoPage } from "@/api/model/device";
import { listMethod } from "@/api/model/method"; import { listMethod } from "@/api/model/method";
import { listModel } from "@/api/model/alertmodel"; import { listModelEnabledNoPage } from "@/api/model/alertmodel";
import { ElMessageBox } from 'element-plus'; import { ElMessageBox } from 'element-plus';
import {listPolicyInfo,updatePolicy,updatePolicyBatch,addPolicy,addPolicyBatch,listAlertParamSelect } from "@/api/model/policy"; import {listPolicyInfo,updatePolicy,updatePolicyBatch,addPolicy,addPolicyBatch,listAlertParamSelect } from "@/api/model/policy";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const router = useRouter(); const router = useRouter();
const { operator_sign,dc_param_value_type } = proxy.useDict('operator_sign','dc_param_value_type'); const { operator_sign,dc_param_value_type,dc_alert_level } = proxy.useDict('operator_sign','dc_param_value_type','dc_alert_level');
const alertList = ref([]); const alertList = ref([]);
const open = ref(false); const open = ref(false);
const openPolicy = ref(false); const openPolicy = ref(false);
@ -347,6 +365,9 @@ const rowPolicySelected = ref([]);
const colorValue = ref({}); const colorValue = ref({});
const tableVisiable = ref(false); const tableVisiable = ref(false);
const dialogWidth = ref('1600px'); const dialogWidth = ref('1600px');
const queryModel = ref({});
const levelVisiable = ref(false);
const nameVisiable = ref(false);
const alert_value = ref([ const alert_value = ref([
{label: '1', value: true, elTagType: 'default', elTagClass: null}, {label: '1', value: true, elTagType: 'default', elTagClass: null},
{label: '0', value: false, elTagType: 'default', elTagClass: null} {label: '0', value: false, elTagType: 'default', elTagClass: null}
@ -519,7 +540,6 @@ function handlePolicy(row) {
selectedRows.value=[]; selectedRows.value=[];
deletePolicyRows.value=[]; deletePolicyRows.value=[];
addPolicyRows.value=[]; addPolicyRows.value=[];
deletePolicyRows.value=[];
logicCode.value = row.logicCode; logicCode.value = row.logicCode;
formPolicy.value.enabled = row.enabled; formPolicy.value.enabled = row.enabled;
if(row.logicCode=='A'){ if(row.logicCode=='A'){
@ -532,6 +552,8 @@ function handlePolicy(row) {
sortIdVisiable.value=false; sortIdVisiable.value=false;
methodIdsVisiable.value=true; methodIdsVisiable.value=true;
tableVisiable.value=false; tableVisiable.value=false;
levelVisiable.value = true;
nameVisiable.value = true;
}else if(row.logicCode == 'B'){ }else if(row.logicCode == 'B'){
dialogWidth.value = '1600px'; dialogWidth.value = '1600px';
getModelList(row); getModelList(row);
@ -542,6 +564,8 @@ function handlePolicy(row) {
sortIdVisiable.value=false; sortIdVisiable.value=false;
methodIdsVisiable.value=false; methodIdsVisiable.value=false;
tableVisiable.value=true; tableVisiable.value=true;
levelVisiable.value = false;
nameVisiable.value = false;
}else if(row.logicCode == 'C'){ }else if(row.logicCode == 'C'){
ElMessageBox.alert('目前该告警逻辑没有实现', '提示', { ElMessageBox.alert('目前该告警逻辑没有实现', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@ -671,6 +695,7 @@ function submitFormPolicy() {
getList(); getList();
}); });
}else if(logicCode.value == 'A'){ }else if(logicCode.value == 'A'){
formPolicy.value.methodIds = formPolicy.value.methodIds?.join(',');
updatePolicy(formPolicy.value).then(response => { updatePolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功"); proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false; openPolicy.value = false;
@ -694,6 +719,7 @@ function submitFormPolicy() {
getList(); getList();
}); });
}else if(logicCode.value == 'A'){ }else if(logicCode.value == 'A'){
formPolicy.value.methodIds = formPolicy.value.methodIds?.join(',');
addPolicy(formPolicy.value).then(response => { addPolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功"); proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false; openPolicy.value = false;
@ -713,20 +739,32 @@ function cancelPolicy() {
// //
function getModelListSwitch(row){ function getModelListSwitch(row){
queryPolicy.value.alertId = row.id; queryPolicy.value.alertId = row.id;
queryModel.value.logicCode = row.logicCode;
queryModel.value.paramType = row.paramType;
listPolicyInfo(queryPolicy.value).then(response=>{ listPolicyInfo(queryPolicy.value).then(response=>{
// //
if(response.data && response.data.length>0){ if(response.data && response.data.length>0){
formPolicy.value.statusValue = response.data[0].statusValue; formPolicy.value.statusValue = response.data[0].statusValue;
formPolicy.value.statusType = response.data[0].statusType; formPolicy.value.statusType = response.data[0].statusType;
formPolicy.value.methodIds = response.data[0].methodIds?.split(',').map(Number); formPolicy.value.methodIds = response.data[0].methodIds==null||response.data[0].methodIds==''?null:response.data[0].methodIds.split(',').map(Number);
formPolicy.value.boolValue = response.data[0].boolValue; formPolicy.value.boolValue = response.data[0].boolValue;
formPolicy.value.level = response.data[0].level;
formPolicy.value.name = response.data[0].name;
formPolicy.value.alertId = row.id; formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid; formPolicy.value.deviceId = row.deviceUuid;
formPolicy.value.alertModelId = response.data[0].alertModelId;
formPolicy.value.id = response.data[0].id; formPolicy.value.id = response.data[0].id;
// //
}else{ }else{
formPolicy.value.alertId = row.id; formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid; formPolicy.value.deviceId = row.deviceUuid;
listModelEnabledNoPage(queryModel.value).then(response => {
if(response.data && response.data.length>0){
formPolicy.value.level = response.data[0].level;
formPolicy.value.name = response.data[0].name;
formPolicy.value.alertModelId = response.data[0].id;
}
});
} }
}); });
} }
@ -736,8 +774,10 @@ function getModelListSwitch(row){
function getModelList(row){ function getModelList(row){
queryPolicy.value.alertId = row.id; queryPolicy.value.alertId = row.id;
queryPolicy.value.flagEnabled = true; queryPolicy.value.flagEnabled = true;
listModel().then(response => { queryModel.value.logicCode = row.logicCode;
modelList.value = response.rows; queryModel.value.paramType = row.paramType;
listModelEnabledNoPage(queryModel.value).then(response => {
modelList.value = response.data;
formPolicy.value.alertId = row.id; formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid; formPolicy.value.deviceId = row.deviceUuid;
proxy.$refs.policyTable.clearSelection(); proxy.$refs.policyTable.clearSelection();
@ -765,7 +805,7 @@ function getModelList(row){
element.policyId = item.id; element.policyId = item.id;
element.statusValue = item.statusValue; element.statusValue = item.statusValue;
element.statusType = item.statusType; element.statusType = item.statusType;
element.methodIds = item.methodIds?.split(',').map(Number); element.methodIds = item.methodIds==null||item.methodIds==''?null:item.methodIds.split(',').map(Number);
element.operator = item.operator; element.operator = item.operator;
element.sort = item.sortId; element.sort = item.sortId;
element.id = item.alertModelId; element.id = item.alertModelId;
@ -942,9 +982,9 @@ function judgeIfRightValue(){
if(!handleValueChangeSub(item)){ if(!handleValueChangeSub(item)){
flag = false; flag = false;
}; };
if(item.value === '' || item.methodIds.length === 0){ // if(item.value === '' || item.methodIds == null || item.methodIds.length === 0){
flag = false; // flag = false;
} // }
}) })
} }
return flag; return flag;
@ -984,9 +1024,9 @@ const validateCell = (data) => {
} else if (typeof data.value === 'boolean') { } else if (typeof data.value === 'boolean') {
return data.value !== undefined && data.value !== null; return data.value !== undefined && data.value !== null;
} else if (Array.isArray(data.value)) { } else if (Array.isArray(data.value)) {
return data.value !== []; return data.value.lenght == 0;
} else if (typeof data.value === 'object') { } else if (typeof data.value === 'object') {
return data.value !== {}; return data.value.lenght == 0;
} else { } else {
return data.value !== undefined && data.value !== null; return data.value !== undefined && data.value !== null;
} }
@ -1030,6 +1070,17 @@ function changeEnabled(row){
updateAlert(param); updateAlert(param);
} }
function levelChange(value){
if(logicCode.value == 'A'){
dc_alert_level.value.forEach(item=>{
if(item.value == String(value)){
formPolicy.value.name = item.label
}
})
}
}
getList(); getList();

222
src/views/model/alert/model.vue

@ -1,8 +1,8 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="参数据类型" prop="paramType"> <el-form-item label="参数据类型" prop="paramType">
<el-select v-model="queryParams.paramType" placeholder="请选择参数据类型" clearable> <el-select v-model="queryParams.paramType" placeholder="请选择参数据类型" clearable>
<el-option <el-option
v-for="dict in dc_param_value_type" v-for="dict in dc_param_value_type"
:key="dict.value" :key="dict.value"
@ -30,12 +30,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="级别" prop="level"> <el-form-item label="级别" prop="level">
<el-input <el-select v-model="form.level" placeholder="请选择告警级别">
v-model="queryParams.level" <el-option
placeholder="请输入级别" v-for="dict in dc_alert_level"
clearable :key="dict.value"
@keyup.enter="handleQuery" :label="dict.label"
/> :value="dict.value"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="运算符" prop="operator"> <el-form-item label="运算符" prop="operator">
<el-select v-model="queryParams.operator" placeholder="请选择运算符" clearable> <el-select v-model="queryParams.operator" placeholder="请选择运算符" clearable>
@ -104,7 +106,7 @@
<el-table ref="modelTable" v-loading="loading" :data="modelList" @selection-change="handleSelectionChange"> <el-table ref="modelTable" v-loading="loading" :data="modelList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键" align="center" prop="id" /> <el-table-column label="主键" align="center" prop="id" />
<el-table-column label="参数据类型" align="center" prop="paramType" > <el-table-column label="参数据类型" align="center" prop="paramType" >
<template #default="scope"> <template #default="scope">
<dict-tag :options="dc_param_value_type" :value="scope.row.paramType"/> <dict-tag :options="dc_param_value_type" :value="scope.row.paramType"/>
</template> </template>
@ -115,7 +117,11 @@
<dict-tag :options="flagEnabledTable" :value="scope.row.flagEnabled"/> <dict-tag :options="flagEnabledTable" :value="scope.row.flagEnabled"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="级别" align="center" prop="level" /> <el-table-column label="级别" align="center" prop="level" >
<template #default="scope">
<dict-tag :options="dc_alert_level" :value="scope.row.level"/>
</template>
</el-table-column>
<el-table-column label="排序" align="center" prop="sort" /> <el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="运算符" align="center" prop="operator" > <el-table-column label="运算符" align="center" prop="operator" >
<template #default="scope"> <template #default="scope">
@ -150,11 +156,11 @@
<!-- 添加或修改告警模版对话框 --> <!-- 添加或修改告警模版对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body> <el-dialog :title="title" v-model="open" width="500px" append-to-body>
<el-form ref="modelRef" :model="form" :rules="rules" label-width="120px"> <el-form ref="modelRef" :model="form" :rules="getRule" label-width="120px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="参数据类型" prop="paramType"> <el-form-item label="参数据类型" prop="paramType">
<el-select v-model="form.paramType" placeholder="请选择参数据类型"> <el-select v-model="form.paramType" placeholder="请选择参数据类型" @change="paramTypeChange">
<el-option <el-option
v-for="dict in dc_param_value_type" v-for="dict in dc_param_value_type"
:key="dict.value" :key="dict.value"
@ -164,24 +170,31 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-show="codeVisiable">
<el-form-item label="代码" prop="code"> <el-form-item label="代码" prop="code">
<el-input v-model="form.code" placeholder="请输入代码" /> <el-input v-model="form.code" placeholder="请输入代码" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="级别" prop="level"> <el-form-item label="级别" prop="level">
<el-input v-model="form.level" placeholder="请输入级别" /> <el-select v-model="form.level" placeholder="请选择告警级别" ref="selectBlurLevel" @change="levelChange" @blur="handleBlurLevel">
<el-option
v-for="dict in dc_alert_level"
:key="dict.value"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-show="sortVisiable">
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort" >
<el-input v-model="form.sort" placeholder="请输入级别" /> <el-input v-model="form.sort" placeholder="请输入排序" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="是否有效" prop="flagEnabled"> <el-form-item label="是否有效" prop="flagEnabled">
<el-select v-model="form.flagEnabled" placeholder="请选择是否有效"> <el-select v-model="form.flagEnabled" placeholder="请选择是否有效" ref="selectFlagEnabled" @blur="handleBlurFlagEnabled">
<el-option <el-option
v-for="dict in flagEnabled" v-for="dict in flagEnabled"
:key="dict.value" :key="dict.value"
@ -193,7 +206,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="运算符" prop="operator"> <el-form-item label="运算符" prop="operator">
<el-select v-model="form.operator" placeholder="请选择运算符"> <el-select v-model="form.operator" :disabled="operatorDisabled" placeholder="请选择运算符">
<el-option <el-option
v-for="dict in operator_sign" v-for="dict in operator_sign"
:key="dict.value" :key="dict.value"
@ -208,11 +221,23 @@
<el-input v-model="form.name" placeholder="请输入名称" /> <el-input v-model="form.name" placeholder="请输入名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12" v-show="valueFloatVisiable">
<el-form-item label="值" prop="value"> <el-form-item label="值" prop="value">
<el-input v-model="form.value" placeholder="请输入值"/> <el-input v-model="form.value" placeholder="请输入值"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" v-show="valueBoolVisiable">
<el-form-item label="值" prop="value">
<el-select v-model="form.value" placeholder="请选择值">
<el-option
v-for="dict in alert_value"
:key="dict.label"
:label="dict.label"
:value="parseFloat(dict.label)"
/>
</el-select>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
<template #footer> <template #footer>
@ -228,10 +253,10 @@
@import "@/assets/styles/self-defined.scss"; @import "@/assets/styles/self-defined.scss";
</style> </style>
<script setup name="Model"> <script setup name="Model">
import { listModel, getModel, delModel, addModel, updateModel } from "@/api/model/alertmodel"; import { listModel,listModelEnabledNoPage, getModel, delModel, addModel, updateModel } from "@/api/model/alertmodel";
import { ElMessageBox } from 'element-plus'; import { ElMessageBox } from 'element-plus';
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const { dc_param_value_type,operator_sign } = proxy.useDict('dc_param_value_type','operator_sign'); const { dc_param_value_type,operator_sign,dc_alert_level } = proxy.useDict('dc_param_value_type','operator_sign','dc_alert_level');
const modelList = ref([]); const modelList = ref([]);
const open = ref(false); const open = ref(false);
const loading = ref(true); const loading = ref(true);
@ -241,6 +266,13 @@ const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const total = ref(0); const total = ref(0);
const title = ref(""); const title = ref("");
const rules = ref({});
const valueBoolVisiable = ref(false);
const valueFloatVisiable = ref(true);
const codeVisiable = ref(true);
const sortVisiable = ref(true);
const operatorVisiable = ref(true);
const operatorDisabled = ref(false);
const flagEnabled = ref([ const flagEnabled = ref([
{label: '有效', value: 1, elTagType: 'default', elTagClass: null}, {label: '有效', value: 1, elTagType: 'default', elTagClass: null},
{label: '无效', value: 0, elTagType: 'default', elTagClass: null} {label: '无效', value: 0, elTagType: 'default', elTagClass: null}
@ -249,6 +281,10 @@ const flagEnabledTable = ref([
{label: '有效', value: '1', elTagType: 'default', elTagClass: null}, {label: '有效', value: '1', elTagType: 'default', elTagClass: null},
{label: '无效', value: '0', elTagType: 'default', elTagClass: null} {label: '无效', value: '0', elTagType: 'default', elTagClass: null}
]); ]);
const alert_value = ref([
{label: '1', value: true, elTagType: 'default', elTagClass: null},
{label: '0', value: false, elTagType: 'default', elTagClass: null}
]);
const data = reactive({ const data = reactive({
form: {}, form: {},
queryParams: { queryParams: {
@ -260,14 +296,64 @@ const data = reactive({
level: null, level: null,
operator: null, operator: null,
name: null, name: null,
value: null value: null,
sort: null,
},
rulesA: {
paramType: [
{ required: true, message: "参数数据类型不能为空", trigger: "blur" }
],
code: [
{ required: false, message: "代码不能为空", trigger: "blur" }
],
flagEnabled: [
{ required: true, message: "是否有效标志不能为空", trigger: "blur" }
],
level: [
{ required: true, message: "告警等级不能为空", trigger: "blur" }
],
operator: [
{ required: false, message: "运算符不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "名称", trigger: "blur" }
],
value: [
{ required: true, message: "预设值不能为空", trigger: "blur" }
],
sort: [
{ required: false, message: "排序不能为空", trigger: "blur" }
],
},
rulesB: {
paramType: [
{ required: true, message: "参数数据类型不能为空", trigger: "blur" }
],
code: [
{ required: true, message: "代码不能为空", trigger: "blur" }
],
flagEnabled: [
{ required: true, message: "是否有效标志不能为空", trigger: "blur" }
],
level: [
{ required: true, message: "告警等级不能为空", trigger: "blur" }
],
operator: [
{ required: true, message: "运算符不能为空", trigger: "blur" }
],
name: [
{ required: true, message: "名称", trigger: "blur" }
],
value: [
{ required: true, message: "预设值不能为空", trigger: "blur" }
],
sort: [
{ required: true, message: "排序不能为空", trigger: "blur" }
],
}, },
rules: {
}
}); });
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rulesA, rulesB } = toRefs(data);
/** 查询告警模版列表 */ /** 查询告警模版列表 */
function getList() { function getList() {
loading.value = true; loading.value = true;
@ -306,6 +392,7 @@ function reset() {
name: null, name: null,
value: null value: null
}; };
proxy.resetForm("modelRef"); proxy.resetForm("modelRef");
} }
@ -313,11 +400,18 @@ function reset() {
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
proxy.resetForm("queryRef"); proxy.resetForm("queryRef");
codeVisiable.value = true;
sortVisiable.value = true;
operatorVisiable.value = true;
valueBoolVisiable.value = false;
valueFloatVisiable.value = true;
operatorDisabled.value = false;
handleQuery(); handleQuery();
} }
@ -333,6 +427,7 @@ function handleAdd() {
reset(); reset();
open.value = true; open.value = true;
title.value = "添加告警模版"; title.value = "添加告警模版";
form.value.operator= "==";
} }
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -343,6 +438,10 @@ function handleUpdate(row) {
form.value = response.data; form.value = response.data;
open.value = true; open.value = true;
title.value = "修改告警模版"; title.value = "修改告警模版";
if(row.paramType == '4'){
form.value.operator = "==";
}
paramTypeChange(row.paramType);
}); });
} }
@ -422,5 +521,72 @@ function judgeIfRightValue(){
return handleValueChange(form.value); return handleValueChange(form.value);
} }
function levelChange(value){
if(form.value.paramType == '4'){
dc_alert_level.value.forEach(item=>{
if(item.value == value){
form.value.name = item.label
}
})
}else{
dc_alert_level.value.forEach(item=>{
if(item.value == value){
form.value.name = item.label
}
})
}
}
function paramTypeChange(value){
if(value == '4'){
// rules.value = rulesA
codeVisiable.value = false;
sortVisiable.value = false;
operatorVisiable.value = false;
valueBoolVisiable.value = true;
valueFloatVisiable.value = false;
operatorDisabled.value = true;
}else if(value == '3'){
// rules.value = rulesB
codeVisiable.value = true;
sortVisiable.value = true;
operatorVisiable.value = true;
valueBoolVisiable.value = false;
valueFloatVisiable.value = true;
operatorDisabled.value = false;
}else{
// rules.value = rulesB
codeVisiable.value = true;
sortVisiable.value = true;
operatorVisiable.value = true;
valueBoolVisiable.value = false;
valueFloatVisiable.value = true;
operatorDisabled.value = false;
}
}
const getRule = computed(() => {
if(form.value.paramType == 4){
return rulesA.value;
}else{
return rulesB.value;
}
});
function handleBlurLevel(value){
if(form.value.level != null){
proxy.$refs.selectBlurLevel.hideMenu();
}
}
function handleBlurFlagEnabled(value){
if(form.value.flagEnabled != null){
proxy.$refs.selectFlagEnabled.clearValidate();
}
}
getList(); getList();
</script> </script>

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

@ -1,88 +1,104 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px"> <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
<el-form-item label="数据类型" prop="paramType"> <el-row>
<el-select v-model="queryParams.paramType" placeholder="请选择数据类型" clearable> <el-col :span="4">
<el-option <el-form-item label="数据类型" prop="paramType">
v-for="dict in dc_param_value_type" <el-select v-model="queryParams.paramType" placeholder="请选择数据类型" clearable>
:key="dict.value" <el-option
:label="dict.label" v-for="dict in dc_param_value_type"
:value="dict.value" :key="dict.value"
/> :label="dict.label"
</el-select> :value="dict.value"
</el-form-item> />
<el-form-item label="开始值" prop="beginValue"> </el-select>
<el-input </el-form-item>
v-model="queryParams.beginValue" </el-col>
placeholder="请输入开始值" <el-col :span="4">
clearable <el-form-item label="开始值" prop="beginValue">
@keyup.enter="handleQuery" <el-input
/> v-model="queryParams.beginValue"
</el-form-item> placeholder="请输入开始值"
<el-form-item label="结束值" prop="endValue"> clearable
<el-input @keyup.enter="handleQuery"
v-model="queryParams.endValue" />
placeholder="请输入结束值" </el-form-item>
clearable </el-col>
@keyup.enter="handleQuery" <el-col :span="4">
/> <el-form-item label="是否告警" prop="alertFlag">
</el-form-item> <el-select v-model="queryParams.alertFlag" placeholder="请选择是否告警" clearable>
<el-form-item label="是否告警" prop="alertFlag"> <el-option
<el-select v-model="queryParams.alertFlag" placeholder="请选择是否告警" clearable> v-for="item in alertFlag"
<el-option :key="item.value"
v-for="item in alertFlag" :label="item.label"
:key="item.value" :value="item.value"
:label="item.label" />
:value="item.value" </el-select>
/> </el-form-item>
</el-select> </el-col>
</el-form-item> <el-col :span="4">
<el-form-item label="策略ID" prop="alertId"> <el-form-item label="策略ID" prop="alertId">
<el-input <el-input
v-model="queryParams.alertId" v-model="queryParams.alertId"
placeholder="请输入策略ID" placeholder="请输入策略ID"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态值" prop="statusValue"> </el-col>
<el-input <el-col :span="4">
v-model="queryParams.statusValue" <el-form-item label="状态值" prop="statusValue">
placeholder="请输入状态值" <el-input
clearable v-model="queryParams.statusValue"
@keyup.enter="handleQuery" placeholder="请输入状态值"
/> clearable
</el-form-item> @keyup.enter="handleQuery"
<el-form-item label="状态类型" prop="statusType"> />
<el-select v-model="queryParams.statusType" placeholder="请选择状态类型" clearable> </el-form-item>
<el-option label="请选择字典生成" value="" /> </el-col>
</el-select> <el-col :span="4">
</el-form-item> <el-form-item label="状态类型" prop="statusType">
<el-form-item label="中台设备ID" prop="deviceId"> <el-select v-model="queryParams.statusType" placeholder="请选择状态类型" clearable>
<el-input <el-option label="请选择字典生成" value="" />
v-model="queryParams.deviceId" </el-select>
placeholder="请输入中台设备ID" </el-form-item>
clearable </el-col>
@keyup.enter="handleQuery" </el-row>
/> <el-row>
</el-form-item> <el-col :span="4">
<el-form-item label="排序" prop="sortId"> <el-form-item label="中台设备ID" prop="deviceId">
<el-input-number v-model="queryParams.sortId" :min="1" :max="1000" /> <el-input
</el-form-item> v-model="queryParams.deviceId"
<el-form-item label="告警方式" prop="methodId"> placeholder="请输入中台设备ID"
<el-select v-model="queryParams.methodId" placeholder="请选择告警方式ID" clearable> clearable
<el-option @keyup.enter="handleQuery"
v-for="item in methodList" />
:key="item.id" </el-form-item>
:label="item.methodName" </el-col>
:value="item.id" <el-col :span="4">
/> <el-form-item label="排序" prop="sortId">
</el-select> <el-input-number v-model="queryParams.sortId" :min="1" :max="1000" />
</el-form-item> </el-form-item>
<el-form-item> </el-col>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button> <el-col :span="4">
<el-button type="info" plain icon="Refresh" @click="resetQuery">重置</el-button> <el-form-item label="告警方式" prop="methodId">
</el-form-item> <el-select v-model="queryParams.methodId" placeholder="请选择告警方式ID" clearable>
<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="4" class="textaligncenter">
<el-form-item>
<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-col>
</el-row>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
@ -219,6 +235,9 @@
</div> </div>
</template> </template>
<style lang="scss" >
@import "@/assets/styles/self-defined.scss";
</style>
<script setup name="Policy"> <script setup name="Policy">
import { selectDeviceParamPolicy, 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"; import { listMethod } from "@/api/model/method";

Loading…
Cancel
Save