Files
SmartParks_uniapp/pages/sys/workbench/earlyWarning/earlyWarning.vue
2025-08-21 14:25:49 +08:00

291 lines
6.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="warn-container">
<!-- 顶部导航 -->
<view class="warn-navbar">
<image src="/static/ic_back.png" class="warn-back" @click="goBack" />
<text class="warn-title">预警处理</text>
<text class="warn-right-txt" @click="goStatistics">预警统计</text>
</view>
<!-- tab栏 -->
<view class="warn-tabs">
<view v-for="(tab, idx) in tabs" :key="idx" :class="['warn-tab', { active: idx === activeTab }]"
@click="changeTab(idx)">
{{ tab }}
<view v-if="idx === activeTab" class="tab-underline"></view>
</view>
</view>
<!-- 列表区 -->
<scroll-view class="warn-list" scroll-y refresher-enabled refresher-background="#f7f7f7"
:refresher-triggered="refresherTriggered" @refresherrefresh="onRefresh" @scrolltolower="loadMore"
:lower-threshold="50">
<view v-for="(item, idx) in list" :key="idx" class="warn-card" @click="goDetail2(item)">
<view class="warn-row">
<view class="warn-no">{{item.smallTypeName}}</view>
<view class="warn-status">{{item.levelName}}</view>
</view>
<image class="warn-line-image" src="/static/ic_my_repair_03.png" />
<view class="warn-info">预警内容{{ item.description }}</view>
<view class="warn-info">预警位置{{ item.deviceGroupName }}</view>
<view class="warn-info">预警时间{{ item.reportTime }}</view>
<view class="warn-info">预警设备{{ item.deviceName }}</view>
<view v-if="[20, 30, 31, 32].includes(item.state)" class="warn-eval-wrap" @click.stop="goDetail(item)">
<view class="warn-eval-btn">去处理</view>
</view>
</view>
<!-- 底部加载提示 -->
<view v-if="loading" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
加载中...
</view>
<view v-if="noMore[activeTab]" style="text-align:center;color:#999;font-size:26rpx;padding:20rpx;">
没有更多数据了
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
tabs: ["待处理", "全部"],
activeTab: 0,
tabData: [
[],
[]
], // 每个 tab 的数据
pageNum: [1, 1], // 每个 tab 当前页码
pageSize: 10,
noMore: [false, false], // 每个 tab 是否没有更多数据
tabLoaded: [false, false], // tab 是否加载过
loading: false,
refresherTriggered: false
};
},
computed: {
list() {
return this.tabData[this.activeTab];
}
},
created() {
this.onRefresh()
},
methods: {
goBack() {
uni.navigateBack();
},
// 切换 tab
async changeTab(idx) {
this.activeTab = idx;
if (!this.tabLoaded[idx]) {
this.onRefresh()
}
},
// 下拉刷新
async onRefresh() {
this.refresherTriggered = true;
this.pageNum[this.activeTab] = 1;
this.noMore[this.activeTab] = false;
this.tabData[this.activeTab] = [];
await this.loadTabData(this.activeTab);
this.refresherTriggered = false;
},
// 滚动加载更多
async loadMore() {
if (this.loading || this.noMore[this.activeTab]) return;
this.pageNum[this.activeTab]++;
await this.loadTabData(this.activeTab);
},
// 请求数据
async loadTabData(idx) {
this.loading = true;
let params = {
pageNum: this.pageNum[idx],
pageSize: this.pageSize
};
// 待处理
if (idx === 0) {
params.states = [20, 30, 31, 32];
}
let res = await this.$u.api.getWarns(params);
if (res.code == "200") {
let rows = res.rows || [];
if (rows.length < this.pageSize) {
this.noMore[idx] = true;
}
this.$set(this.tabData, idx, [...this.tabData[idx], ...rows]);
}
this.tabLoaded[idx] = true;
this.loading = false;
},
goDetail(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: "/pages/sys/workbench/earlyWarning/warnDetail?item=" + itemStr,
});
},
goDetail2(item) {
const itemStr = encodeURIComponent(JSON.stringify(item));
uni.navigateTo({
url: "/pages/sys/workbench/earlyWarning/warnDetail?item=" + itemStr + "&pageType=detail",
});
},
goStatistics() {
uni.navigateTo({
url: "/pages/sys/workbench/earlyWarning/warnStatistics"
});
}
}
};
</script>
<style scoped>
.warn-container {
height: 100vh;
background: #fff;
display: flex;
flex-direction: column;
}
.warn-navbar {
width: 100%;
height: 100rpx;
display: flex;
align-items: center;
justify-content: stretch;
position: relative;
margin-top: 50rpx;
}
.warn-back {
width: 18rpx;
height: 32rpx;
margin-left: 24rpx;
margin-right: 78rpx;
}
.warn-right-txt {
font-size: 24rpx;
color: #0090FF;
margin-right: 24rpx;
}
.warn-title {
font-size: 36rpx;
color: #000;
margin-left: auto;
margin-right: auto;
}
.warn-tabs {
display: flex;
align-items: center;
justify-content: space-around;
background: #fff;
height: 80rpx;
bwarn-bottom: 1px solid #f0f0f0;
flex-shrink: 0;
}
.warn-tab {
flex: 1;
text-align: center;
font-size: 30rpx;
color: #888;
position: relative;
font-weight: 500;
padding: 0 0 10rpx 0;
cursor: pointer;
}
.warn-tab.active {
color: #2186ff;
font-weight: bold;
}
.tab-underline {
width: 60rpx;
height: 6rpx;
background: #2186ff;
bwarn-radius: 3rpx;
margin: 0 auto;
margin-top: 8rpx;
}
.warn-list {
padding: 0 24rpx;
flex: 1;
overflow-y: auto;
padding-bottom: 30rpx;
height: calc(100vh - 80rpx - 32rpx);
background: #f7f7f7;
}
.warn-card {
background: #fff;
bwarn-radius: 12rpx;
margin-top: 24rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
padding-top: 25rpx;
padding-bottom: 32rpx;
}
.warn-eval-wrap {
display: flex;
justify-content: center;
width: 100%;
margin-top: 20rpx;
}
.warn-eval-btn {
width: 240rpx;
height: 60rpx;
text-align: center;
line-height: 60rpx;
background: #0090FF;
border-radius: 40rpx;
font-size: 24rpx;
color: white;
}
.warn-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12rpx;
margin-top: 25rpx;
margin-left: 19rpx;
margin-right: 50rpx;
}
.warn-no {
font-size: 24rpx;
color: #0b0b0b;
font-weight: 500;
}
.warn-status {
font-size: 24rpx;
font-weight: 500;
}
.warn-line-image {
margin-left: 29rpx;
margin-right: 39rpx;
height: 2rpx;
margin-bottom: 29rpx;
}
.warn-info {
font-size: 24rpx;
color: #888;
margin-bottom: 30rpx;
margin-left: 47rpx;
}
</style>