Browse Source

告警改动初版

pull/1/head
ljlong_2630 1 year ago
parent
commit
5aba24d28f
  1. 3
      .gitignore
  2. 53
      src/api/model/logicconfig.js
  3. 4
      src/api/model/policy.js
  4. 9
      src/assets/styles/self-defined.scss
  5. 447
      src/views/model/alert/deviceparamalert.vue
  6. 298
      src/views/model/alert/logicconfig.vue
  7. 58
      src/views/model/alert/model.vue
  8. 132
      src/views/model/device/index.vue

3
.gitignore

@ -20,4 +20,5 @@ bin-release/
*.DS_Store
node_modules/
package-lock.json
dist/
dist/
dist.tar.gz

53
src/api/model/logicconfig.js

@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询告警逻辑列表
export function listLogicconfig(query) {
return request({
url: '/model/dcBusiAlertLogicConfig/list',
method: 'get',
params: query
})
}
// 查询告警逻辑详细
export function getLogicconfig(id) {
return request({
url: '/model/dcBusiAlertLogicConfig/' + id,
method: 'get'
})
}
// 新增告警逻辑
export function addLogicconfig(data) {
return request({
url: '/model/dcBusiAlertLogicConfig',
method: 'post',
data: data
})
}
// 修改告警逻辑
export function updateLogicconfig(data) {
return request({
url: '/model/dcBusiAlertLogicConfig',
method: 'put',
data: data
})
}
// 删除告警逻辑
export function delLogicconfig(id) {
return request({
url: '/model/dcBusiAlertLogicConfig/' + id,
method: 'delete'
})
}
// 导出告警逻辑
export function exportLogicconfig(query) {
return request({
url: '/${baseUrl}/export',
method: 'get',
params: query
})
}

4
src/api/model/policy.js

@ -81,11 +81,11 @@ export function listPolicyNoPage(query) {
}
// 批量修改参数值状态策略
export function updatePolicyBatch(data) {
export function updatePolicyBatch(updateList,deleteList,addList) {
return request({
url: '/model/dcBusiAlertParamPolicy/batchUpdate',
method: 'put',
data: data
data: {"updateList":updateList,"deleteList":deleteList,"addList":addList}
})
}

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

@ -59,7 +59,6 @@
margin-top:10px;
}
<<<<<<< Updated upstream
.el-step__icon {
position: relative;
z-index: 1;
@ -90,15 +89,12 @@
width: 0;
height: 0;
}
=======
>>>>>>> Stashed changes
.divsonmarginleft0{
div{
margin-left:0 !important;
}
}
<<<<<<< Updated upstream
.marginbottom{
@ -184,8 +180,3 @@
display: block;
}
=======
.marginbottom{
margin-bottom: 0 !important;
}
>>>>>>> Stashed changes

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

