Files
app-govern/pages/index/comp/targetInfo.vue

308 lines
8.6 KiB
Vue
Raw Normal View History

2026-05-29 16:23:56 +08:00
<template>
<view class="target-info-page">
<scroll-view class="target-info-scroll" scroll-y :show-scrollbar="false">
<view class="monitor-card card">
<view class="card-header">
<view class="event-icon">
<Cn-icon-transient name="监测点" />
</view>
<view class="card-header-info">
2026-06-01 20:36:04 +08:00
<text class="point-name ellipsis">{{ pointInfo.pointName || '-' }}</text>
2026-05-29 16:23:56 +08:00
<view class="meta-row">
2026-06-01 20:36:04 +08:00
<text v-if="pointInfo.engineeringName" class="meta-item ellipsis">
工程{{ pointInfo.engineeringName }}
</text>
<text class="meta-item ellipsis">项目{{ pointInfo.projectName || '-' }}</text>
<text class="meta-item ellipsis">设备{{ pointInfo.deviceName || '-' }}</text>
2026-05-29 16:23:56 +08:00
</view>
<text class="meta-time ellipsis">最新数据时间{{ pointInfo.dataTime || '-' }}</text>
</view>
</view>
<view class="legend-row">
<view class="legend-item" v-for="phase in phaseColors" :key="phase.name">
<view class="legend-dot" :style="{ background: phase.color }" />
<text class="legend-text">{{ phase.name }}</text>
</view>
</view>
2026-06-01 20:36:04 +08:00
<view v-if="moreChildren.length" class="params-section">
2026-05-29 16:23:56 +08:00
<view
2026-06-01 20:36:04 +08:00
v-for="(rowItems, rowIdx) in chunkedChildren(moreChildren)"
2026-05-29 16:23:56 +08:00
:key="rowIdx"
class="double-row"
>
2026-06-01 20:36:04 +08:00
<view v-for="(child, childIdx) in rowItems" :key="child.targetId || childIdx" class="param-group">
2026-05-29 16:23:56 +08:00
<view class="param-title">
2026-06-01 20:36:04 +08:00
<text>{{ child.name }}{{ child.unit ? ` (${child.unit})` : '' }}</text>
2026-05-29 16:23:56 +08:00
</view>
2026-06-01 20:36:04 +08:00
<view v-if="hasTPhaseData(child)" class="phase-single">
<text class="phase-value-vertical phase-value-vertical--neutral">{{ child.T }}</text>
</view>
<view v-else class="phase-vertical">
2026-05-29 16:23:56 +08:00
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[0].color }">{{ child.A }}</text>
</view>
<view class="phase-divider" />
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[1].color }">{{ child.B }}</text>
</view>
<view class="phase-divider" />
<view class="phase-item-vertical">
<text class="phase-value-vertical" :style="{ color: phaseColors[2].color }">{{ child.C }}</text>
</view>
</view>
</view>
</view>
</view>
2026-06-01 20:36:04 +08:00
<view v-else class="empty-wrap">
<Cn-empty msg="暂无更多指标" :paddingTop="120"></Cn-empty>
</view>
2026-05-29 16:23:56 +08:00
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
pointInfo: {},
phaseColors: [
{ name: 'A相', color: '#F1B22E' },
{ name: 'B相', color: '#2BA471' },
{ name: 'C相', color: '#D54941' },
],
}
},
2026-06-01 20:36:04 +08:00
computed: {
moreChildren() {
const children = this.pointInfo.children || []
const selected = this.getSelectedIndicators()
return children.filter(
(child) => !selected.some((name) => this.matchIndicator(child.name, name)),
)
},
},
onLoad() {
const point = uni.getStorageSync('monitorPointDetail')
if (point) {
this.pointInfo = {
...point,
selectedIndicators: this.getSelectedIndicatorsFromStorage(point.selectedIndicators),
}
if (point.pointName) {
uni.setNavigationBarTitle({ title: point.pointName })
}
2026-05-29 16:23:56 +08:00
}
},
2026-06-01 20:36:04 +08:00
onUnload() {
uni.removeStorageSync('monitorPointDetail')
},
2026-05-29 16:23:56 +08:00
methods: {
2026-06-01 20:36:04 +08:00
getSelectedIndicatorsFromStorage(fallback = []) {
const cached = uni.getStorageSync(this.$cacheKey.monitorSelectedIndicators)
if (Array.isArray(cached) && cached.length) {
return cached
}
return Array.isArray(fallback) ? fallback : []
},
getSelectedIndicators() {
return this.getSelectedIndicatorsFromStorage(this.pointInfo.selectedIndicators)
},
matchIndicator(name, selected) {
if (!name || !selected) return false
const base = (name || '').replace(/\(.*\)/, '').trim()
const selectedBase = (selected || '').replace(/\(.*\)/, '').trim()
return base === selectedBase
},
hasTPhaseData(child) {
return child.T !== undefined && child.T !== null && child.T !== '-'
},
2026-05-29 16:23:56 +08:00
chunkedChildren(children) {
const result = []
for (let i = 0; i < children.length; i += 2) {
result.push(children.slice(i, i + 2))
}
return result
},
},
}
</script>
<style lang="scss" scoped>
.target-info-page {
min-height: 100vh;
background: #f7f8fa;
}
.target-info-scroll {
height: 100vh;
box-sizing: border-box;
padding: 20rpx 0 40rpx;
}
.card {
background: #ffffff;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.08) 0px 0px 1px 1px;
margin: 0 10px;
overflow: hidden;
}
.monitor-card {
border: 1rpx solid #eef2f6;
}
.card-header {
padding: 20rpx 20rpx 12rpx;
display: flex;
align-items: center;
border-bottom: 1rpx solid #eef2f6;
}
.event-icon {
width: 90rpx;
height: 90rpx;
border-radius: 16rpx;
display: flex;
justify-content: center;
align-items: center;
margin-right: 20rpx;
background-color: #376cf320;
flex-shrink: 0;
}
.card-header-info {
flex: 1;
min-width: 0;
}
.point-name {
display: block;
font-size: 30rpx;
font-weight: 700;
color: #333333;
margin-bottom: 8rpx;
}
.meta-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6rpx 12rpx;
}
.meta-item {
2026-06-01 11:32:25 +08:00
font-size: 24rpx;
2026-05-29 16:23:56 +08:00
color: #666666;
2026-06-01 11:32:25 +08:00
line-height: 1.2;
2026-05-29 16:23:56 +08:00
}
.meta-time {
display: block;
margin-top: 8rpx;
2026-06-01 11:32:25 +08:00
font-size: 24rpx;
2026-05-29 16:23:56 +08:00
color: #666666;
2026-06-01 11:32:25 +08:00
line-height: 1.2;
2026-05-29 16:23:56 +08:00
}
.legend-row {
display: flex;
gap: 20rpx;
align-items: center;
padding: 16rpx 20rpx;
}
.legend-item {
display: flex;
align-items: center;
gap: 8rpx;
}
.legend-dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
}
.legend-text {
font-size: 24rpx;
color: #666666;
}
.params-section {
padding: 0 16rpx 20rpx;
}
2026-06-01 20:36:04 +08:00
.empty-wrap {
position: relative;
min-height: 320rpx;
}
2026-05-29 16:23:56 +08:00
.double-row {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16rpx;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
}
.param-group {
min-width: 0;
2026-06-01 20:36:04 +08:00
background: #f3f3f3;
2026-05-29 16:23:56 +08:00
border-radius: 16rpx;
padding: 16rpx 8rpx 12rpx;
}
.param-title {
2026-06-01 20:36:04 +08:00
font-size: 24rpx;
2026-05-29 16:23:56 +08:00
color: #666666;
margin-bottom: 8rpx;
padding-left: 4rpx;
}
.phase-vertical {
display: flex;
align-items: stretch;
}
2026-06-01 20:36:04 +08:00
.phase-single {
display: flex;
justify-content: center;
align-items: center;
padding: 4rpx;
}
2026-05-29 16:23:56 +08:00
.phase-item-vertical {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 4rpx;
}
.phase-value-vertical {
font-size: 28rpx;
font-weight: 700;
2026-06-01 20:36:04 +08:00
&--neutral {
color: #333333;
}
2026-05-29 16:23:56 +08:00
}
.phase-divider {
width: 1px;
background: #d2d2d2;
margin: 8rpx 0;
}
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>