告警大屏css初稿,大屏小图echart测试页

This commit is contained in:
龚皓
2024-11-01 13:19:38 +08:00
parent e16bda93b1
commit f456cdaa8c
12 changed files with 1061 additions and 155 deletions

View File

@@ -13,10 +13,42 @@
告警总数:{{ displayTotalItems }}
</span>
</el-row>
<el-row class="filter-row">
<el-col :span="5">
<el-form-item label="摄像头名称">
<el-select v-model="filterParams.cameraId" placeholder="请选择摄像头" filterable>
<el-option v-for="camera in cameras" :key="camera.id" :label="camera.name" :value="camera.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="告警类型">
<el-select v-model="filterParams.types" placeholder="请选择告警类型">
<el-option v-for="(label, key) in typeMapping" :key="key" :label="label" :value="key"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="开始时间">
<el-date-picker v-model="filterParams.timeAfter" type="datetime" placeholder="请选择开始时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="5">
<el-form-item label="结束时间">
<el-date-picker v-model="filterParams.timeBefore" type="datetime" placeholder="请选择结束时间"></el-date-picker>
</el-form-item>
</el-col>
<el-col :span="2" class="filter-buttons">
<el-button type="primary" @click="handleFilter">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</el-col>
</el-row>
<el-row class="table-row">
<el-col :span="24" class="table-col">
<div class="table-container">
<el-table :data="tableData" header-row-class-name="table-header" :fit="true" height="580">
<el-table :data="tableData" header-row-class-name="table-header" :fit="true" height="580">
<el-table-column prop="id" label="告警编号" min-width="100"></el-table-column>
<el-table-column label="告警类型" min-width="150">
<template v-slot="scope">
@@ -35,9 +67,13 @@
}}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" min-width="100">
<el-table-column label="操作" min-width="150">
<template v-slot="scope">
<el-button type="text" @click="handleView(scope.row)">查看</el-button>
<el-button type="text" v-if="scope.row.status === 'pending'"
@click="submitStatusUpdate('closed', scope.row)">
标记为已处理
</el-button>
</template>
</el-table-column>
</el-table>
@@ -78,7 +114,7 @@
<p>持续时间: {{ duration }}</p>
</el-col>
<el-col :span="6">
<p>备注: {{ selectedRow.note }}</p>
<p>备注: {{ selectedRow.remark }}</p>
</el-col>
</el-row>
<!-- <div class="event-media">
@@ -93,7 +129,7 @@
</div>
</div>
</div> -->
<div class="event-media" :class="{ 'center-media' :mediums.length === 1 }">
<div class="event-media" :class="{ 'center-media': mediums.length === 1 }">
<!-- 告警关联视频 -->
<div v-if="hasVideo" class="media-container video-item">
<p>告警关联视频</p>
@@ -106,10 +142,27 @@
<el-image :src="snapshotFile" fit="contain" @click="openMediaDialog('image', snapshotFile)"></el-image>
</div>
</div>
<!-- 备注输入框 -->
<el-row>
<el-col :span="24">
<el-form-item>
<el-input v-model="remark" placeholder="请描述事件原因,处理过程方法,以及处理结果" type="textarea" rows="5"></el-input>
</el-form-item>
</el-col>
</el-row>
<!-- 条件显示按钮 -->
<el-row class="dialog-button">
<el-col :span="24" style="text-align: center;">
<el-button v-if="selectedRow.status === 'pending'" type="primary" @click="submitStatusUpdate('closed')">
标记为已处理
</el-button>
<el-button v-else type="primary" @click="submitStatusUpdate(selectedRow.status)">
提交
</el-button>
</el-col>
</el-row>
</div>
<span slot="footer" class="dialog-footer">
<div class=""></div>
</span>
</el-dialog>
<el-dialog v-model="mediaDialogVisible" width="70%">
<div v-if="mediaType === 'image'">
@@ -134,6 +187,7 @@ const boxApi = new BoxApi();
// 响应式数据
const tableData = ref([]);
const dialogVisible = ref(false);
const remark = ref("");
const mediaDialogVisible = ref(false);
const mediaType = ref('');
const mediaSrc = ref('');
@@ -144,6 +198,7 @@ const duration = ref('');
const typeMapping = reactive({});
const statusMapping = {
'pending': '待处理',
'assigned': '处理中',
'closed': '已处理'
};
const currentPage = ref(1);
@@ -151,6 +206,101 @@ const pageSize = ref(20);
const token = ref(null);
const totalItems = ref(0);
const displayTotalItems = ref(0); // 用于展示的数字
const cameras = ref([]);
const fetchCameras = async () => {
try {
const token = localStorage.getItem('alertToken');
const limit = 20; // 每次请求 20 条数据
let offset = 0; // 从 0 开始
let allCameras = [];
// 第一次请求,用于获取总数
const firstResponse = await boxApi.getCameras(limit, offset, token);
const cameraCount = firstResponse.count;
allCameras = firstResponse.results;
// 根据总数继续请求剩余的数据
while (offset + limit < cameraCount) {
offset += limit;
const response = await boxApi.getCameras(limit, offset, token);
allCameras = allCameras.concat(response.results);
}
cameras.value = allCameras; // 存储所有摄像头信息
} catch (error) {
console.error("Error fetching cameras:", error);
}
};
const filterParams = reactive({
types: null,
timeAfter: null,
timeBefore: null,
});
// 更新状态和备注的方法
const submitStatusUpdate = async (newStatus, row = null) => {
try {
// console.console.log(row,row.id);
const eventId = row ? row.id : selectedRow.value.id;
const remarkContent = remark.value && remark.value.trim() !== "" ? remark.value : null;
// 调用 setEventStatus 更新事件状态和备注
await boxApi.setEventStatus(eventId, newStatus, remarkContent);
if (row) {
row.status = newStatus;
row.remark = remarkContent; // 更新该行的备注
} else {
selectedRow.value.status = newStatus;
selectedRow.value.remark = remarkContent;
dialogVisible.value = false; // 关闭弹窗
remark.value = ""; // 清空备注
}
} catch (error) {
console.error("Error updating event status:", error);
}
};
const handleFilter = async () => {
try {
const types = filterParams.types || null;
// const timeAfter = filterParams.timeAfter ? new Date(filterParams.timeAfter).toISOString() : null;
// const timeBefore = filterParams.timeBefore ? new Date(filterParams.timeBefore).toISOString() : null;
const timeAfter = filterParams.timeAfter ? formatDateTime(new Date(filterParams.timeAfter)) : null;
const timeBefore = filterParams.timeBefore ? formatDateTime(new Date(filterParams.timeBefore)) : null;
const cameraId = filterParams.cameraId || null;
const { results, count } = await boxApi.getEventsByParams(
token.value,
pageSize.value,
currentPage.value,
timeBefore,
timeAfter,
types,
cameraId
);
tableData.value = results;
totalItems.value = count;
} catch (error) {
console.error("Error fetching filtered events:", error);
}
};
const handleReset = () => {
filterParams.types = null;
filterParams.timeAfter = null;
filterParams.timeBefore = null;
filterParams.cameraId = null;
fetchEvents(); // 重置筛选条件后,重新获取所有告警数据
};
const openMediaDialog = (type, src) => {
@@ -226,12 +376,21 @@ const handleView = (row) => {
row.formatted_started_at = formatDateTime(row.started_at);
dialogVisible.value = true;
mediums.value = row.mediums || [];
remark.value = row.remark || "";
};
const closeDialog = () => {
remark.value = "";
};
// 分页处理
const handlePageChange = (page) => {
currentPage.value = page;
fetchEvents();
if (filterParams.types || filterParams.timeAfter || filterParams.timeBefore) {
handleFilter();
} else {
fetchEvents();
}
};
// 页大小处理
@@ -267,6 +426,7 @@ onMounted(async () => {
token.value = localStorage.getItem('alertToken');
await fetchTypeMapping(token.value);
await fetchEvents();
await fetchCameras();
});
</script>
@@ -343,8 +503,8 @@ onMounted(async () => {
padding: 10px;
}
.table-col{
max-height:100%;
.table-col {
max-height: 100%;
}
.video-item video,
@@ -374,4 +534,22 @@ onMounted(async () => {
::v-deep .pagination-container .el-pagination__classifier {
color: #000;
}
.dialog-button {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20px;
}
.filter-row {
display: flex;
justify-content: center;
align-content: center;
height: 80px;
padding: 20px;
margin-top: 20px;
gap: 20px;
font-weight: bold;
}
</style>

View File

@@ -96,6 +96,7 @@ onMounted(async () => {
height: 56vh;
margin-top: 60px;
/* border: 1px solid #1E2E4A; */
}
.bottom-pan{
margin: 0;

View File

@@ -224,7 +224,7 @@ onBeforeUnmount(() => {
/* 每个摄像头项目的样式 */
.camera-item {
margin-bottom: 8px;
margin-bottom: 10px;
cursor: pointer;
padding: 12px;
border: 1px solid #458388;
@@ -313,8 +313,8 @@ onBeforeUnmount(() => {
width: 100%;
height: 100%;
/* background-color: #1E2E4A; */
background: linear-gradient(to top, rgba(64, 226, 255, 0.7), rgba(211, 64, 248, 0.7));
/* background: linear-gradient(to top, rgba(0, 7, 8, 0.9), rgba(12, 2, 155, 0.7)); */
/* background: linear-gradient(to top, rgba(64, 226, 255, 0.7), rgba(211, 64, 248, 0.7)); */
background: linear-gradient(to top, rgba(0, 7, 8, 0.9), rgba(12, 2, 155, 0.7));
border: 2px solid #0b4c5f;
border-radius: 8px;
position: relative;

304
src/html/ViewList.vue Normal file
View File

@@ -0,0 +1,304 @@
<template>
<div class="list-view">
<div class="background-overlay"></div>
<div class="container">
<!-- 头栏 -->
<div class="header">
<div class="title-left">
<div small-bg>
<dv-decoration8 :reverse="true" style="width:28vw;height:60px;" />
</div>
<div small-bg>
<dv-decoration3 style="width:250px;height:30px;" />
</div>
</div>
<div class="line-title">
<div text-2xl pt10>
<div small-bg>
<dv-decoration-11 class="custom-decoration" style="width:25vw;height:70px;">
<div color-green font-700 bg="~ dark/0">
<dv-decoration7 style="width:20vw;height:30px;">
<div color-white font-300>
&nbsp;本地告警大屏&nbsp;
</div>
</dv-decoration7>
</div>
</dv-decoration-11>
</div>
</div>
<div small-bg>
<dv-decoration5 :dur="2" style="width:25vw;height:80px;" />
</div>
</div>
<div class="title-right">
<div small-bg class="first-row">
<dv-decoration8 style="width:28vw;height:60px;" />
</div>
<div small-bg class="second-row">
<dv-decoration3 style="width:250px;height:30px;" />
</div>
</div>
</div>
<div class="main-section">
<!-- 左侧区域 -->
<div class="left-section">
<!-- <div class="section top-left corner-style" >左上
<div class="section hiden"></div>
</div>
<div class="section middle-left corner-style">左中
<div class="section hiden"></div>
</div>
<div class="section bottom-left corner-style">左下
<div class="section hiden"></div>
</div> -->
<dv-border-box-13 title="告警数据概览(数据计算数字)" class="section top-left">
<LeftTop />
</dv-border-box-13>
<dv-border-box-13 title="点位告警数量(不同点位的数量)" class="section middle-left">点位告警数量不同点位的数量</dv-border-box-13>
<dv-border-box-13 title="今日告警列表(告警详情)" class="section bottom-left ">今日告警列表告警详情</dv-border-box-13>
</div>
<!-- 中部区域 -->
<div class="center-section">
<dv-border-box8 class="center-top">
<dv-border-box8 class="center-top-header">警戒画面</dv-border-box8>
<div class="center-top-grids">
<div class="grid-item">栅格左上</div>
<div class="grid-item">栅格右上</div>
<div class="grid-item">栅格左下</div>
<div class="grid-item">栅格右下</div>
</div>
</dv-border-box8>
<div class="center-bottom">
<!-- <dv-border-box-13 class="center-bottom-left">中下左</dv-border-box-13> -->
<dv-border-box-13 class="center-bottom-right">警戒点位列表</dv-border-box-13>
</div>
</div>
<!-- 右侧区域 -->
<div class="right-section">
<dv-border-box-13 class="section top-right corner-style">告警类型概览</dv-border-box-13>
<dv-border-box-13 class="section middle-right corner-style">告警数量分布</dv-border-box-13>
<dv-border-box-13 class="section bottom-right corner-style">告警种类划分</dv-border-box-13>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, onBeforeUnmount, nextTick, computed } from 'vue';
import { BoxApi } from '@/utils/boxApi.ts';
import { VideoPlay, VideoPause, VideoCameraFilled } from '@element-plus/icons-vue';
import LeftTop from '@/components/Max/LeftTop.vue';
// import '/src/assets/viewListStyle.css'
</script>
<style scoped>
.list-view {
display: flex;
justify-content: center;
margin: 0;
height: 100vh;
width: 100vw;
padding: 4vh 10vw 10vh 1vw;
/* background-color: rgb(121, 184, 243); */
/* background-image: url('/bg05.png'); */
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background: radial-gradient(circle, rgb(24, 64, 197), rgb(0, 7, 60));
position: relative;
color: black;
box-sizing: border-box;
}
/* .custom-decoration{
color:white;
} */
.background-overlay {
position: absolute;
/* 绝对定位 */
top: 0;
left: 0;
right: 0;
bottom: 0;
/* background-image: url('/bg01.png'); */
background-size: cover;
background-position: center;
background-repeat: no-repeat;
opacity: 0.8;
z-index: 0;
}
.container {
display: flex;
flex-direction: column;
width: 80vw;
height: 100%;
gap: 1vh;
position: relative;
/* 为了在背景下显示 */
z-index: 1;
}
.header {
height: 12vh;
width: 81vw;
/* background-color: #000080; */
color: white;
text-align: center;
line-height: 12vh;
display: flex;
flex-direction: row;
margin-bottom: 20px;
}
.line-title {
display: flex;
flex-direction: column;
/* gap: 2vh; */
}
.title-left {
display: flex;
flex-direction: column;
}
.title-right {
display: flex;
flex-direction: column; /* 设置为垂直布局 */
}
.first-row {
display: flex;
justify-content: flex-start; /* 第一行内容靠左 */
}
.second-row {
display: flex;
justify-content: flex-end; /* 第二行内容靠右 */
}
.main-section {
height: 72vh;
display: flex;
flex-direction: row;
gap: 1vw;
}
.left-section,
.right-section {
display: flex;
flex-direction: column;
width: 22vw;
height: 70vh;
gap: 2vh;
}
.top-left,
.middle-left,
.bottom-left,
.top-right,
.middle-right,
.bottom-right {
color: white;
text-align: center;
width: 22vw;
height: 22vh;
/* background-color: rgba(255, 255, 255, 0.1); */
/* border: 3px solid rgba(0, 255, 255, 0.5); */
/* box-shadow: 0 2px 5px rgba(221, 204, 204, 0.5); */
}
.top-left{
position: relative;
padding: 1vh 1vw;
display: flex;
justify-content: center; /* 水平居中 */
align-items: center; /* 垂直居中 */
flex-grow: 1;
width: 20vw;
height: 20vh;
}
/* .top-left, .top-right {
margin-bottom: 1vh;
}
.bottom-left, .bottom-right {
margin-top: 1vh;
} */
.center-section {
display: flex;
flex-direction: column;
width: 35vw;
height: 70vh;
gap: 1vh;
}
.center-top {
height: 47vh;
/* background-color: #555; */
color: white;
display: flex;
flex-direction: column;
}
.center-top-header {
height: 3vh;
width: 35vw;
text-align: center;
line-height: 3vh;
margin-bottom: 1vh;
/* background-color: rgba(0, 51, 102, 0.8); */
border-radius: 3px;
/* 圆角 */
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
/* 添加阴影 */
}
.center-top-grids {
display: grid;
grid-template-columns: 17vw 17vw;
gap: 2vh 1vw;
}
.grid-item {
width: 17vw;
height: 20vh;
/* background-color: #777; */
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.center-bottom {
display: flex;
gap: 1vw;
flex-direction: row;
}
.center-bottom-left,
.center-bottom-right {
width: 35vw;
height: 22vh;
/* background-color: #444; */
color: white;
text-align: center;
/* margin-top: 1vh; */
}
</style>