Files
sgxt_web/src/views/home/model/zdryWarning.vue

191 lines
5.1 KiB
Vue
Raw Normal View History

2025-04-15 14:38:12 +08:00
<template>
<div class="comom-title">
2025-08-01 17:16:03 +08:00
<span class="title">常规预警</span>
</div>
2025-04-15 14:38:12 +08:00
<div class="comom-cnt zdryBox">
<div style="height:33px;">
2025-07-14 18:15:09 +08:00
<CheckBox :data="checkData" @changeData="changeData"></CheckBox>
2025-04-15 14:38:12 +08:00
</div>
2025-08-29 14:30:58 +08:00
<ul class="ryBox" ref="scrollCgTableRef" @mouseenter="stopAutoScroll" @mouseleave="startAutoScroll" v-loading="loading" v-infinite-scroll="loadList">
2025-07-14 17:31:24 +08:00
<li v-for="item in personList" :key="item.id" @click="chooseItem(item)">
2025-08-01 17:16:03 +08:00
<YjItem :item="item" :dict="{D_BZ_HPZL}"></YjItem>
2025-04-15 14:38:12 +08:00
</li>
2025-07-14 17:31:24 +08:00
<MOSTY.Empty :show="!loading && personList.length <= 0" :imgSize="100"></MOSTY.Empty>
2025-04-15 14:38:12 +08:00
</ul>
</div>
</template>
<script setup>
2025-07-14 17:31:24 +08:00
import emitter from "@/utils/eventBus.js";
2025-07-14 14:21:12 +08:00
import { qcckPost } from "@/api/qcckApi.js";
2025-04-15 14:38:12 +08:00
import YjItem from "@/views/home/components/yjItem.vue";
import * as MOSTY from "@/components/MyComponents/index";
import CheckBox from "@/components/checkBox/index.vue";
2025-08-29 14:30:58 +08:00
import { ref ,reactive, onMounted,getCurrentInstance , onUnmounted} from 'vue';
2025-07-14 17:31:24 +08:00
const { proxy } = getCurrentInstance();
2025-08-01 17:16:03 +08:00
const {D_BZ_HPZL} =proxy.$dict('D_BZ_HPZL')
2025-04-15 14:38:12 +08:00
const checkData = reactive({
2025-08-01 17:16:03 +08:00
list: ["人员", "车辆"],
hasChoose: ["人员", "车辆"],
2025-04-15 14:38:12 +08:00
});
2025-07-14 14:21:12 +08:00
const total = ref(0);
2025-08-01 17:16:03 +08:00
const yjJb = ref('1,2');
2025-07-14 14:21:12 +08:00
const pageNum = ref(1);
2025-04-15 14:38:12 +08:00
const loading = ref(false); // 加载中
2025-07-14 14:21:12 +08:00
const personList = ref([]);
2025-08-29 14:30:58 +08:00
const scrollCgTableRef = ref(null) // 滚动元素区域
let isAutoScrolling = true // 是否自动滚动
const intervalId = ref(null) //定时器
2025-07-14 14:21:12 +08:00
onMounted(()=>{
getList()
2025-08-29 14:30:58 +08:00
autoScroll()
2025-07-14 14:21:12 +08:00
})
2025-08-29 14:30:58 +08:00
onUnmounted(() => {
if (intervalId.value) clearInterval(intervalId.value)// 清理定时器
2025-07-14 14:21:12 +08:00
})
2025-08-29 14:30:58 +08:00
// 自动滚动
const autoScroll = () => {
2025-08-31 22:42:03 +08:00
if(personList.value.length==0){return}
2025-08-29 14:30:58 +08:00
intervalId.value = setInterval(() => {
if (!isAutoScrolling) return
const scrollTableEl = scrollCgTableRef.value
scrollTableEl.scrollTop += 1 // 垂直滚动距离
let scrollTop = scrollTableEl.scrollTop;
let scrollHeight = scrollTableEl.scrollHeight;
let offsetHeight = Math.ceil(scrollTableEl.getBoundingClientRect().height);
let currentHeight = scrollTop + offsetHeight;
if (currentHeight >= scrollHeight) { // 到底部
if(personList.value.length == total.value){
scrollTableEl.scrollTop = 0;
}else{
pageNum.value++;
getList('load')
}
}
}, 100)
}
// 停止滚动
const stopAutoScroll = () => {
isAutoScrolling = false
}
2025-08-31 22:42:03 +08:00
2025-08-29 14:30:58 +08:00
// 开始滚动
const startAutoScroll = () => {
isAutoScrolling = true
autoScroll()
}
2025-04-15 14:38:12 +08:00
// 复选框切换
2025-07-14 14:21:12 +08:00
function changeData(val){
pageNum.value = 1;
personList.value = [];
checkData.hasChoose = val;
let ids = [];
val.forEach(it => {
2025-08-01 17:16:03 +08:00
if(it == '人员') ids.push(1);
if(it == '车辆') ids.push(2);
2025-07-14 14:21:12 +08:00
});
yjJb.value = ids.join(',')
2025-07-24 14:40:46 +08:00
if(val.length == 0) personList.value = [];
else getList();
2025-04-15 14:38:12 +08:00
}
2025-07-14 14:21:12 +08:00
// 触底加载
const loadList = () =>{
if( personList.value.length == total.value) return;
pageNum.value++;
getList()
}
2025-04-15 14:38:12 +08:00
2025-08-29 14:30:58 +08:00
const getList = (type) =>{
2025-08-01 17:16:03 +08:00
let data = { pageSize:10, pageNum:pageNum.value,yjLx:yjJb.value };
2025-08-29 14:30:58 +08:00
loading.value = !type ? true : false;
2025-08-01 17:16:03 +08:00
qcckPost(data,'/mosty-gsxt/tbYjxx/getPageList').then(res=>{
2025-07-14 14:21:12 +08:00
loading.value = false;
let arr = res.records || [];
personList.value = pageNum.value == 1 ? arr : personList.value.concat(arr);
total.value = res.total;
}).catch(()=>{
loading.value = false;
})
}
2025-07-14 17:31:24 +08:00
2025-08-06 14:25:36 +08:00
const chooseItem = (item) => {
console.log(item);
2025-07-14 18:15:09 +08:00
emitter.emit('showHomeYJ',[item]);
2025-07-14 17:31:24 +08:00
emitter.emit('deletePointArea','home_yj_map');
if(!item.jd || !item.jd) return proxy.$message({ type: "warning", message: "该预警没有坐标!" });
let icon = require('@/assets/point/yj.png');
if(item.yjjb == '20') icon = require('@/assets/point/yj1.png');
if(item.yjjb == '30') icon = require('@/assets/point/yj2.png');
if(item.yjjb == '40') icon = require('@/assets/point/yj3.png');
emitter.emit('addPointArea',{flag:'home_yj_map',icon,coords:[item]});
emitter.emit('setMapCenter',{location:[item.jd,item.wd],zoomLevel:10});
}
2025-04-15 14:38:12 +08:00
</script>
2025-07-14 14:21:12 +08:00
<style>
.el-loading-mask{
background: rgba(0,0,0,0.5);
}
</style>
2025-04-15 14:38:12 +08:00
<style lang="scss" scoped>
@import "@/assets/css/homeScreen.scss";
.zdryBox{
background: #052249;
2025-07-14 18:15:09 +08:00
height: 100%;
2025-04-15 14:38:12 +08:00
.ryBox{
height: calc(100% - 33px);
overflow: hidden;
overflow-y: auto;
}
}
::-webkit-scrollbar {
background-color: #263b70;
}
::-webkit-scrollbar-thumb {
background-color: #146bbe;
}
::-webkit-scrollbar-track {
background-color: #263b70;
}
::-webkit-scrollbar-corner {
background-color: #142141;
}
::v-deep .el-checkbox__label{
color:#fff;
}
::v-deep .el-checkbox__input.is-checked+.el-checkbox__label{
color:#00FFFF;
}
::v-deep .el-checkbox__inner{
background:rgba(0,144,255,0.2);
border:1px solid #0072FF;
}
::v-deep .el-checkbox__input.is-checked .el-checkbox__inner{
background-color: #00FFFF;
border-color:#00FFFF;
}
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner{
background-color: #00FFFF;
border-color:#00FFFF;
}
::v-deep .el-checkbox__inner::after{
border:2px solid #000;
border-left:0;
border-top:0;
left:3px;
top:0px;
}
::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner::before{
background: #000;
}
2025-07-24 14:40:46 +08:00
</style>