|
|
@ -1,8 +1,8 @@ |
|
|
|
<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-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" |
|
|
@ -30,12 +30,14 @@ |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="级别" prop="level"> |
|
|
|
<el-input |
|
|
|
v-model="queryParams.level" |
|
|
|
placeholder="请输入级别" |
|
|
|
clearable |
|
|
|
@keyup.enter="handleQuery" |
|
|
|
/> |
|
|
|
<el-select v-model="form.level" placeholder="请选择告警级别"> |
|
|
|
<el-option |
|
|
|
v-for="dict in dc_alert_level" |
|
|
|
:key="dict.value" |
|
|
|
:label="dict.label" |
|
|
|
:value="dict.value" |
|
|
|
/> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="运算符" prop="operator"> |
|
|
|
<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-column type="selection" width="55" align="center" /> |
|
|
|
<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"> |
|
|
|
<dict-tag :options="dc_param_value_type" :value="scope.row.paramType"/> |
|
|
|
</template> |
|
|
@ -115,7 +117,11 @@ |
|
|
|
<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="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="operator" > |
|
|
|
<template #default="scope"> |
|
|
@ -150,11 +156,11 @@ |
|
|
|
|
|
|
|
<!-- 添加或修改告警模版对话框 --> |
|
|
|
<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-col :span="12"> |
|
|
|
<el-form-item label="参数据类型" prop="paramType"> |
|
|
|
<el-select v-model="form.paramType" placeholder="请选择参数据类型"> |
|
|
|
<el-form-item label="参数数据类型" prop="paramType"> |
|
|
|
<el-select v-model="form.paramType" placeholder="请选择参数数据类型" @change="paramTypeChange"> |
|
|
|
<el-option |
|
|
|
v-for="dict in dc_param_value_type" |
|
|
|
:key="dict.value" |
|
|
@ -164,24 +170,31 @@ |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-col :span="12" v-show="codeVisiable"> |
|
|
|
<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="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-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="排序" prop="sort"> |
|
|
|
<el-input v-model="form.sort" placeholder="请输入级别" /> |
|
|
|
<el-col :span="12" v-show="sortVisiable"> |
|
|
|
<el-form-item label="排序" prop="sort" > |
|
|
|
<el-input v-model="form.sort" placeholder="请输入排序" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<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 |
|
|
|
v-for="dict in flagEnabled" |
|
|
|
:key="dict.value" |
|
|
@ -193,7 +206,7 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="运算符" prop="operator"> |
|
|
|
<el-select v-model="form.operator" placeholder="请选择运算符"> |
|
|
|
<el-select v-model="form.operator" :disabled="operatorDisabled" placeholder="请选择运算符"> |
|
|
|
<el-option |
|
|
|
v-for="dict in operator_sign" |
|
|
|
:key="dict.value" |
|
|
@ -208,11 +221,23 @@ |
|
|
|
<el-input v-model="form.name" placeholder="请输入名称" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-col :span="12" v-show="valueFloatVisiable"> |
|
|
|
<el-form-item label="值" prop="value"> |
|
|
|
<el-input v-model="form.value" placeholder="请输入值"/> |
|
|
|
</el-form-item> |
|
|
|
</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-form> |
|
|
|
<template #footer> |
|
|
@ -228,10 +253,10 @@ |
|
|
|
@import "@/assets/styles/self-defined.scss"; |
|
|
|
</style> |
|
|
|
<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'; |
|
|
|
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 open = ref(false); |
|
|
|
const loading = ref(true); |
|
|
@ -241,6 +266,13 @@ const single = ref(true); |
|
|
|
const multiple = ref(true); |
|
|
|
const total = ref(0); |
|
|
|
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([ |
|
|
|
{label: '有效', value: 1, 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: '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({ |
|
|
|
form: {}, |
|
|
|
queryParams: { |
|
|
@ -260,14 +296,64 @@ const data = reactive({ |
|
|
|
level: null, |
|
|
|
operator: 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() { |
|
|
|
loading.value = true; |
|
|
@ -306,6 +392,7 @@ function reset() { |
|
|
|
name: null, |
|
|
|
value: null |
|
|
|
}; |
|
|
|
|
|
|
|
proxy.resetForm("modelRef"); |
|
|
|
} |
|
|
|
|
|
|
@ -313,11 +400,18 @@ function reset() { |
|
|
|
function handleQuery() { |
|
|
|
queryParams.value.pageNum = 1; |
|
|
|
getList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** 重置按钮操作 */ |
|
|
|
function resetQuery() { |
|
|
|
proxy.resetForm("queryRef"); |
|
|
|
codeVisiable.value = true; |
|
|
|
sortVisiable.value = true; |
|
|
|
operatorVisiable.value = true; |
|
|
|
valueBoolVisiable.value = false; |
|
|
|
valueFloatVisiable.value = true; |
|
|
|
operatorDisabled.value = false; |
|
|
|
handleQuery(); |
|
|
|
} |
|
|
|
|
|
|
@ -333,6 +427,7 @@ function handleAdd() { |
|
|
|
reset(); |
|
|
|
open.value = true; |
|
|
|
title.value = "添加告警模版"; |
|
|
|
form.value.operator= "=="; |
|
|
|
} |
|
|
|
|
|
|
|
/** 修改按钮操作 */ |
|
|
@ -343,6 +438,10 @@ function handleUpdate(row) { |
|
|
|
form.value = response.data; |
|
|
|
open.value = true; |
|
|
|
title.value = "修改告警模版"; |
|
|
|
if(row.paramType == '4'){ |
|
|
|
form.value.operator = "=="; |
|
|
|
} |
|
|
|
paramTypeChange(row.paramType); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -422,5 +521,72 @@ function judgeIfRightValue(){ |
|
|
|
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(); |
|
|
|
</script> |
|
|
|