This commit is contained in:
2026-03-05 16:34:25 +08:00
parent 13ee9e66cc
commit 69e199e9cc
15 changed files with 1398 additions and 677 deletions

View File

@ -1,15 +1,19 @@
<template>
<view class="home-container">
<view class="site-sections-list">
<view class="site-title">站点选择</view>
<radio-group class="site-radio" @change="onSiteChange">
<label v-for="item in siteOptions" :key="item.value" class="radio-item"
:class="{ active: item.value === siteId, disabled: item.disable }">
<radio class="radio" :value="item.value" :disabled="item.disable"
:checked="item.value === siteId" color="#547ef4" />
<text class="radio-text">{{ item.text }}</text>
</label>
</radio-group>
<uni-data-picker placeholder="请选择" popup-title="业态选择" :step-searh="true" :value="siteId" :clear-icon="false"
:localdata="siteTypeOptions" :ellipsis="false" @change="selectedSite">
</uni-data-picker>
<view class="info">
<view class="list">
<uni-icons type="location" color="#fff" size="20"></uni-icons>
{{ baseInfo.siteAddress || '-' }}
</view>
<view class="list">
<uni-icons type="calendar" color="#fff" size="20"></uni-icons>
{{ baseInfo.runningTime || '-' }}
</view>
</view>
</view>
<view class="base-info">
@ -22,16 +26,16 @@
<view class="title">总累计运行数据</view>
<view class="total-revenue">
<text class="label">总收入</text>
<text class="value">{{ format2(runningInfo.totalRevenue) }}</text>
<text class="value">{{ format2(totalRevenueDisplayValue) }}</text>
<text class="unit"></text>
</view>
</view>
<uni-grid :column="2" :showBorder="false" :square="false" :highlight="false">
<uni-grid-item v-for="(item, index) in sjglData" :key="index + 'sjglData'">
<uni-grid-item v-for="(item, index) in runningDataCards" :key="index + 'sjglData'">
<view class="grid-item-box">
<view class="title">{{ item.title }}</view>
<view class="text" :style="{ color: item.color }">
{{ format2(runningInfo[item.attr]) }}
{{ format2(item.value) }}
</view>
</view>
</uni-grid-item>
@ -58,7 +62,9 @@
} from '@/utils/filters'
import {
getAllSites,
getSingleSiteBaseInfo,
getDzjkHomeView,
getProjectDisplayData,
getAmmeterRevenueData
} from '@/api/ems/site.js'
@ -67,9 +73,29 @@
return {
pageScrollTop: 0,
siteOptions: [],
siteTypeOptions: [{
text: '储能',
value: 'cn',
children: []
},
{
text: '光能',
value: 'gn',
disable: true,
children: []
},
{
text: '岸电',
value: 'ad',
disable: true,
children: []
}
],
siteId: '',
mapUrl: '',
baseInfo: {},
runningInfo: {},
runningDisplayData: [],
revenueChartData: {},
revenueOptions: {
padding: [10, 5, 0, 10],
@ -86,7 +112,7 @@
},
extra: {}
},
sjglData: [{
fallbackSjglData: [{
title: "今日充电量kWh",
attr: "dayChargedCap",
color: '#4472c4'
@ -130,9 +156,49 @@
}
},
computed: {
...mapGetters(['belongSite'])
...mapGetters(['belongSite', 'currentSiteId']),
totalRunningSectionData() {
return (this.runningDisplayData || []).filter(item => item.sectionName === '总累计运行数据')
},
totalRevenueDisplayItem() {
const sectionData = this.totalRunningSectionData || []
const byFieldCode = sectionData.find(item => item.fieldCode === 'totalRevenue')
if (byFieldCode) {
return byFieldCode
}
return sectionData.find(item => item.fieldName === '总收入')
},
totalRevenueDisplayValue() {
return this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldValue : this.runningInfo.totalRevenue
},
runningDataCards() {
const sectionData = this.totalRunningSectionData || []
if (sectionData.length > 0) {
const revenueFieldCode = this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldCode : ''
return sectionData
.filter(item => item.fieldCode !== revenueFieldCode)
.map((item, index) => ({
title: item.fieldName,
value: item.fieldValue,
color: this.getCardColor(index)
}))
}
return this.fallbackSjglData.map(item => ({
title: item.title,
value: this.runningInfo[item.attr],
color: item.color
}))
}
},
methods: {
isAvailableSite(siteId) {
const site = this.siteOptions.find(item => item.value === siteId)
return !!(site && !site.disable)
},
getCardColor(index) {
const colors = ['#4472c4', '#70ad47', '#4472c4', '#f67438', '#4472c4', '#70ad47', '#70ad47', '#f67438']
return colors[index % colors.length]
},
format2(value) {
const num = Number(value || 0)
return Number.isFinite(num) ? num.toFixed(2) : '0.00'
@ -152,38 +218,59 @@
}
return list
},
onSiteChange(e) {
const value = e.detail.value
selectedSite(data) {
const siteObj = (data.detail.value || [])[1]
const value = siteObj?.value
if (!value) return
if (value === this.siteId) return
this.siteId = value
this.$store.commit('SET_CURRENTSITEID', value)
this.updateSiteInfo()
},
updateSiteInfo() {
if (!this.siteId) {
this.baseInfo = {}
this.runningInfo = {}
this.runningDisplayData = []
this.revenueChartData = {}
this.mapUrl = ''
return
}
this.updateMapCenter()
this.getSiteBaseInfo()
this.getRunningInfo()
this.getRevenueChartData()
},
getSiteBaseInfo() {
return getSingleSiteBaseInfo({
siteId: this.siteId
}).then(response => {
this.baseInfo = response?.data || {}
})
},
getSiteList() {
getAllSites().then(response => {
const data = response?.data || []
this.siteOptions = data.map(item => {
const children = data.map(item => {
return {
text: item.siteName,
value: item.siteId,
id: item.id,
longitude: Number(item.longitude || 0),
latitude: Number(item.latitude || 0),
disable: !this.belongSite || this.belongSite.length === 0 || this.belongSite.includes('all') ? false : !this
.belongSite.includes(item.siteId)
}
})
this.siteId = this.siteOptions.find(item => !item.disable)?.value || ''
this.siteId && this.updateSiteInfo()
this.siteTypeOptions.find(i => i.value === 'cn').children = children
this.siteOptions = children
const defaultSiteId = this.isAvailableSite(this.currentSiteId) ? this.currentSiteId : (children.find(item => !item
.disable)?.value || '')
if (defaultSiteId) {
this.siteId = defaultSiteId
this.$store.commit('SET_CURRENTSITEID', defaultSiteId)
this.updateSiteInfo()
}
})
},
updateMapCenter() {
@ -202,10 +289,12 @@
this.mapUrl = `https://api.tianditu.gov.cn/staticimage?center=${lon},${lat}&width=${width}&height=${height}&zoom=${zoom}&layers=${layers}&markers=${lon},${lat}&tk=${tk}`
},
getRunningInfo() {
getDzjkHomeView({
siteId: this.siteId
}).then(response => {
this.runningInfo = response?.data || {}
return Promise.all([
getDzjkHomeView(this.siteId),
getProjectDisplayData(this.siteId)
]).then(([homeResponse, displayResponse]) => {
this.runningInfo = homeResponse?.data || {}
this.runningDisplayData = displayResponse?.data || []
})
},
getRevenueChartData() {
@ -284,6 +373,14 @@
})
}
},
watch: {
currentSiteId(newSiteId) {
if (!newSiteId || newSiteId === this.siteId) return
if (!this.isAvailableSite(newSiteId)) return
this.siteId = newSiteId
this.updateSiteInfo()
}
},
onLoad() {
this.$nextTick(() => {
this.getSiteList()
@ -324,51 +421,64 @@
padding: 30rpx 30rpx;
padding-bottom: 100rpx;
color: #fff;
.site-title {
font-size: 28rpx;
font-weight: 600;
margin-bottom: 16rpx;
}
.info {
color: #fff;
font-size: 26rpx;
line-height: 30rpx;
vertical-align: middle;
margin-top: 20rpx;
.site-radio {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
>.list {
display: flex;
justify-content: flex-start;
align-items: center;
.radio-item {
display: flex;
align-items: center;
padding: 12rpx 20rpx;
border-radius: 28rpx;
background: rgba(0, 0, 0, 0.18);
color: rgba(255, 255, 255, 0.75);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
transition: all 0.2s ease;
&:not(:last-child) {
margin-bottom: 20rpx;
}
&.active {
background: #ffffff;
color: #233157;
box-shadow: 0 12rpx 22rpx rgba(0, 0, 0, 0.18);
}
&.disabled {
opacity: 0.45;
}
.radio {
display: none;
}
.radio-text {
font-size: 24rpx;
font-weight: 600;
letter-spacing: 0.5rpx;
>.uni-icons {
margin-right: 10rpx;
}
}
}
.uni-data-tree {
::v-deep {
.input-value {
border: none;
padding-left: 0;
.selected-area {
width: 90%;
flex: none;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
.selected-list {
color: #fff;
}
}
.text-color {
color: #fff;
font-size: 34rpx;
line-height: 36rpx;
font-weight: bolder;
}
.arrow-area {
transform: rotate(-135deg);
.input-arrow {
border-color: #fff;
}
}
}
}
}
}
.base-info {