jc1.0
fanluyan 1 year ago
parent a3d432ae57
commit ada3d9825f

@ -695,3 +695,15 @@ export function listComparatorApi(data) {
}, },
}); });
} }
//告警信息
export function warningListApi(data) {
return request({
url: "/warning/list",
method: "get",
params: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
},
});
}

@ -7,7 +7,6 @@
width="520px" width="520px"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
{{ this.sensorId }}
<el-form <el-form
label-position="left" label-position="left"
ref="formInfo" ref="formInfo"
@ -130,9 +129,9 @@ export default {
compareOptions: [], // compareOptions: [], //
operatorValOptions: [], // operatorValOptions: [], //
riskLevelOption: [ riskLevelOption: [
{ id: 0, name: "高" }, { id: 2, name: "高" },
{ id: 1, name: "中" }, { id: 1, name: "中" },
{ id: 2, name: "低" }, { id: 0, name: "低" },
], ],
rules: { rules: {
@ -355,7 +354,7 @@ export default {
thresholdL: "", thresholdL: "",
thresholdR: "", thresholdR: "",
riskLevelVal: 0, // riskLevelVal: 0, //
state: false, state: 1,
}; };
}, },
}, },

@ -0,0 +1,306 @@
<template>
<div class="copyrulesBox">
<el-dialog
class="rulesDialogBox"
:title="title"
:visible.sync="rulesDialogshow"
width="520px"
:close-on-click-modal="false"
>
<div class="copyBox" v-loading="deviceLoading">
<div class="rulesRow">
<el-descriptions size="mini" border v-if="rulesData">
<el-descriptions-item label="属性名称:">{{
rulesData.typePoint.fieldDesc
}}</el-descriptions-item>
<el-descriptions-item label="比较器">{{
rulesData.comparatorDesc
}}</el-descriptions-item>
<el-descriptions-item label="触发条件">{{
rulesData.operatorDesc
}}</el-descriptions-item>
<el-descriptions-item label="阈值">
{{ rulesData.threshold }}
</el-descriptions-item>
<el-descriptions-item label="状态">
<span v-if="rulesData.active == 0"
><el-tag type="danger">停用</el-tag>
</span>
<span v-else> <el-tag type="success">启用</el-tag> </span>
</el-descriptions-item>
<el-descriptions-item label="告警等级"
><span v-if="rulesData.level == 2"
><el-tag type="danger"></el-tag>
</span>
<span v-else-if="rulesData.level == 1">
<el-tag type="warning"></el-tag>
</span>
<span v-else-if="rulesData.level == 0">
<el-tag type="info"></el-tag>
</span></el-descriptions-item
>
</el-descriptions>
</div>
<el-checkbox
v-model="isAllSelected"
:indeterminate="isIndeterminate"
@change="handleAllCheck"
>全选</el-checkbox
>
<el-checkbox-group
v-model="selectedDeviceNames"
@change="handleDeviceCheck"
>
<el-checkbox
v-for="device in deviceList"
:key="device.id"
:label="device.name"
:disabled="device.id == sensorId"
></el-checkbox>
</el-checkbox-group>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="hide"> </el-button>
<el-button type="primary" @click="submitForm()"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { monitoringListApi, AlarmRulesAddRules } from "@/utils/api/index";
export default {
props: ["title", "typeId", "sensorId"],
data() {
return {
formInfo: {},
deviceLoading: false,
rulesDialogshow: false,
rulesData: "",
deviceList: [],
isAllSelected: false, // /
selectedDeviceNames: [], //
};
},
computed: {
//
isIndeterminate() {
//
const selectedNames = this.selectedDeviceNames;
const enabledDevices = this.deviceList.filter(
(device) => device.id !== this.sensorId
);
//
if (
selectedNames.length === 0 ||
selectedNames.length === enabledDevices.length
) {
return false;
}
//
const enabledSelectedNames = enabledDevices
.map((device) => device.name)
.filter((name) => selectedNames.includes(name));
//
return (
enabledSelectedNames.length > 0 &&
enabledSelectedNames.length < enabledDevices.length
);
},
},
created() {},
mounted() {},
watch: {},
methods: {
//
getdataform(val) {
console.log(val);
this.rulesData = val;
if (val.operator == "BTW" || val.operator == "NTW") {
console.log("wossssssssss", val.active);
const thresholdValues = val.threshold.split(",");
this.formInfo = {
attribute: val.modevtypePointId,
compareVal: val.comparator, //
operatorVal: val.operator, //
thresholdL: thresholdValues[0],
thresholdR: thresholdValues[1],
riskLevelVal: val.level, //
state: val.active,
};
console.log(this.formInfo);
} else {
this.formInfo = {
attribute: val.modevtypePointId,
compareVal: val.comparator, //
operatorVal: val.operator, //
threshold: val.threshold, //
riskLevelVal: val.level, //
state: val.active,
};
}
},
//typeId
getNsensorList() {
this.deviceLoading = true;
monitoringListApi({ typeId: this.typeId, pageNum: 1, pageSize: 1000 })
.then((res) => {
console.log(res);
this.deviceLoading = false;
this.deviceList = res.data.content;
})
.catch((err) => {
console.log(err); //
});
},
// /
handleAllCheck(val) {
//
const enabledDevices = this.deviceList.filter(
(device) => device.id !== this.sensorId
);
this.selectedDeviceNames = val
? enabledDevices.map((device) => device.name)
: [];
//
this.isAllSelected =
val && enabledDevices.length === this.selectedDeviceNames.length;
//
this.isIndeterminate =
val &&
enabledDevices.length > 0 &&
enabledDevices.length !== this.selectedDeviceNames.length;
},
//
handleDeviceCheck(value) {
//
const enabledDevices = this.deviceList.filter(
(device) => device.id !== this.sensorId
);
//
this.isAllSelected =
enabledDevices.length === value.length &&
value.length ===
enabledDevices
.map((device) => device.name)
.filter((name) => value.includes(name)).length;
//
this.isIndeterminate =
enabledDevices.length > 0 &&
value.length > 0 &&
value.length < enabledDevices.length;
},
submitForm() {
const selectedDevices = this.deviceList.filter((device) => {
return this.selectedDeviceNames.includes(device.name);
});
//
console.log(selectedDevices);
for (let i = 0; i < selectedDevices.length; i++) {
console.log(selectedDevices[i].id); // ID
let params = {};
if (
this.formInfo.operatorVal == "BTW" ||
this.formInfo.operatorVal == "NTW"
) {
let thresholdVal = `${this.formInfo.thresholdL.trim()},${this.formInfo.thresholdR.trim()}`;
params = {
sensorId: selectedDevices[i].id, // 使ID
modevtypePointId: this.formInfo.attribute,
comparator: this.formInfo.compareVal,
operator: this.formInfo.operatorVal,
threshold: thresholdVal,
level: this.formInfo.riskLevelVal,
active: this.formInfo.state, //
};
} else {
params = {
sensorId: selectedDevices[i].id, // 使ID
modevtypePointId: this.formInfo.attribute,
comparator: this.formInfo.compareVal,
operator: this.formInfo.operatorVal,
threshold: this.formInfo.threshold,
level: this.formInfo.riskLevelVal,
active: this.formInfo.state, //
};
}
// AlarmRulesAddRules params
AlarmRulesAddRules(params)
.then((res) => {
if (res.success) {
this.$message({
duration: 1500,
showClose: true,
message: "添加成功",
type: "success",
});
this.hide();
// this.hide() this.$parent.getRules()
} else {
this.$message({
duration: 1500,
showClose: true,
message: res.errorMsg,
type: "error",
});
}
})
.catch((err) => {
//
console.error(err);
this.$message({
duration: 1500,
showClose: true,
message: "添加失败:" + (err.message || "未知错误"),
type: "error",
});
});
}
},
display() {
this.rulesDialogshow = true;
this.getNsensorList();
},
hide() {
this.rulesDialogshow = false;
this.deviceList = [];
this.selectedDeviceNames = [];
},
},
};
</script>
<style lang="less">
.copyrulesBox {
.rulesDialogBox {
.el-dialog__body {
padding: 10px 20px;
}
.copyBox {
height: 400px;
overflow: auto;
.rulesRow {
margin-bottom: 12px;
}
.el-checkbox-group {
display: flex;
flex-direction: column;
.el-checkbox {
height: 32px;
line-height: 32px;
}
}
}
}
}
</style>