@ -1,43 +1,54 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="中台设备ID" prop="deviceUuid">
<el-input
v-model="queryParams.deviceUuid"
placeholder="请输入中台设备ID"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="参数编码" prop="paramCode">
<el-input
v-model="queryParams.paramCode"
placeholder="请输入参数编码"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="参数名称" prop="paramName">
<el-input
v-model="queryParams.paramName"
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-row>
<el-col :span="4">
<el-form-item label="中台设备ID" prop="deviceUuid">
<el-input
v-model="queryParams.deviceUuid"
placeholder="请输入中台设备ID"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="设备名称" prop="deviceName">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="参数编码" prop="paramCode">
<el-input
v-model="queryParams.paramCode"
placeholder="请输入参数编码"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="参数名称" prop="paramName">
<el-input
v-model="queryParams.paramName"
placeholder="请输入参数名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<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-col>
</el-row>
</el-form>
<el-row :gutter="10" class="mb8">
@ -72,7 +83,7 @@
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="alertList" @selection-change="handleSelectionChange">
<el-table v-loading="loading" :data="alertList">
<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" />
@ -136,7 +147,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="告警参数" prop="paramCode">
<el-select v-model="form.paramCode" filterable placeholder="请选择参数" clearable>
<el-select v-model="form.paramCode" filterable placeholder="请选择参数" clearable @change="setParamsType">
<el-option
v-for="item in paramsList"
:key="item.paramCode"
@ -146,6 +157,11 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="告警参数类型" v-show="false" prop="paramCode">
<el-input v-model="form.paramType"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
@ -156,13 +172,13 @@
</template>
</el-dialog>
<!-- 添加或修改参数值状态策略对话框 -->
<el-dialog :title="titlePolicy" v-model="openPolicy" width="1200px" append-to-body>
<el-dialog :title="titlePolicy" v-model="openPolicy" width="1600px" append-to-body>
<el-form ref="policyRef" :model="formPolicy" :rules="rulesPolicy" label-width="120px">
<el-row>
<el-col :span="12" v-show="beginValueVisiable">
<el-form-item label="告警值" prop="beginValue">
<!-- <el-input v-model="formPolicy.beginValue" placeholder="请输入开始值" /> -->
<el-select v-model="formPolicy.beginValue" placeholder="请选择是否告警">
<el-col :span="12" v-show="boolValueVisiable">
<el-form-item label="告警值" prop="boolValue">
<!-- <el-input v-model="formPolicy.boolValue" placeholder="请输入开始值" /> -->
<el-select v-model="formPolicy.boolValue" placeholder="请选择是否告警">
<el-option
v-for="item in alert_value"
:key="item.value"
@ -172,21 +188,9 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否告警" prop="alertFlag">
<el-select v-model="formPolicy.alertFlag" placeholder="请选择是否告警">
<el-option
v-for="item in alertFlag"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12" v-show="methodIdVisiable">
<el-form-item label="告警方式" prop="methodId">
<el-select v-model="formPolicy.methodId" placeholder="请选择告警方式">
<el-col :span="12" v-show="methodIdsVisiable">
<el-form-item label="告警方式" prop="methodIds">
<el-select v-model="formPolicy.methodIds" placeholder="请选择告警方式">
<el-option
v-for="item in methodList"
:key="item.id"
@ -220,7 +224,7 @@
</el-col>
<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 ref="policyTable" v-loading="loading" :data="modelList" :row-key="getRowKey" @selection-change="handleSelectionChange">
<el-table-column type="selection" reserve-selection="true" width="55" align="center" />
<el-table-column label="名称" align="center" prop="name">
<template #default="scope">
@ -235,7 +239,7 @@
</el-table-column>
<el-table-column label="限值" align="center" prop="value">
<template #default="scope">
<el-input v-model="scope.row.value"></el-input>
<el-input v-model="scope.row.value" @change="handleValueChange(scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="级别" align="center" prop="level">
@ -243,9 +247,14 @@
<el-input v-model="scope.row.level"></el-input>
</template>
</el-table-column>
<el-table-column label="告警方式" align="center" prop="methodId">
<el-table-column label="排序" align="center" prop="sort">
<template #default="scope">
<el-input v-model="scope.row.sort"></el-input>
</template>
</el-table-column>
<el-table-column label="告警方式" align="center" prop="methodIds">
<template #default="scope">
<el-select v-model="scope.row.methodId" placeholder="请选择告警方式">
<el-select v-model="scope.row.methodIds" multiple @change="methodIdsChange" placeholder="请选择告警方式">
<el-option
v-for="item in methodList"
:key="item.id"
@ -305,8 +314,6 @@ const openPolicy = 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 deviceList = ref([]);
@ -317,25 +324,22 @@ const selectedRows = ref([]);
const deletePolicyRows = ref([]);
const oldPolicyRows = ref([]);
const addPolicyRows = ref([]);
const policyParamsUpdateAdd = ref([]);
const beginValueVisiable = ref(false);
const boolValueVisiable = ref(false);
const statusValueVisiable = ref(false);
const statusTypeVisiable = ref(false);
const sortIdVisiable = ref(false);
const methodIdVisiable = ref(false);
const methodIdsVisiable = ref(false);
const policyModelVisiable = ref(false);
const policyParams = ref([]);
const policyAlertId = ref("");
const policyDeviceUuid = ref("");
const paramTypeValue = ref("");
const logicCode = ref("");
const rowPolicySelected = ref([]);
const enabledFlagTable = ref([
{label: '可用', value: 'true', elTagType: 'default', elTagClass: null},
{label: '不可用', value: 'false', elTagType: 'default', elTagClass: null}
]);
const alertFlag = ref([
{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}
@ -360,15 +364,14 @@ const data = reactive({
queryParamsPolicy:{
pageNum: 1,
pageSize: 10,
beginValue: null,
boolValue: null,
endValue: null,
alertFlag: null,
alertId: null,
statusValue: null,
statusType: null,
deviceId: null,
sortId: null,
methodId: null
methodIds: null
},
queryPolicy:{
alertId: null,
@ -412,7 +415,6 @@ function cancel() {
//
function reset() {
form.value = {
id: null,
tentantId: null,
version: null,
createBy: null,
@ -423,9 +425,18 @@ function reset() {
userId: null,
deleteBy: null,
deleteTime: null,
deviceUuid: null,
paramCode: null,
note: null
id: null,
boolValue: null,
alertId: null,
statusValue: null,
statusType: null,
deviceId: null,
sortId: null,
sort: null,
methodIds: null,
level:null,
operator: null,
operator_sign: null,
};
proxy.resetForm("alertRef");
}
@ -444,15 +455,17 @@ function resetPolicy() {
deleteBy: null,
deleteTime: null,
id: null,
beginValue: null,
endValue: null,
alertFlag: null,
boolValue: null,
alertId: null,
statusValue: null,
statusType: null,
deviceId: null,
sortId: null,
methodId: null
sort: null,
methodIds: null,
level:null,
operator: null,
operator_sign: null,
};
proxy.resetForm("policyRef");
}
@ -471,9 +484,13 @@ function resetQuery() {
//
function handleSelectionChange(selection) {
ids.value = selection.map(item => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
selection.forEach(item=>{
if(!rowPolicySelected.value.includes(item)){
handleValueChange(item);
}
})
rowPolicySelected.value = selection;
}
/** 新增按钮操作 */
@ -489,22 +506,37 @@ function handlePolicy(row) {
resetPolicy();
selectedRows.value=[];
deletePolicyRows.value=[];
if(row.paramType==4){
addPolicyRows.value=[];
deletePolicyRows.value=[];
logicCode.value = row.logicCode;
if(row.logicCode=='A'){
getModelListSwitch(row);
beginValueVisiable.value=true;
boolValueVisiable.value=true;
policyModelVisiable.value=false;
statusValueVisiable.value=true;
statusTypeVisiable.value=true;
sortIdVisiable.value=false;
methodIdVisiable.value=true;
}else{
methodIdsVisiable.value=true;
}else if(row.logicCode == 'B'){
getModelList(row);
policyModelVisiable.value=true;
beginValueVisiable.value=false;
boolValueVisiable.value=false;
statusValueVisiable.value=false;
statusTypeVisiable.value=false;
sortIdVisiable.value=false;
methodIdVisiable.value=false;
methodIdsVisiable.value=false;
}else if(row.logicCode == 'C'){
ElMessageBox.alert('目前该告警逻辑没有实现', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
}else{
ElMessageBox.alert('请确保已创建有效告警逻辑', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
}
getMethodList();
queryParamsPolicy.value.alertId = row.id;
@ -584,29 +616,32 @@ function submitFormPolicy() {
//
if (formPolicy.value.id != null) {
//
if(paramTypeValue.value != 4 ){
if(proxy.$refs.policyTable.getSelectionRows().length==0){
ElMessageBox.alert('请确保至少勾选了一条告警算法', '提示', {
confirmButtonText: '确定',
center: true,
})
if(logicCode.value == 'B' ){
// if(proxy.$refs.policyTable.getSelectionRows().length==0){
// ElMessageBox.alert('', '', {
// confirmButtonText: '',
// center: true,
// })
// return;
// }
if(!judgeIfRightValue()){
return;
}
};
mapFormTableUpdate();
computeDelPolicy();
computeAddPolicy();
updatePolicyBatch(policyParams.value).then(response => {
if(deletePolicyRows.value.length>0){
newHandleDeletePolicy();
}
if(addPolicyRows.value.length>0){
handleAddPolicy();
}
updatePolicyBatch(policyParams.value,deletePolicyRows.value,addPolicyRows.value).then(response => {
// if(deletePolicyRows.value.length>0){
// newHandleDeletePolicy();
// }
// if(addPolicyRows.value.length>0){
// handleAddPolicy();
// }
proxy.$modal.msgSuccess("修改成功");
openPolicy.value = false;
getList();
});
}else{
}else if(logicCode.value == 'A'){
updatePolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
@ -615,21 +650,24 @@ function submitFormPolicy() {
}
} else {
//
if(paramTypeValue.value != 4 ){
if(proxy.$refs.policyTable.getSelectionRows().length==0){
ElMessageBox.alert('请确保至少勾选了一条告警算法', '提示', {
confirmButtonText: '确定',
center: true,
})
if(logicCode.value == 'B' ){
// if(proxy.$refs.policyTable.getSelectionRows().length==0){
// ElMessageBox.alert('', '', {
// confirmButtonText: '',
// center: true,
// })
// return;
// }
if(!judgeIfRightValue()){
return;
}
};
mapFormTable();
addPolicyBatch(policyParams.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
getList();
});
}else{
}else if(logicCode.value == 'A'){
addPolicy(formPolicy.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
openPolicy.value = false;
@ -654,9 +692,8 @@ function getModelListSwitch(row){
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.beginValue = response.data[0].beginValue;
formPolicy.value.methodIds = response.data[0].methodIds.split(',');
formPolicy.value.boolValue = response.data[0].boolValue;
formPolicy.value.alertId = row.id;
formPolicy.value.deviceId = row.deviceUuid;
formPolicy.value.id = response.data[0].id;
@ -672,6 +709,7 @@ function getModelListSwitch(row){
//
function getModelList(row){
queryPolicy.value.alertId = row.id;
queryPolicy.value.flagEnabled = true;
listModel().then(response => {
modelList.value = response.rows;
formPolicy.value.alertId = row.id;
@ -683,7 +721,6 @@ function getModelList(row){
if(response.data && response.data.length>0){
console.log(response.data);
oldPolicyRows.value = response.data;
formPolicy.value.alertFlag = response.data[0].alertFlag;
formPolicy.value.alertId = response.data[0].alertId;
formPolicy.value.deviceId = response.data[0].deviceId;
formPolicy.value.id = response.data[0].id;
@ -692,13 +729,21 @@ function getModelList(row){
if(item.alertModelId == element.id){
policyDeviceUuid.value = item.deviceId;
policyAlertId.value = item.alertId;
element.value = item.beginValue;
element.level = item.sortId;
if(paramTypeValue.value == '3'){
element.value = item.floatValue;
}else if(paramTypeValue.value == '2'){
element.value = item.stringValue;
}else if(paramTypeValue.value == '1'){
element.value = item.intValue;
}
element.level = item.level;
element.name = item.name;
element.id = item.id;
element.statusValue = item.statusValue;
element.statusType = item.statusType;
element.methodId = item.methodId;
element.methodIds = item.methodIds.split(',');
element.operator = item.operator;
element.sort = item.sortId;
proxy.$refs.policyTable.toggleRowSelection(element,true);
return element;
}
@ -716,16 +761,23 @@ function mapFormTable(){
policyParams.value=[];
policyTableRows.forEach(item=>{
let policyParam = {};
policyParam.alertFlag = formPolicy.value.alertFlag;
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = policyAlertId.value;
policyParam.beginValue = item.value;
policyParam.sortId = item.level;
if(paramTypeValue.value == '3'){
policyParam.floatValue = item.value;
}else if(paramTypeValue.value == '2'){
policyParam.stringValue = item.value;
}else if(paramTypeValue.value == '1'){
policyParam.intValue = item.value;
}
policyParam.level = item.level;
policyParam.alertModelId = item.id;
policyParam.name = item.name;
policyParam.statusValue = item.statusValue;
policyParam.statusType = item.statusType;
policyParam.methodId = item.methodId;
policyParam.methodIds = item.methodIds.join(',');
policyParam.operator = item.operator;
policyParam.sortId = item.sort;
policyParams.value.push(policyParam);
})
}
@ -737,16 +789,23 @@ function mapFormTableUpdate(){
policyTableRows.forEach(item=>{
let policyParam = {};
policyParam.id = item.id;
policyParam.alertFlag = formPolicy.value.alertFlag;
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = item.alertId;
policyParam.beginValue = item.value;
policyParam.sortId = item.level;
if(paramTypeValue.value == '3'){
policyParam.floatValue = item.value;
}else if(paramTypeValue.value == '2'){
policyParam.stringValue = item.value;
}else if(paramTypeValue.value == '1'){
policyParam.intValue = item.value;
}
policyParam.level = item.level;
policyParam.alertModelId = item.alertModelId;
policyParam.name = item.name;
policyParam.statusValue = item.statusValue;
policyParam.statusType = item.statusType;
policyParam.methodId = item.methodId;
policyParam.methodIds = item.methodIds.join(',');
policyParam.operator = item.operator;
policyParam.sortId = item.sort;
policyParams.value.push(policyParam);
})
}
@ -757,20 +816,6 @@ function getRowKey(row){
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();
@ -782,6 +827,9 @@ function computeDelPolicy() {
}
})
if(!flag){
policyParams.value = policyParams.value.filter(element=>{
return item.id === element.id
})
deletePolicyRows.value.push(item);
}
})
@ -797,37 +845,104 @@ function computeAddPolicy() {
}
})
if(!flag){
addPolicyRows.value.push(item);
policyParams.value = policyParams.value.filter(element=>{
return item.id !== element.id;
})
//id
delete item.id;
let policyParam = {};
policyParam.deviceId = policyDeviceUuid.value;
policyParam.alertId = policyAlertId.value;
if(paramTypeValue.value == '3'){
policyParam.floatValue = item.value;
}else if(paramTypeValue.value == '2'){
policyParam.stringValue = item.value;
}else if(paramTypeValue.value == '1'){
policyParam.intValue = item.value;
}
policyParam.level = item.level;
policyParam.alertModelId = item.id;
policyParam.name = item.name;
policyParam.statusValue = item.statusValue;
policyParam.statusType = item.statusType;
policyParam.methodIds = item.methodIds.join(',');
policyParam.operator = item.operator;
policyParam.sortId = item.sort;
addPolicyRows.value.push(policyParam);
}
})
}
/** 新增方法 */
function handleAddPolicy(){
mapFormTableUpdataAdd();
addPolicyBatch(policyParamsUpdateAdd.value);
function setParamsType(val){
paramsList.value.forEach(item=>{
if(item.paramCode == val){
form.value.paramType = item.paramType;
}
})
}
//
function mapFormTableUpdataAdd(){
policyParamsUpdateAdd.value=[];
addPolicyRows.value.forEach(item=>{
let policyParam = {};
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;
policyParam.statusValue = item.statusValue;
policyParam.statusType = item.statusType;
policyParam.methodId = item.methodId;
policyParamsUpdateAdd.value.push(policyParam);
})
//
function handleValueChange(row){
let flag = true;
const selectedRowsNow = proxy.$refs.policyTable.getSelectionRows();
if(selectedRowsNow.length>0){
selectedRowsNow.forEach(item=>{
if(item.sort < row.sort){
if(item.value > row.value){
flag = false;
}
}else if(item.sort > row.sort){
if(item.value < row.value){
flag = false;
}
}
})
}
if(!flag){
ElMessageBox.alert('请确认目前已勾选的告警限值配置是否合理', '提示', {
confirmButtonText: '确定',
center: true,
})
}
return flag;
}
function judgeIfRightValue(){
let flag = true;
const selectedRowsNow = proxy.$refs.policyTable.getSelectionRows();
if(selectedRowsNow.length>0){
selectedRowsNow.forEach(item=>{
if(!handleValueChangeSub(item)){
flag = false;
};
})
}
return flag;
}
//
function handleValueChangeSub(row){
let flag = true;
const selectedRowsNow = proxy.$refs.policyTable.getSelectionRows();
if(selectedRowsNow.length>0){
selectedRowsNow.forEach(item=>{
if(item.sort < row.sort){
if(item.value > row.value){
flag = false;
}
}else if(item.sort > row.sort){
if(item.value < row.value){
flag = false;
}
}
})
}
return flag;
}
function methodIdsChange(){
proxy.$forceUpdate();
}
getList();

298
src/views/model/alert/logicconfig.vue

@ -0,0 +1,298 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="逻辑编码" prop="logicCode">
<el-select v-model="queryParams.logicCode" placeholder="请选择逻辑编码" clearable>
<el-option
v-for="dict in dc_alert_logic"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="参数变量类型" prop="paramValueType">
<el-select v-model="queryParams.paramValueType" 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="note">
<el-input
v-model="queryParams.note"
placeholder="请输入备注"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<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-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="logicconfigList" @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="logicCode">
<template #default="scope">
<dict-tag :options="dc_alert_logic" :value="scope.row.logicCode"/>
</template>
</el-table-column>
<el-table-column label="参数变量类型" align="center" prop="paramValueType">
<template #default="scope">
<dict-tag :options="dc_param_value_type" :value="scope.row.paramValueType"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="note" />
<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="800px" append-to-body>
<el-form ref="logicconfigRef" :model="form" :rules="rules" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="逻辑编码" prop="logicCode">
<el-select v-model="form.logicCode" placeholder="请选择逻辑编码">
<el-option
v-for="dict in dc_alert_logic"
:key="dict.value"
:label="dict.label"
:value="dict.value" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="参数变量类型" prop="paramValueType">
<el-select v-model="form.paramValueType" placeholder="请选择参数变量类型">
<el-option
v-for="dict in dc_param_value_type"
:key="dict.value"
:label="dict.label"
:value="dict.value" ></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="note">
<el-input v-model="form.note" 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>
<script setup name="Logicconfig">
import { listLogicconfig, getLogicconfig, delLogicconfig, addLogicconfig, updateLogicconfig } from "@/api/model/logicconfig";
const { proxy } = getCurrentInstance();
const { dc_alert_logic, dc_param_value_type } = proxy.useDict('dc_alert_logic', 'dc_param_value_type');
const logicconfigList = 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 data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
logicCode: null,
paramValueType: null,
note: null
},
rules: {
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询告警逻辑列表 */
function getList() {
loading.value = true;
listLogicconfig(queryParams.value).then(response => {
logicconfigList.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,
logicCode: null,
paramValueType: null,
note: null
};
proxy.resetForm("logicconfigRef");
}
/** 搜索按钮操作 */
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
getLogicconfig(_id).then(response => {
form.value = response.data;
open.value = true;
title.value = "修改告警逻辑";
});
}
/** 提交按钮 */
function submitForm() {
proxy.$refs["logicconfigRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
updateLogicconfig(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
addLogicconfig(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 delLogicconfig(_ids);
}).then(() => {
getList();
proxy.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
/** 导出按钮操作 */
function handleExport() {
proxy.download('model/alert/logicconfig/export', {
...queryParams.value
}, `logicconfig_${new Date().getTime()}.xlsx`)
}
getList();
</script>

58
src/views/model/alert/model.vue

@ -101,7 +101,7 @@
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table 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 label="主键" align="center" prop="id" />
<el-table-column label="参数据类型" align="center" prop="paramType" >
@ -116,6 +116,7 @@
</template>
</el-table-column>
<el-table-column label="级别" align="center" prop="level" />
<el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="运算符" align="center" prop="operator" >
<template #default="scope">
<dict-tag :options="operator_sign" :value="scope.row.operator"/>
@ -168,6 +169,16 @@
<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-form-item>
</el-col>
<el-col :span="12">
<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="请选择是否有效">
@ -180,11 +191,6 @@
</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="请选择运算符">
@ -204,7 +210,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="值" prop="value">
<el-input v-model="form.value" placeholder="请输入值" />
<el-input v-model="form.value" placeholder="请输入值"/>
</el-form-item>
</el-col>
</el-row>
@ -223,6 +229,7 @@
</style>
<script setup name="Model">
import { listModel, 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 modelList = ref([]);
@ -344,12 +351,26 @@ function submitForm() {
proxy.$refs["modelRef"].validate(valid => {
if (valid) {
if (form.value.id != null) {
if(!judgeIfRightValue()){
ElMessageBox.alert('请确认目前的告警限值配置是否合理', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
};
updateModel(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功");
open.value = false;
getList();
});
} else {
if(!judgeIfRightValue()){
ElMessageBox.alert('请确认目前的告警限值配置是否合理', '提示', {
confirmButtonText: '确定',
center: true,
})
return;
};
addModel(form.value).then(response => {
proxy.$modal.msgSuccess("新增成功");
open.value = false;
@ -378,5 +399,28 @@ function handleExport() {
}, `model_${new Date().getTime()}.xlsx`)
}
//
function handleValueChange(row){
let flag = true;
if(modelList.value.length>0){
modelList.value.forEach(item=>{
if(item.sort < row.sort){
if(item.value > row.value){
flag = false;
}
}else if(item.sort > row.sort){
if(item.value < row.value){
flag = false;
}
}
})
}
return flag;
}
function judgeIfRightValue(){
return handleValueChange(form.value);
}
getList();
</script>

132
src/views/model/device/index.vue

@ -1,35 +1,41 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="中台设备编码" prop="centerDeviceCode">
<el-input
v-model="queryParams.centerDeviceCode"
placeholder="请输入中台设备编码"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="通讯来源类型" prop="deviceSource">
<el-select v-model="queryParams.deviceSourceId" placeholder="请选择通讯来源类型" clearable>
<el-option
v-for="dict in dc_device_source"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@change="deviceSourceChange"
/>
</el-select>
</el-form-item>
<el-collapse-transition>
<div v-show="collapseVisible">
<el-row>
<el-col :span="4">
<el-form-item label="中台设备编码" prop="centerDeviceCode">
<el-input
v-model="queryParams.centerDeviceCode"
placeholder="请输入中台设备编码"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="设备名称" prop="deviceName">
<el-input
v-model="queryParams.deviceName"
placeholder="请输入设备名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="通讯来源类型" prop="deviceSource">
<el-select v-model="queryParams.deviceSourceId" placeholder="请选择通讯来源类型" clearable>
<el-option
v-for="dict in dc_device_source"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@change="deviceSourceChange"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="是否可用" prop="enabledFlag">
<el-select v-model="queryParams.enabledFlag" placeholder="请选择是否可用" clearable>
<el-option
@ -40,6 +46,8 @@
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="设备类型" prop="deviceType">
<el-select v-model="queryParams.deviceType" placeholder="请选择设备类型" clearable>
<el-option
@ -50,11 +58,20 @@
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="所属组织名称" prop="orgName">
<el-tree-select v-model="queryParams.orgName" :data="deptOptions"
:props="{ value: 'label', label: 'label', children: 'children' }" value-key="id" placeholder="请选择组织名称"
check-strictly :default-expand-all="true" clearable/>
</el-form-item>
</el-col>
</el-row>
<el-collapse-transition>
<div v-show="collapseVisible">
<el-row>
<el-col :span="4">
<el-form-item label="位置编码" prop="locationCode">
<el-input
v-model="queryParams.locationCode"
@ -63,6 +80,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="位置名称" prop="locationName">
<el-input
v-model="queryParams.locationName"
@ -71,6 +90,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="设备应用范围" prop="deviceClass">
<el-input
v-model="queryParams.deviceClass"
@ -79,14 +100,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="接口名称" prop="apiName">
<el-input
v-model="queryParams.apiName"
placeholder="请输入接口名称"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="服务器地址" prop="serverIp">
<el-input
v-model="queryParams.serverIp"
@ -95,6 +110,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="从属网关ID" prop="gatewayId">
<el-input
v-model="queryParams.gatewayId"
@ -103,6 +120,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="纬度" prop="latValue">
<el-input
v-model="queryParams.latValue"
@ -111,6 +130,10 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="4">
<el-form-item label="经度" prop="lagValue">
<el-input
v-model="queryParams.lagValue"
@ -119,6 +142,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="是否告警" prop="alertEnabled">
<el-select v-model="queryParams.alertEnabled" placeholder="请选择设备类型" clearable>
<el-option
@ -129,31 +154,42 @@
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="设备模型" prop="deviceModelId">
<el-select v-model="queryParams.deviceModelId" placeholder="请选择设备模型id" clearable>
<el-option label="请选择设备模型" value="deviceModelId" />
</el-select>
</el-form-item>
<el-form-item label="租户号" prop="tentantId">
</el-col>
<el-col :span="4">
<el-form-item label="设备分组" prop="deviceGroupId">
<el-select v-model="queryParams.deviceGroupId" placeholder="请选择设备分组ID" clearable>
<el-option label="请添加设备分组" value="" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<!-- <el-form-item label="租户号" prop="tentantId">
<el-input
v-model="queryParams.tentantId"
placeholder="请输入租户号"
clearable
@keyup.enter="handleQuery"
/>
</el-form-item> -->
</el-col>
<el-col :span="4">
<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-button @click="toggleCollapse">{{editName}}</el-button>
</el-form-item>
<el-form-item label="设备分组" prop="deviceGroupId">
<el-select v-model="queryParams.deviceGroupId" placeholder="请选择设备分组ID" clearable>
<el-option label="请添加设备分组" value="" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</div>
</el-collapse-transition>
<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-button @click="toggleCollapse">{{editName}}</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">

Loading…
Cancel
Save