411 lines
9.3 KiB
Vue

<template>
<Card title="今日告警">
<div class="ai-bottom-right">
<div class="list-content">
<div class="tab-list">
<div>序号</div>
<div>抓拍照片</div>
<div>设备名称</div>
<div>告警类型</div>
<div>告警时间</div>
<div>操作</div>
</div>
<el-scrollbar class="list-box">
<div v-for="(item, index) in warnAlarmList" class="list-style" :key="item.id">
<div>{{ index + 1 }}</div>
<div class="list-img">
<div class="img-style">
<!-- <img src="@/assets/images/noData.png" /> -->
<img :src="BASEURL + '/image/' + item.imageUrl" />
</div>
</div>
<!-- <div>{{ item.dev }}</div> -->
<div>{{ item.hardwareName }}</div>
<div>{{ item.alarmType ? getWarnName(item.alarmType) : "" }}</div>
<div>{{ item.createTime }}</div>
<div style="color: #65d7f9; cursor: pointer" @click="openDetailDialog(item)">查看详情</div>
</div>
<div class="not-data" v-if="warnAlarmList.length == 0">
<img src="@/assets/images/noData.png" />
<p>暂无数据</p>
</div>
</el-scrollbar>
</div>
</div>
<div class="list-detail" v-if="showDialog" @click="handleClick">
<div class="dialog-content">
<div class="dialog-icon"><img src="@/assets/images/titleIcon.png" /></div>
<div class="dialog-title"><i>抓拍详情</i></div>
<div class="dialog-detail">
<div class="detail-text">
<div class="text-box">
<div class="type">告警类型</div>
<div class="text">{{ detailData.alarmType ? getWarnName(detailData.alarmType) : "" }}</div>
</div>
<div class="text-box" style="margin-top: 5%">
<div class="type">设备名称</div>
<div class="text">{{ detailData.hardwareName || "" }}</div>
</div>
<div class="text-box" style="margin-top: 5%">
<div class="type">记录时间</div>
<div class="text">{{ detailData.createTime }}</div>
</div>
</div>
</div>
<div class="big-pic">
<img :src="BASEURL + '/image/' + detailData.imageUrl" />
</div>
<div class="close-icon" @click="closeDialog">
<el-icon><Close /></el-icon>
</div>
</div>
</div>
</Card>
</template>
<script lang="ts" setup>
import Card from "@/components/card.vue";
import { ref, onMounted, computed , onBeforeUnmount} from "vue";
import { getAlarmList, getAlarmTypeOption } from "@/api/modules/aIEarlyWarn";
import { GlobalStore } from "@/stores";
import mitts from "@/utils/bus"; //兄弟组件传值
// import { aiAlarmTypeEnum } from "@/enums/project/aiAlarmTypeEnum";
let aiAlarmTypeEnum = ref([] as any);
// 当前环境
const BASEURL = import.meta.env.VITE_API_URL;
const store = GlobalStore();
// const list = reactive([
// {
// id: 1,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 2,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 3,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 4,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 5,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 6,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 7,
// devName: "青金山隧道钢筋加场枪机",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 8,
// devName: "青金山隧道钢筋加场枪机",
// dev: "未知",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 9,
// devName: "青金山隧道钢筋加场枪机",
// dev: "未知",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 10,
// devName: "青金山隧道钢筋加场枪机",
// dev: "未知",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 11,
// devName: "青金山隧道钢筋加场枪机",
// dev: "未知",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// },
// {
// id: 12,
// devName: "青金山隧道钢筋加场枪机",
// dev: "未知",
// warnType: "未穿反光衣",
// warnTime: "2023-01-01 12:00:00"
// }
// ]);
let showDialog = ref(false as any);
function handleClick(event: any) {
// console.log("点击", event.target.className);
if (event.target.className == "list-detail") {
closeDialog();
}
}
let detailData = ref({} as any);
let warnAlarmList = ref([] as any);
//获取告警列表
const getWarnAlarmList = async () => {
const res: any = await getAlarmList({ projectSn: store.sn, selectType: 3 });
console.log("获取告警列表", res);
if (res.result.length > 0) {
warnAlarmList.value = res.result;
mitts.emit("warnAlarmList", res.result[0]);
detailData.value = res.result[0];
} else {
warnAlarmList.value = [];
detailData.value = {};
}
};
//获取告警类型枚举
const getWarnTypeOption = async () => {
const res: any = await getAlarmTypeOption({ projectSn: store.sn });
// console.log("获取告警类型", res.result);
let warnType = res.result.map((item: any) => {
return {
id: Number(item.data),
value: item.name
};
});
aiAlarmTypeEnum.value = warnType;
console.log("获取告警类型**", aiAlarmTypeEnum.value);
};
// 返回对应的枚举名称
function getWarnName(warnType: any) {
let enumObj = aiAlarmTypeEnum.value.find((item: any) => item.id === warnType);
return enumObj ? enumObj.value : "";
}
// 打开详情弹窗
function openDetailDialog(item: any) {
// console.log(item, "当前行数据");
detailData.value = item;
showDialog.value = true;
}
// 关闭详情弹窗
function closeDialog() {
showDialog.value = false;
detailData.value = {};
}
//将方法暴露给父组件
defineExpose({
getWarnTypeOption,
getWarnAlarmList
})
onMounted(async () => {
getWarnTypeOption();
getWarnAlarmList();
});
onBeforeUnmount(async () => {
mitts.off("warnAlarmList");
});
</script>
<style lang="scss" scoped>
.list-detail {
position: absolute;
width: 100%;
height: 100%;
top: 0%;
left: 0%;
background: rgba(7, 28, 49, 0.5);
z-index: 20;
.dialog-content {
position: absolute;
box-sizing: border-box;
padding: 1%;
left: 38%;
top: 30%;
width: 25%;
height: 45%;
background: url("@/assets/images/aIEarlyWarning/dialogBg.png") no-repeat;
background-size: 100% 100%;
z-index: 21;
.dialog-icon {
position: absolute;
left: 3%;
top: 3%;
width: 7%;
height: 7%;
img {
width: 100%;
height: 100%;
}
}
.pic-icon {
position: absolute;
left: 3%;
top: 40%;
width: 7%;
height: 7%;
img {
width: 100%;
height: 100%;
}
}
.close-icon {
position: absolute;
right: 3%;
top: 3%;
cursor: pointer;
color: #ffffff;
font-size: 18px;
}
.dialog-title {
color: #ffffff;
font-weight: bold;
margin-left: 8%;
font-size: 18px;
font-family: "OPPOSans-Bold";
}
.dialog-detail {
width: 100%;
height: 25%;
margin-top: 5%;
.detail-text {
width: 95%;
height: 100%;
.text-box {
height: 25%;
display: flex;
align-items: center;
background: url("@/assets/images/aIEarlyWarning/contentBg.png") no-repeat;
background-size: 100% 100%;
.type {
width: 20%;
margin-left: 3%;
color: #a1accb;
font-size: 12px;
}
.text {
font-size: 12px;
color: #ffffff;
}
}
}
}
.pic-title {
color: #ffffff;
font-weight: bold;
font-size: 18px;
font-family: "OPPOSans-Bold";
margin-top: 5%;
margin-left: 8%;
}
.big-pic {
width: 100%;
height: 50%;
margin-top: 10%;
img {
width: 100%;
height: 100%;
}
}
}
}
.ai-bottom-right {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 2%;
.list-content {
height: 94%;
width: 100%;
// background: url("@/assets/images/cardImg.png") no-repeat;
// background-size: 100% 100%;
.tab-list {
display: flex;
width: 100%;
height: 10%;
background: url("@/assets/images/vehicleManagement/ListTitleImg.png") no-repeat;
background-size: 100% 100%;
// position: absolute;
left: 75.5%;
top: 75%;
color: #ccc;
font-size: 14px;
line-height: 30px;
div {
text-align: center;
width: 16%;
}
}
.list-box {
height: 98%;
.list-style:nth-child(even) {
background: rgba(39, 88, 192, 0.06);
}
.list-style {
display: flex;
align-items: center;
color: #fff;
height: 10%;
font-size: 12px;
.list-img {
// width: 4%;
display: flex;
justify-content: center;
align-items: center;
.img-style {
width: 30px;
height: 24px;
img {
width: 100%;
height: 100%;
object-fit: contain;
}
}
}
div {
text-align: center;
width: 16%;
white-space: nowrap;
}
}
.list-style:hover {
background: #091f3f;
}
}
}
}
.not-data {
top: 35%;
width: 25%;
left: 35%;
position: absolute;
text-align: center;
img {
width: 40%;
margin: 5% 30%;
}
p {
color: #fff;
font-size: 14px;
margin: -6% 37%;
}
}
</style>