|
|
|
<template>
|
|
|
|
<div class="app-container">
|
|
|
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
|
|
|
|
<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">
|
|
|
|
<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="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" />
|
|
|
|
<el-table-column label="设备名称" align="center" prop="deviceName" :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" 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="handlePolicy(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="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" filterable placeholder="请选择参数" clearable @change="getParamsList">
|
|
|
|
<el-option
|
|
|
|
v-for="item in deviceList"
|
|
|
|
:key="item.uuid"
|
|
|
|
:label="item.deviceName"
|
|
|
|
:value="item.uuid"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item label="告警参数" prop="paramCode">
|
|
|
|
<el-select v-model="form.paramCode" filterable placeholder="请选择参数" clearable @change="setParamsType">
|
|
|
|
<el-option
|
|
|
|
v-for="item in paramsList"
|
|
|
|
:key="item.paramCode"
|
|
|
|
:label="item.paramName"
|
|
|
|
:value="item.paramCode"
|
|
|
|
/>
|
|
|
|
</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>
|
|
|
|
<div class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
<!-- 添加或修改参数值状态策略对话框 -->
|
|
|
|
<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="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"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<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"
|
|
|
|
: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" 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" v-show="statusTypeVisiable">
|
|
|
|
<el-form-item label="状态类型" prop="statusType">
|
|
|
|
<el-select v-model="formPolicy.statusType" placeholder="请选择状态类型">
|
|
|
|
<el-option
|
|
|
|
v-for="item in status"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
</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" @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">
|
|
|
|
<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" @change="handleValueChange(scope.row)"></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-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.methodIds" multiple @change="methodIdsChange" placeholder="请选择告警方式">
|
|
|
|
<el-option
|
|
|
|
v-for="item in methodList"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.methodName"
|
|
|
|
:value="item.id"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="状态值" align="center" prop="statusValue">
|
|
|
|
<template #default="scope">
|
|
|
|
<el-input v-model="scope.row.statusValue"></el-input>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="状态类型" align="center" prop="statusType">
|
|
|
|
<template #default="scope">
|
|
|
|
<el-select v-model="scope.row.statusType" placeholder="请选择状态类型">
|
|
|
|
<el-option
|
|
|
|
v-for="item in status"
|
|
|
|
:key="item.value"
|
|
|
|
:label="item.label"
|
|
|
|
:value="item.value"
|
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
|
|
<div class="dialog-footer">
|
|
|
|
<el-button type="primary" @click="submitFormPolicy">确 定</el-button>
|
|
|
|
<el-button @click="cancelPolicy">取 消</el-button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<style lang="scss" >
|
|
|
|
@import "@/assets/styles/self-defined.scss";
|
|
|
|
</style>
|
|
|
|
<script setup name="Alert">
|
|
|
|
import { getDeviceParamsAlertInfo, listAlert, getAlert, delAlert, addAlert, updateAlert } from "@/api/model/alert";
|
|
|
|
import { listDeviceNoPage } from "@/api/model/device";
|
|
|
|
import { listMethod } from "@/api/model/method";
|
|
|
|
import { listModel } from "@/api/model/alertmodel";
|
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
|
import { listPolicy,listPolicyInfo,updatePolicy,updatePolicyBatch,addPolicy,addPolicyBatch,newDelPolicy, listAlertParamSelect } from "@/api/model/policy";
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
const router = useRouter();
|
|
|
|
const { operator_sign,dc_param_value_type,alert_value } = proxy.useDict('operator_sign','dc_param_value_type','alert_value');
|
|
|
|
const alertList = ref([]);
|
|
|
|
const open = ref(false);
|
|
|
|
const openPolicy = ref(false);
|
|
|
|
const loading = ref(true);
|
|
|
|
const showSearch = ref(true);
|
|
|
|
const ids = ref([]);
|
|
|
|
const total = ref(0);
|
|
|
|
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 boolValueVisiable = ref(false);
|
|
|
|
const statusValueVisiable = ref(false);
|
|
|
|
const statusTypeVisiable = ref(false);
|
|
|
|
const sortIdVisiable = 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 status = ref([
|
|
|
|
{label: '状态1', value: '1', elTagType: 'default', elTagClass: null},
|
|
|
|
{label: '状态2', value: '2', elTagType: 'default', elTagClass: null}
|
|
|
|
]);
|
|
|
|
const data = reactive({
|
|
|
|
form: {},
|
|
|
|
formPolicy: {},
|
|
|
|
queryParams: {
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
deviceUuid: null,
|
|
|
|
paramCode: null,
|
|
|
|
note: null
|
|
|
|
},
|
|
|
|
queryParamsDevice: {
|
|
|
|
deviceUuid: null,
|
|
|
|
},
|
|
|
|
queryParamsParam: {
|
|
|
|
deviceUuid: null,
|
|
|
|
paramCode: null,
|
|
|
|
},
|
|
|
|
queryParamsPolicy:{
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
boolValue: null,
|
|
|
|
endValue: null,
|
|
|
|
alertId: null,
|
|
|
|
statusValue: null,
|
|
|
|
statusType: null,
|
|
|
|
deviceId: null,
|
|
|
|
sortId: null,
|
|
|
|
methodIds: null
|
|
|
|
},
|
|
|
|
queryPolicy:{
|
|
|
|
alertId: null,
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
deviceUuid: [
|
|
|
|
{ required: true, message: "中台设备UUID不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
paramCode: [
|
|
|
|
{ required: true, message: "参数编码不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
},
|
|
|
|
rulesPolicy: {
|
|
|
|
deviceUuid: [
|
|
|
|
{ required: true, message: "中台设备UUID不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
paramCode: [
|
|
|
|
{ required: true, message: "参数编码不能为空", trigger: "blur" }
|
|
|
|
],
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const { queryParamsDevice, queryParamsParam, queryParams, form, rules,queryParamsPolicy,queryPolicy, formPolicy, rulesPolicy } = toRefs(data);
|
|
|
|
|
|
|
|
/** 查询设备告警列表 */
|
|
|
|
function getList() {
|
|
|
|
loading.value = true;
|
|
|
|
getDeviceParamsAlertInfo(queryParams.value).then(response => {
|
|
|
|
alertList.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,
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 表单重置
|
|
|
|
function resetPolicy() {
|
|
|
|
formPolicy.value = {
|
|
|
|
tentantId: null,
|
|
|
|
version: null,
|
|
|
|
createBy: null,
|
|
|
|
createTime: null,
|
|
|
|
updateBy: null,
|
|
|
|
updateTime: null,
|
|
|
|
deptId: null,
|
|
|
|
userId: null,
|
|
|
|
deleteBy: null,
|
|
|
|
deleteTime: 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("policyRef");
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
function handleQuery() {
|
|
|
|
queryParams.value.pageNum = 1;
|
|
|
|
getList();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
function resetQuery() {
|
|
|
|
proxy.resetForm("queryRef");
|
|
|
|
handleQuery();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 多选框选中数据
|
|
|
|
function handleSelectionChange(selection) {
|
|
|
|
selection.forEach(item=>{
|
|
|
|
if(!rowPolicySelected.value.includes(item)){
|
|
|
|
handleValueChange(item);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
rowPolicySelected.value = selection;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
function handleAdd() {
|
|
|
|
reset();
|
|
|
|
getDeviceList();
|
|
|
|
open.value = true;
|
|
|
|
title.value = "添加设备告警";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 维护告警策略 */
|
|
|
|
function handlePolicy(row) {
|
|
|
|
resetPolicy();
|
|
|
|
selectedRows.value=[];
|
|
|
|
deletePolicyRows.value=[];
|
|
|
|
addPolicyRows.value=[];
|
|
|
|
deletePolicyRows.value=[];
|
|
|
|
logicCode.value = row.logicCode;
|
|
|
|
if(row.logicCode=='A'){
|
|
|
|
getModelListSwitch(row);
|
|
|
|
boolValueVisiable.value=true;
|
|
|
|
policyModelVisiable.value=false;
|
|
|
|
statusValueVisiable.value=true;
|
|
|
|
statusTypeVisiable.value=true;
|
|
|
|
sortIdVisiable.value=false;
|
|
|
|
methodIdsVisiable.value=true;
|
|
|
|
}else if(row.logicCode == 'B'){
|
|
|
|
getModelList(row);
|
|
|
|
policyModelVisiable.value=true;
|
|
|
|
boolValueVisiable.value=false;
|
|
|
|
statusValueVisiable.value=false;
|
|
|
|
statusTypeVisiable.value=false;
|
|
|
|
sortIdVisiable.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;
|
|
|
|
policyAlertId.value = row.id;
|
|
|
|
policyDeviceUuid.value = row.deviceUuid;
|
|
|
|
paramTypeValue.value = row.paramType;
|
|
|
|
openPolicy.value = true;
|
|
|
|
title.value = "维护告警策略";
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
function submitForm() {
|
|
|
|
proxy.$refs["alertRef"].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
if (form.value.id != null) {
|
|
|
|
updateAlert(form.value).then(response => {
|
|
|
|
proxy.$modal.msgSuccess("修改成功");
|
|
|
|
open.value = false;
|
|
|
|
getList();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
addAlert(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 delAlert(_ids);
|
|
|
|
}).then(() => {
|
|
|
|
getList();
|
|
|
|
proxy.$modal.msgSuccess("删除成功");
|
|
|
|
}).catch(() => {});
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
function handleExport() {
|
|
|
|
proxy.download('model/alert/export', {
|
|
|
|
...queryParams.value
|
|
|
|
}, `alert_${new Date().getTime()}.xlsx`)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDeviceList(){
|
|
|
|
loading.value = false;
|
|
|
|
listDeviceNoPage(queryParamsDevice.value).then(response => {
|
|
|
|
deviceList.value = response.data;
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getParamsList(deviceUuid){
|
|
|
|
loading.value = true;
|
|
|
|
queryParamsParam.value.deviceUuid = deviceUuid;
|
|
|
|
listAlertParamSelect(queryParamsParam.value).then(response => {
|
|
|
|
paramsList.value = response.data;
|
|
|
|
loading.value = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMethodList(){
|
|
|
|
listMethod().then(response => {
|
|
|
|
methodList.value = response.rows;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//提交到策略信息表
|
|
|
|
function submitFormPolicy() {
|
|
|
|
proxy.$refs["policyRef"].validate(valid => {
|
|
|
|
if (valid) {
|
|
|
|
//根据标志值来判断是否是修改操作
|
|
|
|
if (formPolicy.value.id != null) {
|
|
|
|
//根据参数类型区分
|
|
|
|
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,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 if(logicCode.value == 'A'){
|
|
|
|
updatePolicy(formPolicy.value).then(response => {
|
|
|
|
proxy.$modal.msgSuccess("新增成功");
|
|
|
|
openPolicy.value = false;
|
|
|
|
getList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//根据参数类型区分
|
|
|
|
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 if(logicCode.value == 'A'){
|
|
|
|
addPolicy(formPolicy.value).then(response => {
|
|
|
|
proxy.$modal.msgSuccess("新增成功");
|
|
|
|
openPolicy.value = false;
|
|
|
|
getList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function cancelPolicy() {
|
|
|
|
openPolicy.value = false;
|
|
|
|
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.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;
|
|
|
|
//新增界面初始化
|
|
|
|
}else{
|
|
|
|
formPolicy.value.alertId = row.id;
|
|
|
|
formPolicy.value.deviceId = row.deviceUuid;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//非开关量初始化策略表单
|
|
|
|
function getModelList(row){
|
|
|
|
queryPolicy.value.alertId = row.id;
|
|
|
|
queryPolicy.value.flagEnabled = true;
|
|
|
|
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.alertId = response.data[0].alertId;
|
|
|
|
formPolicy.value.deviceId = response.data[0].deviceId;
|
|
|
|
formPolicy.value.id = response.data[0].id;
|
|
|
|
modelList.value.map(element=>{
|
|
|
|
response.data.forEach(item=>{
|
|
|
|
if(item.alertModelId == element.id){
|
|
|
|
policyDeviceUuid.value = item.deviceId;
|
|
|
|
policyAlertId.value = item.alertId;
|
|
|
|
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.methodIds = item.methodIds.split(',');
|
|
|
|
element.operator = item.operator;
|
|
|
|
element.sort = item.sortId;
|
|
|
|
proxy.$refs.policyTable.toggleRowSelection(element,true);
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//新增表单映射
|
|
|
|
function mapFormTable(){
|
|
|
|
const policyTableRows = proxy.$refs.policyTable.getSelectionRows();
|
|
|
|
policyParams.value=[];
|
|
|
|
policyTableRows.forEach(item=>{
|
|
|
|
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;
|
|
|
|
policyParams.value.push(policyParam);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//修改表单映射
|
|
|
|
function mapFormTableUpdate(){
|
|
|
|
const policyTableRows = proxy.$refs.policyTable.getSelectionRows();
|
|
|
|
policyParams.value=[];
|
|
|
|
policyTableRows.forEach(item=>{
|
|
|
|
let policyParam = {};
|
|
|
|
policyParam.id = item.id;
|
|
|
|
policyParam.deviceId = policyDeviceUuid.value;
|
|
|
|
policyParam.alertId = item.alertId;
|
|
|
|
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.methodIds = item.methodIds.join(',');
|
|
|
|
policyParam.operator = item.operator;
|
|
|
|
policyParam.sortId = item.sort;
|
|
|
|
policyParams.value.push(policyParam);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRowKey(row){
|
|
|
|
// 返回行的唯一标识符
|
|
|
|
// 这里使用 id 作为唯一标识符,你可以根据实际情况进行修改
|
|
|
|
return row.id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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){
|
|
|
|
policyParams.value = policyParams.value.filter(element=>{
|
|
|
|
return item.id === element.id
|
|
|
|
})
|
|
|
|
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){
|
|
|
|
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 setParamsType(val){
|
|
|
|
paramsList.value.forEach(item=>{
|
|
|
|
if(item.paramCode == val){
|
|
|
|
form.value.paramType = item.paramType;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断限值后一项值要比前一项小
|
|
|
|
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();
|
|
|
|
|
|
|
|
</script>
|