@ -48,9 +48,9 @@
<el-table-column prop="id" label="ID" width="50"> </el-table-column> <el-table-column prop="id" label="ID" width="50"> </el-table-column>
<el-table-column prop="typePoint.fieldDesc" label="属性名称"> <el-table-column prop="typePoint.fieldDesc" label="属性名称">
</el-table-column> </el-table-column>
<el-table-column prop="comparatorDesc" label="选择器"> <el-table-column prop="comparatorDesc" label="比较器">
</el-table-column> </el-table-column>
<el-table-column prop="operatorDesc" label="选择符"> <el-table-column prop="operatorDesc" label="触发条件">
</el-table-column> </el-table-column>
<el-table-column prop="threshold" label="阈值"> </el-table-column> <el-table-column prop="threshold" label="阈值"> </el-table-column>
<el-table-column prop="active" label="状态"> <el-table-column prop="active" label="状态">
@ -63,18 +63,19 @@
</el-table-column> </el-table-column>
<el-table-column prop="level" label="告警等级"> <el-table-column prop="level" label="告警等级">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.level == 0" <span v-if="scope.row.level == 2"
><el-tag type="danger"></el-tag> ><el-tag type="danger"></el-tag>
</span> </span>
<span v-else-if="scope.row.level == 1"> <span v-else-if="scope.row.level == 1">
<el-tag type="warning"></el-tag> <el-tag type="warning"></el-tag>
</span> </span>
<span v-else-if="scope.row.level == 2"> <span v-else-if="scope.row.level == 0">
<el-tag type="info"></el-tag> <el-tag type="info"></el-tag>
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="lastDTime" label="最后数据时间">
</el-table-column>
<el-table-column label="操作" class-name="editClass" width="260px"> <el-table-column label="操作" class-name="editClass" width="260px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-link <el-link
@ -84,7 +85,13 @@
icon="el-icon-document" icon="el-icon-document"
>编辑</el-link >编辑</el-link
> >
<el-link
type="primary"
@click="handleCopyClick(scope.row)"
size="small"
icon="el-icon-document"
>复制规则</el-link
>
<el-link <el-link
type="danger" type="danger"
@click="handleDeleteClick(scope.row)" @click="handleDeleteClick(scope.row)"
@ -107,11 +114,17 @@
:modevtype="modevtypeVal" :modevtype="modevtypeVal"
:sensorId="sensorIdVal" :sensorId="sensorIdVal"
></addRules> ></addRules>
<copyRules
ref="copyRulesRef"
:title="title"
:typeId="typeIdVal"
:sensorId="sensorIdVal"
></copyRules>
</div> </div>
</template> </template>
<script> <script>
import addRules from "./components/addRules"; import addRules from "./components/addRules";
import copyRules from "./components/copyRules";
import { import {
getParamTreeApi, getParamTreeApi,
AlarmRulesListApi, AlarmRulesListApi,
@ -121,6 +134,7 @@ export default {
name: "alarmRules", name: "alarmRules",
components: { components: {
addRules, addRules,
copyRules,
}, },
data() { data() {
return { return {
@ -141,6 +155,7 @@ export default {
rulesListLoading: false, rulesListLoading: false,
title: "", title: "",
sensorIdVal: "", sensorIdVal: "",
typeIdVal: "",
}; };
}, },
watch: {}, watch: {},
@ -179,6 +194,7 @@ export default {
this.currentNodeKey = data.id; this.currentNodeKey = data.id;
this.modevtypeVal = data.typeId; this.modevtypeVal = data.typeId;
this.sensorIdVal = data.id; this.sensorIdVal = data.id;
this.typeIdVal = data.typeId;
this.getRules(); this.getRules();
}, },
// //
@ -208,6 +224,12 @@ export default {
this.$refs.addRulesRef.display(); this.$refs.addRulesRef.display();
this.$refs.addRulesRef.getdataform(data); this.$refs.addRulesRef.getdataform(data);
}, },
//
handleCopyClick(data) {
this.title = "复制规则";
this.$refs.copyRulesRef.display();
this.$refs.copyRulesRef.getdataform(data);
},
// //
handleDeleteClick(data) { handleDeleteClick(data) {
this.$confirm("确定要删除该规则吗?", "提示", { this.$confirm("确定要删除该规则吗?", "提示", {

@ -44,6 +44,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

@ -43,6 +43,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

@ -44,6 +44,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

@ -74,6 +74,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

@ -43,6 +43,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

@ -15,9 +15,14 @@
> >
<el-table-column align="center" prop="warnTime" label="报警时间"> <el-table-column align="center" prop="warnTime" label="报警时间">
</el-table-column> </el-table-column>
<el-table-column align="center" prop="deviceName" label="设备名称"> <el-table-column align="center" prop="sensorId" label="设备名称">
</el-table-column> </el-table-column>
<el-table-column align="center" prop="warnDesc" label="告警信息"> <el-table-column
align="center"
prop="warnDesc"
label="告警信息"
min-width="200"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip <el-tooltip
class="item" class="item"
@ -29,29 +34,24 @@
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" prop="warningCount" label="告警次数"> <el-table-column align="center" prop="warnLevel" label="告警等级">
</el-table-column>
<el-table-column align="center" prop="warningValue" label="当前值">
</el-table-column>
<el-table-column align="center" prop="threadval" label="告警阈值">
</el-table-column>
<el-table-column align="center" label="操作" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <span v-if="scope.row.warnLevel == 2"> </span>
@click.native.prevent="particulars(scope.$index, scope.row)" <span v-else-if="scope.row.warnLevel == 1"> </span>
type="text" <span v-else-if="scope.row.warnLevel == 0"> </span>
size="small"
>
查看详情
</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" prop="warnValue" label="当前值">
</el-table-column>
<el-table-column align="center" prop="threshold" label="告警阈值">
</el-table-column>
</el-table> </el-table>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { warningListApi } from "@/utils/api/index";
export default { export default {
name: "warnmessage", name: "warnmessage",
components: {}, components: {},
@ -61,9 +61,22 @@ export default {
tableData: [], tableData: [],
}; };
}, },
created() {}, created() {
this.getwarnList();
},
mounted() {}, mounted() {},
methods: {}, methods: {
getwarnList() {
warningListApi()
.then((res) => {
console.log(res);
this.tableData = res.data.content;
})
.catch((err) => {
console.log(err); //
});
},
},
}; };
</script> </script>
@ -115,6 +128,9 @@ export default {
.el-table__empty-text { .el-table__empty-text {
color: #fff; color: #fff;
} }
.el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
background-color: rgba(255, 27, 27, 0.2);
}
.el-table::before { .el-table::before {
height: 0; height: 0;
} }

@ -43,6 +43,11 @@ export default {
"154,96,180", "154,96,180",
"234,124,204", "234,124,204",
"3,188,255", "3,188,255",
"241,113,175",
"180,191,23",
"151,225,137",
"240,23,181",
"125,20,22",
], ],
stime: "", stime: "",
eTime: "", eTime: "",

Loading…
Cancel
Save