641 lines
15 KiB
Vue
Raw Normal View History

2026-03-27 17:47:09 +08:00
<template>
<div class="bottom-panel">
2026-03-27 17:47:09 +08:00
<div class="nav-menu">
<div
v-for="(item, index) in menuItems"
:key="index"
class="nav-item"
:class="{ active: activeIndex === index }"
@click="activeIndex = index"
>
<div class="nav-icon-box">
2026-03-27 17:47:09 +08:00
<!-- <i :class="item.icon"></i> -->
<img :src="activeIndex === index ? item.icon1 : item.icon" alt="" />
</div>
<div class="nav-label">{{ item.label }}</div>
</div>
</div>
<!-- 气象预警监测表格 -->
<div class="weather-warning-wrapper" style="padding-left: 6px">
<div class="weather-warning-panel">
<img
class="clear-icon"
src="../../assets/RiskWarning_img/清除icon@2x.png"
alt=""
/>
<div class="panel-header">
<div class="header-title">气象预警监测</div>
<div class="filter-tags">
<label class="tag">
<input type="checkbox" v-model="filters.red" />
<span class="">红色预警</span>
</label>
<label class="tag">
<input type="checkbox" v-model="filters.blue" />
<span class="">蓝色预警</span>
</label>
<label class="tag">
<input type="checkbox" v-model="filters.orange" />
<span class="">橙色预警</span>
</label>
<label class="tag">
<input type="checkbox" v-model="filters.yellow" />
<span class="">黄色预警</span>
</label>
</div>
</div>
<div class="table-container">
<el-table
:data="filteredData"
height="100%"
style="width: 100%; background: transparent"
:header-cell-style="headerCellStyle"
:cell-style="cellStyle"
:row-class-name="rowClassName"
>
<el-table-column prop="time" label="预警时间" min-width="140" />
<el-table-column prop="type" label="类型" min-width="80" align="center" />
<el-table-column label="预警等级" min-width="100" align="center">
<template #default="{ row }">
<!-- <span class="warning-level" :class="row.levelClass">
<i class="level-icon"></i>
{{ row.level }}
</span> -->
<div class="warning-level">
<img
:src="
row.levelClass === 'red'
? redIcon
: row.levelClass === 'blue'
? blueIcon
: row.levelClass === 'orange'
? orangeIcon
: yellowIcon
"
alt=""
/>
</div>
</template>
</el-table-column>
<el-table-column prop="district" label="预警区县" min-width="80" />
</el-table>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
2026-03-27 17:47:09 +08:00
import { ElTable } from "element-plus";
import orangeIcon from "../../assets/RiskWarning_img/橙色@2x.png";
import yellowIcon from "../../assets/RiskWarning_img/黄色@2x.png";
import redIcon from "../../assets/RiskWarning_img//红色@2x.png";
import blueIcon from "../../assets/RiskWarning_img/蓝色@2x.png";
import warningIconIcon from "../../assets/RiskWarning_img/风险预警icon@2x.png";
import tunnelIconIcon from "../../assets/RiskWarning_img/隧道icon@2x.png";
import slopeIconIcon from "../../assets/RiskWarning_img/边坡icon@2x.png";
import bridgeIconIcon from "../../assets/RiskWarning_img/桥梁icon@2x.png";
import roadIconIcon from "../../assets/RiskWarning_img/线路路段icon@2x.png";
import warningIconIcon1 from "../../assets/RiskWarning_img/风险预警icon1@2x.png";
import tunnelIconIcon1 from "../../assets/RiskWarning_img/隧道icon1@2x.png";
import slopeIconIcon1 from "../../assets/RiskWarning_img/边坡icon1@2x.png";
import bridgeIconIcon1 from "../../assets/RiskWarning_img/桥梁icon1@2x.png";
import roadIconIcon1 from "../../assets/RiskWarning_img/线路路段icon1@2x.png";
const activeIndex = ref(0);
const menuItems = [
{
label: "项目",
icon: "icon-warning",
iconClass: "warning",
icon: warningIconIcon,
icon1: warningIconIcon1,
},
{
label: "隧道",
icon: "icon-tunnel",
iconClass: "tunnel",
icon: tunnelIconIcon,
icon1: tunnelIconIcon1,
},
{
label: "边坡",
icon: "icon-slope",
iconClass: "slope",
icon: slopeIconIcon,
icon1: slopeIconIcon1,
},
{
label: "桥梁",
icon: "icon-bridge",
iconClass: "bridge",
icon: bridgeIconIcon,
icon1: bridgeIconIcon1,
},
{
label: "路段",
icon: "icon-road",
iconClass: "road",
icon: roadIconIcon,
icon1: roadIconIcon1,
},
];
// 筛选状态
const filters = ref({
red: false,
blue: false,
orange: false,
yellow: false,
});
// 预警数据
const warningData = ref([
{
time: "2025-11-18 09:24:81",
type: "暴雨",
level: "蓝色预警",
levelClass: "blue",
district: "合川区",
},
{
time: "2025-11-12 09:24:81",
type: "冰雪",
level: "红色预警",
levelClass: "red",
district: "万州区",
},
{
time: "2025-11-12 09:24:81",
type: "大雾",
level: "橙色预警",
levelClass: "orange",
district: "涪陵区",
},
{
time: "2025-11-12 09:24:81",
type: "大风",
level: "黄色预警",
levelClass: "yellow",
district: "城口县",
},
]);
// 过滤后的数据
const filteredData = computed(() => {
const hasFilter =
filters.value.red ||
filters.value.blue ||
filters.value.orange ||
filters.value.yellow;
if (!hasFilter) return warningData.value;
return warningData.value.filter((item) => {
if (filters.value.red && item.levelClass === "red") return true;
if (filters.value.blue && item.levelClass === "blue") return true;
if (filters.value.orange && item.levelClass === "orange") return true;
if (filters.value.yellow && item.levelClass === "yellow") return true;
return false;
});
});
// el-table 样式
const headerCellStyle = () => ({
background: "transparent",
color: "rgba(255, 255, 255, 0.6)",
fontWeight: "normal",
borderBottom: "1px solid rgba(64, 169, 255, 0.2)",
padding: "10px 8px",
});
const cellStyle = () => ({
background: "transparent",
color: "rgba(255, 255, 255, 0.9)",
borderBottom: "1px solid rgba(64, 169, 255, 0.1)",
padding: "5px 5px",
2026-03-27 17:47:09 +08:00
});
const rowClassName = ({ rowIndex }) => {
return rowIndex % 2 === 0 ? "even-row" : "odd-row";
};
// 表格自动滚动相关
const tableRef = ref(null);
const isScrolling = ref(true);
const scrollTimer = ref(null);
const scrollSpeed = 50; // 滚动间隔(毫秒)
const scrollStep = 1; // 每次滚动像素
// 检查是否有筛选条件
const hasFilter = computed(() => {
return filters.value.red || filters.value.blue || filters.value.orange || filters.value.yellow;
});
// 开始自动滚动
const startAutoScroll = () => {
if (scrollTimer.value) {
clearInterval(scrollTimer.value);
}
if (!isScrolling.value || hasFilter.value) return;
const tableBody = document.querySelector('.weather-warning-panel .el-table__body-wrapper .el-scrollbar__wrap');
if (!tableBody) return;
scrollTimer.value = setInterval(() => {
if (tableBody) {
tableBody.scrollTop += scrollStep;
// 滚动到底部后回到顶部(使用 >= 判断,并留出一点余量确保准确触发)
const maxScroll = tableBody.scrollHeight - tableBody.clientHeight;
if (tableBody.scrollTop >= maxScroll - 2) {
tableBody.scrollTop = 0;
}
}
}, scrollSpeed);
};
// 停止自动滚动
const stopAutoScroll = () => {
if (scrollTimer.value) {
clearInterval(scrollTimer.value);
scrollTimer.value = null;
}
};
// 重置滚动到顶部
const resetScrollToTop = () => {
const tableBody = document.querySelector('.weather-warning-panel .el-table__body-wrapper .el-scrollbar__wrap');
if (tableBody) {
tableBody.scrollTop = 0;
}
};
// 鼠标移入停止滚动
const handleMouseEnter = () => {
stopAutoScroll();
};
// 鼠标移出开始滚动
const handleMouseLeave = () => {
if (!hasFilter.value) {
isScrolling.value = true;
startAutoScroll();
}
};
// 监听筛选条件变化
watch(hasFilter, (newVal) => {
if (newVal) {
// 有筛选条件时停止滚动并回到顶部
stopAutoScroll();
resetScrollToTop();
} else {
// 取消筛选后开始滚动
isScrolling.value = true;
nextTick(() => {
startAutoScroll();
});
}
});
onMounted(() => {
nextTick(() => {
startAutoScroll();
// 添加鼠标事件监听
const tableContainer = document.querySelector('.weather-warning-panel .table-container');
if (tableContainer) {
tableContainer.addEventListener('mouseenter', handleMouseEnter);
tableContainer.addEventListener('mouseleave', handleMouseLeave);
}
});
});
onUnmounted(() => {
stopAutoScroll();
const tableContainer = document.querySelector('.weather-warning-panel .table-container');
if (tableContainer) {
tableContainer.removeEventListener('mouseenter', handleMouseEnter);
tableContainer.removeEventListener('mouseleave', handleMouseLeave);
}
});
2026-03-27 17:47:09 +08:00
</script>
<style lang="scss" scoped>
// 视频屏幕自适应 - 基于视口宽度动态调整
// 基准宽度 1920px使用 vw 单位实现自适应
@function vw($px) {
@return calc($px / 1920 * 100vw);
}
.bottom-panel {
2026-03-27 17:47:09 +08:00
position: relative;
width: 100%;
height: 100%;
padding: vw(10);
box-sizing: border-box;
display: flex;
// 小屏幕适配
@media (max-width: 1366px) {
padding: 8px;
}
@media (max-width: 1024px) {
padding: 6px;
}
2026-03-27 17:47:09 +08:00
}
.nav-menu {
width: vw(50);
min-width: 40px;
2026-03-27 17:47:09 +08:00
display: flex;
flex-direction: column;
justify-content: end;
align-items: center;
gap: vw(5);
2026-03-27 17:47:09 +08:00
.nav-item {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
transition: all 0.3s ease;
&:hover,
&.active {
.nav-icon-box {
2026-03-27 17:47:09 +08:00
background: rgba(64, 169, 255, 0.3);
border-color: rgba(64, 169, 255, 0.6);
}
.nav-label {
color: #40a9ff;
}
}
.nav-icon-box {
width: vw(50);
height: vw(50);
min-width: 36px;
min-height: 36px;
margin-bottom: vw(5);
2026-03-27 17:47:09 +08:00
background: rgba(64, 169, 255, 0.1);
border: 1px solid rgba(64, 169, 255, 0.3);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
img {
width: vw(50);
height: vw(50);
min-width: 32px;
min-height: 32px;
2026-03-27 17:47:09 +08:00
}
i {
font-size: vw(24);
2026-03-27 17:47:09 +08:00
color: #40a9ff;
}
// 使用 emoji 作为图标占位
&.warning::before {
content: "📍";
font-size: vw(24);
2026-03-27 17:47:09 +08:00
}
&.tunnel::before {
content: "🚇";
font-size: vw(24);
2026-03-27 17:47:09 +08:00
}
&.slope::before {
content: "⛰️";
font-size: vw(24);
2026-03-27 17:47:09 +08:00
}
&.bridge::before {
content: "🌉";
font-size: vw(24);
2026-03-27 17:47:09 +08:00
}
&.road::before {
content: "🛣️";
font-size: vw(24);
2026-03-27 17:47:09 +08:00
}
}
.nav-label {
display: flex;
align-items: center;
justify-content: center;
font-size: vw(12);
2026-03-27 17:47:09 +08:00
color: #fff;
transition: all 0.3s ease;
}
}
}
// 气象预警监测包装器
.weather-warning-wrapper {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-end;
width: 90%;
}
// 气象预警监测面板样式
.weather-warning-panel {
height: 50%;
background: rgba(64, 169, 255, 0.1);
2026-03-27 17:47:09 +08:00
border: 1px solid rgba(64, 169, 255, 0.3);
border-radius: 8px;
padding: vw(15);
2026-03-27 17:47:09 +08:00
display: flex;
flex-direction: column;
position: relative;
.clear-icon {
position: absolute;
top: vw(-50);
2026-03-27 17:47:09 +08:00
right: 0px;
width: vw(40) !important;
height: vw(40) !important;
min-width: 28px;
min-height: 28px;
2026-03-27 17:47:09 +08:00
}
.panel-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: vw(15);
2026-03-27 17:47:09 +08:00
.header-title {
font-size: vw(18);
2026-03-27 17:47:09 +08:00
font-weight: bold;
color: #40a9ff;
position: relative;
padding-left: vw(12);
2026-03-27 17:47:09 +08:00
&::before {
content: "";
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: vw(4);
height: vw(16);
2026-03-27 17:47:09 +08:00
background: linear-gradient(180deg, #40a9ff 0%, #1890ff 100%);
border-radius: 2px;
}
}
.filter-tags {
display: flex;
gap: vw(15);
2026-03-27 17:47:09 +08:00
.tag {
display: flex;
align-items: center;
gap: vw(5);
2026-03-27 17:47:09 +08:00
cursor: pointer;
input {
width: vw(14);
height: vw(14);
min-width: 12px;
min-height: 12px;
2026-03-27 17:47:09 +08:00
accent-color: #40a9ff;
}
span {
font-size: vw(12);
2026-03-27 17:47:09 +08:00
color: rgba(255, 255, 255, 0.8);
&.tag-red {
color: #ff4d4f;
}
&.tag-blue {
color: #40a9ff;
}
&.tag-orange {
color: #ff7a45;
}
&.tag-yellow {
color: #ffc53d;
}
}
}
}
}
.table-container {
flex: 1;
overflow: hidden;
:deep(.el-table__body-wrapper) {
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
}
}
// el-table 样式
:deep(.el-table) {
background: transparent;
&::before {
display: none;
}
.el-table__inner-wrapper {
background: transparent;
}
.el-table__inner-wrapper:before {
width: 0%;
}
.el-table__header-wrapper {
background: transparent;
}
.el-table__body-wrapper {
background: transparent;
}
tr {
background: transparent;
&:hover {
background: rgba(64, 169, 255, 0.05) !important;
}
}
th.el-table__cell {
background: transparent;
}
td.el-table__cell {
background: transparent;
}
}
.warning-level {
// display: inline-flex;
// align-items: center;
// gap: 5px;
// padding: 4px 10px;
// border-radius: 4px;
// font-size: 12px;
// width: 15px;
// height: 15px;
display: flex;
align-items: center;
justify-content: center;
img {
width: vw(15);
height: vw(15);
min-width: 10px;
min-height: 10px;
2026-03-27 17:47:09 +08:00
}
// .level-icon {
// width: 0;
// height: 0;
// border-left: 6px solid transparent;
// border-right: 6px solid transparent;
// border-bottom: 10px solid currentColor;
// }
&.red {
color: #ff4d4f;
background: rgba(255, 77, 79, 0.1);
}
&.blue {
color: #40a9ff;
background: rgba(64, 169, 255, 0.1);
}
&.orange {
color: #ff7a45;
background: rgba(255, 122, 69, 0.1);
}
&.yellow {
color: #ffc53d;
background: rgba(255, 197, 61, 0.1);
}
}
}
</style>