You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

777 lines
22 KiB
Vue

2 years ago
<template>
2 years ago
<div class="alarmHandBox">
<div class="searchMain">
<div class="searchBox">
<el-form :inline="true" :model="formdata" class="demo-form-inline">
2 years ago
<el-form-item label="电压等级" class="dybox">
2 years ago
<el-select v-model="formdata.dyId" @change="getSearchxl">
<el-option
v-for="item in dyOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
2 years ago
<el-form-item label="线路名称" class="xlbox">
<el-select
v-model="formdata.lineId"
@change="getSearchgt"
filterable
>
<el-option
v-for="item in xlOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="杆塔名称">
<el-select v-model="formdata.towerId" filterable>
<el-option
v-for="item in gtOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="开始日期">
2 years ago
<!-- <el-date-picker
v-model="formdata.timeVal"
type="datetimerange"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="timestamp"
2 years ago
></el-date-picker> -->
<el-date-picker
v-model="formdata.starttime"
type="datetime"
placeholder="开始日期"
value-format="timestamp"
>
2 years ago
</el-date-picker>
</el-form-item>
<el-form-item label="结束日期">
2 years ago
<el-date-picker
v-model="formdata.endtime"
type="datetime"
2 years ago
default-time="23:59:59"
2 years ago
placeholder="结束日期"
value-format="timestamp"
class="ml10"
>
2 years ago
</el-date-picker>
</el-form-item>
2 years ago
<el-form-item label="告警原因" class="gjbox">
2 years ago
<el-select v-model="formdata.label">
2 years ago
<el-option
v-for="item in gjOptions"
2 years ago
:key="item.label"
2 years ago
:label="item.name"
2 years ago
:value="item.label"
2 years ago
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit"></el-button>
</el-form-item>
</el-form>
2 years ago
</div>
2 years ago
2 years ago
<div class="alarmContain" v-loading="loading">
<div class="alarmTable">
<el-table
ref="multipleTable"
:data="tableData"
stripe
border
tooltip-effect="dark"
style="width: 100%"
@selection-change="handleSelectionChange"
height="calc(100% - 40px)"
@row-click="handleRowClick"
2 years ago
highlight-current-row
2 years ago
>
<el-table-column min-width="45" label="序号">
<template slot-scope="scope">
<span>{{ (page - 1) * pageSize + scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column
prop="alarmTime"
label="告警时间"
min-width="135"
:show-overflow-tooltip="true"
:formatter="dateFormat"
>
</el-table-column>
2 years ago
2 years ago
<!-- <el-table-column
prop="dyLevel"
label="电压等级"
2 years ago
min-width="75"
:show-overflow-tooltip="true"
>
2 years ago
</el-table-column> -->
<el-table-column
prop="lineName"
label="线路名称"
min-width="105"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column
2 years ago
prop="towerName"
label="杆塔名称"
2 years ago
min-width="145"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column
2 years ago
prop="displayName"
label="设备名称"
2 years ago
min-width="145"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column
label="通道"
2 years ago
min-width="75"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">{{
scope.row.alias !== null && scope.row.alias !== ""
? scope.row.alias
: scope.row.channnelName
}}</template>
</el-table-column>
<!-- <el-table-column
2 years ago
prop="termId"
label="设备编号"
min-width="75"
:show-overflow-tooltip="true"
>
2 years ago
</el-table-column> -->
<el-table-column
2 years ago
prop="enname"
label="告警原因"
min-width="155"
:show-overflow-tooltip="true"
>
</el-table-column>
2 years ago
<el-table-column label="是否已读" min-width="95" fixed="right">
<template slot-scope="scope">
2 years ago
<span v-if="scope.row.isread == 1" class="readbox">[]</span>
2 years ago
<span v-if="scope.row.isread == 0">[]</span>
</template>
</el-table-column>
</el-table>
<div class="pageNation">
<el-pagination
@current-change="handleCurrentChange"
2 years ago
@size-change="handleSizeChange"
:current-page="page"
:page-size="pageSize"
2 years ago
layout="sizes, prev, pager, next, jumper,total"
:total="total"
>
</el-pagination>
</div>
2 years ago
</div>
<div class="alarmPic">
<div
class="imgshow"
v-loading="alarmLoading"
@click="handleBigPicbox(selectRow)"
>
<!-- @click="handleBigPicbox(selectRow)" -->
2 years ago
<div
class="picshow"
v-if="selectRow.path !== '' && tableData.length !== 0"
>
<!-- <div
class="nosee"
:style="'backgroundImage:url(' + photoPic + '!1280x720)'"
></div>
<viewer :options="OptionssalseImg" class="bigimgView">
<img
@load="imgOnload"
ref="picJpg"
class="animImg"
:src="photoPic + '!1280x720'"
/>
</viewer> -->
<img
ref="picJpg"
class="animImg"
2 years ago
@load="imgOnload"
:src="photoPic + '!1280x720'"
/>
2 years ago
<canvas id="myCanvas" class="myCanvas" ref="myCanvas"></canvas>
</div>
<img
ref="picJpg"
2 years ago
src="../../assets/img/nopic.jpg"
v-if="selectRow.path == '' || tableData.length == 0"
/>
2 years ago
</div>
<div class="editorBtn">
<el-button
type="primary"
:loading="btnpicloading"
@click="handleCommandpic"
2 years ago
:disabled="tableData.length == 0"
>主动拍照</el-button
>
2 years ago
<el-button
type="primary"
@click="handleHistory"
:disabled="tableData.length == 0"
>历史图片</el-button
>
</div>
2 years ago
</div>
2 years ago
</div>
2 years ago
</div>
2 years ago
<!-- 点击出现大图 -->
<div
v-if="showBigpic"
class="showPic"
@click="closePic"
v-loading="canvasloading"
>
2 years ago
<div class="picboxI">
<img @load="imgOnload" class="maskPic" :src="bigPhotoPic" />
<canvas id="myCanvas" class="myCanvas" ref="myCanvas2"></canvas>
</div>
<div class="viewClose">
<i @click="closePic" class="el-icon-close"></i>
2 years ago
</div>
</div>
<historyimg ref="historyimg_ref"></historyimg>
2 years ago
</div>
2 years ago
</template>
<script>
2 years ago
import {
getSearchInfo,
getAlarmList,
2 years ago
getAlarmTypeList,
2 years ago
getLatestPhotoJoggle,
getReturnedPhotoJoggle,
readAlarm,
} from "@/utils/api/index";
import historyimg from "./components/historyimg.vue";
2 years ago
import moment from "moment";
2 years ago
export default {
components: {
historyimg,
},
2 years ago
data() {
return {
OptionssalseImg: {
inline: false,
button: true,
navbar: false,
title: false,
toolbar: false,
tooltip: false,
zoomable: true,
url: "src",
},
2 years ago
dyOptions: [{ id: -1, name: "全部" }], //电压数据
xlOptions: [{ id: -1, name: "全部" }], //线路数据
gtOptions: [{ id: -1, name: "全部" }], //杆塔数据
gjOptions: [{ id: -1, label: -1, name: "全部" }], //告警数据
formdata: {
2 years ago
dyId: -1,
lineId: -1,
towerId: -1,
2 years ago
label: -1,
2 years ago
// timeVal: "",
},
2 years ago
photoPic: "",
tableData: [],
multipleSelection: [],
page: 1, // 当前页数
pageSize: 20, // 每页数量
total: 0, //总条数
2 years ago
loading: false,
btnpicloading: false,
timer: null,
2 years ago
i: 0,
2 years ago
isreadshow: false,
2 years ago
showBigpic: false,
2 years ago
textInfo: "",
2 years ago
bigPhotoPic: "", //大图路径
2 years ago
selectRow: {},
alarmLoading: false,
canvasloading: false,
2 years ago
};
},
2 years ago
mounted() {
2 years ago
// this.$set(this.formdata, "timeVal", [
// new Date(new Date().toLocaleDateString()).getTime(),
// new Date().getTime(),
// ]);
this.$set(
this.formdata,
"starttime",
new Date(new Date().toLocaleDateString()).getTime()
);
2 years ago
this.$set(this.formdata, "endtime", new Date().getTime());
2 years ago
this.getSearchdy();
2 years ago
this.getTableList();
2 years ago
},
2 years ago
methods: {
2 years ago
handleBigPicbox(val) {
this.canvasloading = true;
if (val.path !== "" && this.tableData.length !== 0) {
console.log(val);
this.bigPhotoPic = val.path;
this.showBigpic = true;
this.$nextTick(() => {
this.drawline2(val);
});
}
2 years ago
},
closePic() {
this.showBigpic = false;
},
2 years ago
//获取电压信息
getSearchdy() {
getSearchInfo({ type: 1 })
.then((res) => {
this.dyOptions = this.dyOptions.concat(res.data.list);
this.formdata.dyId = this.dyOptions[0].id;
this.getSearchxl();
})
.catch((err) => {});
},
//获取线路数据
getSearchxl() {
getSearchInfo({ type: 2, id: this.formdata.dyId })
.then((res) => {
2 years ago
this.xlOptions = [{ id: -1, name: "全部" }];
2 years ago
this.xlOptions = this.xlOptions.concat(res.data.list);
this.formdata.lineId = this.xlOptions[0].id;
this.getSearchgt();
})
.catch((err) => {});
},
//获取杆塔数据
getSearchgt() {
getSearchInfo({ type: 3, id: this.formdata.lineId })
.then((res) => {
2 years ago
this.gtOptions = [{ id: -1, name: "全部" }];
2 years ago
this.gtOptions = this.gtOptions.concat(res.data.list);
this.formdata.towerId = this.gtOptions[0].id;
this.getSearchgj();
2 years ago
})
.catch((err) => {});
},
//获取告警原因
getSearchgj() {
2 years ago
getAlarmTypeList()
2 years ago
.then((res) => {
2 years ago
this.gjOptions = [{ id: -1, label: -1, name: "全部" }];
2 years ago
this.gjOptions = this.gjOptions.concat(res.data.list);
2 years ago
console.log(this.gjOptions);
this.formdata.label = this.gjOptions[0].label;
console.log(this.formdata.label);
2 years ago
})
.catch((err) => {});
2 years ago
},
2 years ago
//获取数据
2 years ago
getTableList() {
2 years ago
this.loading = true;
2 years ago
this.$set(this.formdata, "pageindex", this.page);
this.$set(this.formdata, "pagesize", this.pageSize);
2 years ago
// this.$set(this.formdata, "starttime", this.formdata.timeVal[0]);
// this.$set(this.formdata, "endtime", this.formdata.timeVal[1]);
2 years ago
getAlarmList(this.formdata)
.then((res) => {
2 years ago
this.loading = false;
2 years ago
this.tableData = res.data.list;
this.total = res.data.total;
2 years ago
this.photoPic = res.data.list[0].path;
2 years ago
this.selectRow = res.data.list[0];
console.log(this.selectRow);
2 years ago
// 别忘了标签上定义ref 这里的 myTable就说获取的标签上的ref命的名
this.$refs.multipleTable.setCurrentRow(this.selectRow);
this.handleRowClick(this.selectRow);
2 years ago
})
.catch((err) => {
console.log(err);
});
},
//查询
onSubmit() {
2 years ago
if (this.formdata.starttime > this.formdata.endtime) {
return this.$message({
duration: 1500,
showClose: true,
message: "开始日期不能大于结束日期",
type: "warning",
});
2 years ago
}
2 years ago
this.getTableList();
2 years ago
},
2 years ago
handleSelectionChange(val) {
this.multipleSelection = val;
2 years ago
},
2 years ago
//点击分页
handleCurrentChange(val) {
this.page = val;
this.getTableList();
},
//每页条数
handleSizeChange(val) {
this.pageSize = val;
this.getTableList();
},
2 years ago
//绘制告警区域
drawline(data) {
this.canvas = this.$refs.myCanvas;
this.imgpic = this.$refs.picJpg;
this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; //设置画布大小
this.canvas.height = this.imgpic.offsetHeight; //设置画布大小
this.ctx = this.canvas.getContext("2d");
this.ctx.beginPath();
//设置线条颜色,必须放在绘制之前
this.ctx.strokeStyle = "#ff0000";
// 线宽设置,必须放在绘制之前
this.ctx.lineWidth = 1;
// 绘制矩形
var scaleX = this.canvas.width / data.photoWidth, //this.iw图片的宽
scaleY = this.canvas.height / data.photoHeight; //this.ih图片的高
console.log(scaleX, scaleY);
var top = data.x * scaleX,
left = data.y * scaleY,
width = data.width * scaleX,
height = data.height * scaleY;
console.log(top, left, width, height);
// this.ctx.strokeStyle = "red"; //线的颜色
this.ctx.strokeRect(top, left, width, height); //绘制路径矩形
//this.ctx.strokeRect(data.x, data.y, data.width, data.height);
2 years ago
this.ctx.font = "24px normal";
2 years ago
this.ctx.fillStyle = "#ff0000";
this.ctx.fillText(this.textInfo, top, left + 24);
this.ctx.closePath();
this.ctx.stroke();
},
//绘制告警区域
drawline2(data) {
this.canvas = this.$refs.myCanvas2;
this.imgpic = this.$refs.picJpg;
this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; //设置画布大小
this.canvas.height = this.imgpic.offsetHeight; //设置画布大小
this.ctx = this.canvas.getContext("2d");
this.ctx.beginPath();
//设置线条颜色,必须放在绘制之前
this.ctx.strokeStyle = "#ff0000";
// 线宽设置,必须放在绘制之前
this.ctx.lineWidth = 1;
// 绘制矩形
var scaleX = this.canvas.width / data.photoWidth, //this.iw图片的宽
scaleY = this.canvas.height / data.photoHeight; //this.ih图片的高
console.log(scaleX, scaleY);
var top = data.x * scaleX,
left = data.y * scaleY,
width = data.width * scaleX,
height = data.height * scaleY;
console.log(top, left, width, height);
// this.ctx.strokeStyle = "red"; //线的颜色
this.ctx.strokeRect(top, left, width, height); //绘制路径矩形
//this.ctx.strokeRect(data.x, data.y, data.width, data.height);
this.ctx.font = "24px normal";
this.ctx.fillStyle = "#ff0000";
this.ctx.fillText(this.textInfo, top, left + 24);
this.ctx.closePath();
this.ctx.stroke();
},
2 years ago
//点击当前行
2 years ago
handleRowClick(row) {
//this.$refs.multipleTable.toggleRowSelection(row);
2 years ago
console.log(this.$refs.picJpg.complete);
this.alarmLoading = true;
2 years ago
this.photoPic = row.path;
2 years ago
2 years ago
this.selectRow = row;
2 years ago
//未读变已读
2 years ago
if (row.isread == 0) {
setTimeout(function () {
readAlarm({
id: row.id,
2 years ago
})
.then((res) => {
console.log(res);
row.isread = 1;
console.log(row.isread);
})
.catch((err) => {
console.log(err);
});
}, 300);
2 years ago
}
2 years ago
2 years ago
this.$nextTick(() => {
this.drawline(row);
2 years ago
this.imgOnload();
2 years ago
});
2 years ago
},
//手动拍照
handleCommandpic() {
this.btnpicloading = true;
getLatestPhotoJoggle({
captureType: 0,
channel: this.selectRow.channelId,
termId: this.selectRow.termId,
preset: 255,
}).then((res) => {
2 years ago
this.$message({
duration: 1500,
2 years ago
showClose: true,
message: "手动拍照请求成功!",
type: "success",
});
this.timer = window.setInterval(() => {
this.newPicApi(res.data);
2 years ago
this.i++;
}, 5000);
});
},
//获取最新图片
newPicApi(val) {
getReturnedPhotoJoggle({
photoTime: val,
termId: this.selectRow.termId,
}).then((res) => {
if (res.data == true && this.i < 10) {
clearInterval(this.timer);
this.timer = null;
this.i = 0;
this.btnpicloading = false;
this.$notify({
title: "通知信息",
message: "已返回最新图片",
type: "success",
position: "bottom-right",
});
} else if (res.data == false && this.i > 10) {
clearInterval(this.timer);
this.timer = null;
this.i = 0;
this.btnpicloading = false;
this.$notify({
title: "通知信息",
message: "装置暂无响应,请稍后再试!",
type: "warning",
position: "bottom-right",
});
}
});
},
//历史图片
handleHistory() {
this.$refs.historyimg_ref.display();
this.$refs.historyimg_ref.getdataform(this.selectRow);
},
2 years ago
dateFormat(row, column) {
var date = row[column.property];
if (date == undefined) {
return "";
}
return moment(date).format("YYYY-MM-DD HH:mm:ss");
},
2 years ago
imgOnload() {
console.log("加载完成");
this.alarmLoading = false;
this.canvasloading = false;
},
2 years ago
},
2 years ago
};
</script>
2 years ago
<style lang="less">
2 years ago
.alarmHandBox {
2 years ago
width: calc(100% - 24px);
height: calc(100% - 24px);
padding: 12px 12px;
2 years ago
background: #ffffff;
2 years ago
.showPic {
position: fixed;
background-color: rgba(0, 0, 0, 50%);
bottom: 0;
left: 0;
overflow: hidden;
right: 0;
top: 0;
z-index: 9999;
display: flex;
cursor: pointer;
.picboxI {
position: relative;
max-width: 1280px;
max-height: 720px;
margin: auto;
animation-name: scaleDraw;
/*关键帧名称*/
animation-timing-function: ease;
/*动画的速度曲线*/
animation-iteration-count: 1;
/*动画播放的次数*/
animation-duration: 0.65s;
img {
2 years ago
max-width: 1280px;
max-height: 720px;
2 years ago
margin: auto;
}
2 years ago
.myCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
}
.viewClose {
-webkit-app-region: no-drag;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 50%;
cursor: pointer;
height: 80px;
overflow: hidden;
position: absolute;
right: -40px;
top: -40px;
transition: background-color 0.15s;
width: 80px;
.el-icon-close {
bottom: 16px;
left: 16px;
2 years ago
position: absolute;
color: #fff;
font-size: 18px;
2 years ago
}
}
}
.searchMain {
border: 1px solid #dddddd;
2 years ago
height: calc(100% - 22px);
max-height: calc(100% - 22px);
padding: 12px;
border-radius: 4px;
2 years ago
.searchBox {
.ml10 {
2 years ago
margin-left: 10px;
}
2 years ago
.el-form {
.dybox {
.el-form-item__content {
width: 120px;
}
}
.xlbox {
.el-form-item__content {
width: 160px;
}
}
.gjbox {
.el-form-item__content {
width: 140px;
}
}
}
}
}
2 years ago
.alarmTop {
padding: 0px 8px 16px 8px;
2 years ago
}
.alarmContain {
display: flex;
2 years ago
height: calc(100% - 90px);
2 years ago
padding: 0px 8px;
.alarmTable {
width: 50%;
height: 100%;
2 years ago
.el-table__body tr {
cursor: pointer;
}
.el-table__body tr.current-row > td {
background-color: rgba(18, 128, 113, 0.2);
}
2 years ago
.readbox {
color: #e49e61;
}
2 years ago
}
2 years ago
.pageNation {
margin-top: 8px;
2 years ago
justify-content: flex-start;
2 years ago
}
.alarmPic {
width: 50%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
.imgshow {
width: 100%;
height: 100%;
2 years ago
position: relative;
2 years ago
.picshow {
width: 100%;
height: 100%;
position: relative;
}
.nosee {
position: absolute;
width: 100%;
height: 100%;
background-size: 100% 100%;
z-index: 2;
}
.bigimgView {
position: absolute;
width: 100%;
height: 100%;
z-index: 3;
opacity: 0;
}
2 years ago
img {
width: 100%;
height: 100%;
2 years ago
}
2 years ago
.myCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
cursor: pointer;
z-index: 2;
2 years ago
}
2 years ago
}
.editorBtn {
margin-top: 8px;
// border: 1px solid @border-color-base;
padding-top: 5px;
// border-radius: 4px;
2 years ago
}
.editorBtn {
display: flex;
justify-content: flex-start;
}
2 years ago
}
2 years ago
}
2 years ago
}
2 years ago
</style>