develop #2
@ -33,6 +33,14 @@ export function getAmmeterDataList(data) {
|
||||
})
|
||||
}
|
||||
|
||||
//获取所有设备
|
||||
export function getDeviceList(siteId) {
|
||||
return request({
|
||||
url: `/ems/siteConfig/getDeviceList?siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
//获取pcs头部的设备信息
|
||||
export function getRunningHeadInfo(data) {
|
||||
return request({
|
||||
@ -50,36 +58,40 @@ export function getPcsDetailInfo(data) {
|
||||
})
|
||||
}
|
||||
|
||||
//获取单体电池 电池堆列表数据
|
||||
export function getStackNameList(data) {
|
||||
//获取pcs名称列表
|
||||
export function getPcsNameList(siteId) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getStackNameList`, //?siteId=${siteId}
|
||||
method: 'get',
|
||||
data
|
||||
url: `/ems/siteMonitor/getPcsNameList?siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
//获取单体电池 电池堆列表数据
|
||||
export function getStackNameList(siteId) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getStackNameList?siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
//获取单体电池 电池簇列表数据
|
||||
export function getClusterNameList(data) {
|
||||
export function getClusterNameList({ stackDeviceId, siteId }) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getClusterNameList`, //?stackDeviceId=${stackDeviceId}&siteId=${siteId}
|
||||
method: 'get',
|
||||
data
|
||||
url: `/ems/siteMonitor/getClusterNameList?stackDeviceId=${stackDeviceId}&siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
//单体电池表格数据
|
||||
export function getClusterDataInfoList(data) {
|
||||
export function getClusterDataInfoList({ siteId, stackDeviceId, clusterDeviceId, batteryId, pageSize, pageNum }) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getClusterDataInfoList?`, //clusterDeviceId=${clusterDeviceId}&siteId=${siteId}&stackDeviceId=${stackDeviceId}&pageSize=${pageSize}&pageNum=${pageNum}
|
||||
method: 'get',
|
||||
data
|
||||
url: `/ems/siteMonitor/getClusterDataInfoList?clusterDeviceId=${clusterDeviceId}&siteId=${siteId}&stackDeviceId=${stackDeviceId}&batteryId=${batteryId}&pageSize=${pageSize}&pageNum=${pageNum}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
// 单体电池图表
|
||||
export function getSingleBatteryData(data) {
|
||||
export function getSingleBatteryData({ siteId, deviceId, clusterDeviceId, startDate, endDate }) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getSingleBatteryData`, //?siteId=${siteId}&deviceId=${deviceId}&startDate=${startDate}&endDate=${endDate}&clusterDeviceId=${clusterDeviceId}`,
|
||||
method: 'get',
|
||||
data
|
||||
url: `/ems/siteMonitor/getSingleBatteryData?siteId=${siteId}&deviceId=${deviceId}&startDate=${startDate}&endDate=${endDate}&clusterDeviceId=${clusterDeviceId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@ -92,12 +104,19 @@ export function getSingleSiteBaseInfo(data) {
|
||||
})
|
||||
}
|
||||
|
||||
//单站监控 首页 总累计运行数据
|
||||
export function getDzjkHomeView(data) {
|
||||
//单站监控 首页 总累计运行数据(基于日表)
|
||||
export function getDzjkHomeTotalView(siteId) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/homeView`, //?siteId=${siteId}
|
||||
method: 'get',
|
||||
data
|
||||
url: `/ems/siteMonitor/homeTotalView?siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 单站监控项目展示数据(字段配置 + 最新值)
|
||||
export function getProjectDisplayData(siteId) {
|
||||
return request({
|
||||
url: `/ems/siteMonitor/getProjectDisplayData?siteId=${siteId}`,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@ -128,6 +147,18 @@ export function getPointData(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 点位配置-曲线数据(与管理端一致)
|
||||
export function getPointConfigCurve(data) {
|
||||
return request({
|
||||
url: `/ems/pointConfig/curve`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
repeatSubmit: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取站点包含的设备种类 用来判断单站监控设备监控的菜单栏展示
|
||||
export function getSiteAllDeviceCategory(data) {
|
||||
return request({
|
||||
|
||||
69
components/SiteSelector/index.vue
Normal file
69
components/SiteSelector/index.vue
Normal file
@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<view class="ems-site-selector">
|
||||
<uni-data-picker placeholder="请选择" popup-title="业态选择" :step-searh="true" :value="siteId" :clear-icon="false"
|
||||
:localdata="siteTypeOptions" :ellipsis="false" @change="handleChange">
|
||||
</uni-data-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapGetters(['siteId', 'siteTypeOptions'])
|
||||
},
|
||||
methods: {
|
||||
handleChange(data) {
|
||||
const valueList = data?.detail?.value || []
|
||||
const siteObj = valueList[1]
|
||||
if (!siteObj || siteObj.value === undefined || siteObj.value === null || siteObj.value === this.siteId) return
|
||||
this.$store.dispatch('SetCurrentSiteId', siteObj.value)
|
||||
this.$emit('change', siteObj.value)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('LoadSites')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.ems-site-selector {
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
128
components/SiteSwitchHeader/index.vue
Normal file
128
components/SiteSwitchHeader/index.vue
Normal file
@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<view class="site-switch-header">
|
||||
<uni-data-picker
|
||||
placeholder="请选择"
|
||||
popup-title="业态选择"
|
||||
:step-searh="true"
|
||||
:value="siteId"
|
||||
:clear-icon="false"
|
||||
:localdata="siteTypeOptions"
|
||||
:ellipsis="false"
|
||||
@change="handleChange"
|
||||
/>
|
||||
<view class="info">
|
||||
<view class="list">
|
||||
<uni-icons type="location" color="#fff" size="20"></uni-icons>
|
||||
{{ siteAddress || '-' }}
|
||||
</view>
|
||||
<view class="list">
|
||||
<uni-icons type="calendar" color="#fff" size="20"></uni-icons>
|
||||
{{ runningTime || '-' }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
siteId: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
},
|
||||
siteTypeOptions: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
siteAddress: {
|
||||
type: String,
|
||||
default: '-'
|
||||
},
|
||||
runningTime: {
|
||||
type: String,
|
||||
default: '-'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange(data) {
|
||||
this.$emit('change', data)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.site-switch-header {
|
||||
background: linear-gradient(to right, #547ef4, #679ff5);
|
||||
padding: 30rpx 30rpx;
|
||||
padding-bottom: 100rpx;
|
||||
color: #fff;
|
||||
|
||||
.info {
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
line-height: 30rpx;
|
||||
vertical-align: middle;
|
||||
margin-top: 20rpx;
|
||||
|
||||
>.list {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
>.uni-icons {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.uni-data-tree {
|
||||
::v-deep {
|
||||
.uni-data-tree-dialog {
|
||||
color: #333;
|
||||
|
||||
.selected-item,
|
||||
.dialog-title {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,10 +1,11 @@
|
||||
// 应用全局配置
|
||||
module.exports = {
|
||||
// todo 打包项目时切换baseUrl
|
||||
// baseUrl: 'http://localhost:8089',
|
||||
// 测试环境
|
||||
// baseUrl: 'http://110.40.171.179:8089',
|
||||
baseUrl: 'http://110.40.171.179:8089',
|
||||
// 生产环境
|
||||
baseUrl: 'http://1.15.120.242:8089',
|
||||
// baseUrl: 'http://1.15.120.242:8089',
|
||||
// 应用信息
|
||||
appInfo: {
|
||||
// 应用名称
|
||||
|
||||
@ -108,6 +108,12 @@
|
||||
"navigationBarTitleText": "PCS"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/work/yl/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "冷却"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/work/dtdc/index",
|
||||
"style": {
|
||||
|
||||
209
pages/index.vue
209
pages/index.vue
@ -1,16 +1,7 @@
|
||||
<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>
|
||||
</view>
|
||||
<site-switch-header :site-id="siteId" :site-type-options="siteTypeOptions" :site-address="baseInfo.siteAddress"
|
||||
:running-time="baseInfo.runningTime" @change="selectedSite" />
|
||||
|
||||
<view class="base-info">
|
||||
<view class="map-card">
|
||||
@ -22,16 +13,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,18 +49,43 @@
|
||||
} from '@/utils/filters'
|
||||
import {
|
||||
getAllSites,
|
||||
getDzjkHomeView,
|
||||
getSingleSiteBaseInfo,
|
||||
getDzjkHomeTotalView,
|
||||
getProjectDisplayData,
|
||||
getAmmeterRevenueData
|
||||
} from '@/api/ems/site.js'
|
||||
import SiteSwitchHeader from '@/components/SiteSwitchHeader/index.vue'
|
||||
const createSiteTypeOptions = () => ([{
|
||||
text: '储能',
|
||||
value: 'cn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '光能',
|
||||
value: 'gn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '岸电',
|
||||
value: 'ad',
|
||||
children: []
|
||||
}
|
||||
])
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SiteSwitchHeader
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pageScrollTop: 0,
|
||||
siteOptions: [],
|
||||
siteTypeOptions: createSiteTypeOptions(),
|
||||
siteId: '',
|
||||
mapUrl: '',
|
||||
baseInfo: {},
|
||||
runningInfo: {},
|
||||
runningDisplayData: [],
|
||||
revenueChartData: {},
|
||||
revenueOptions: {
|
||||
padding: [10, 5, 0, 10],
|
||||
@ -86,7 +102,7 @@
|
||||
},
|
||||
extra: {}
|
||||
},
|
||||
sjglData: [{
|
||||
fallbackSjglData: [{
|
||||
title: "今日充电量(kWh)",
|
||||
attr: "dayChargedCap",
|
||||
color: '#4472c4'
|
||||
@ -130,9 +146,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 +208,67 @@
|
||||
}
|
||||
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 => {
|
||||
return {
|
||||
const canAccessAll = !this.belongSite || this.belongSite.length === 0 || this.belongSite.includes('all')
|
||||
const siteTypeOptions = createSiteTypeOptions().map(item => ({
|
||||
...item,
|
||||
children: []
|
||||
}))
|
||||
data.forEach(item => {
|
||||
if (!canAccessAll && !this.belongSite.includes(item.siteId)) return
|
||||
const siteType = (item.siteType || item.type || 'cn').toString().toLowerCase()
|
||||
const typeOption = siteTypeOptions.find(i => i.value === siteType) || siteTypeOptions.find(i => i.value === 'cn')
|
||||
if (!typeOption) return
|
||||
typeOption.children.push({
|
||||
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)
|
||||
}
|
||||
latitude: Number(item.latitude || 0)
|
||||
})
|
||||
this.siteId = this.siteOptions.find(item => !item.disable)?.value || ''
|
||||
this.siteId && this.updateSiteInfo()
|
||||
})
|
||||
this.siteTypeOptions = siteTypeOptions.filter(item => (item.children || []).length > 0)
|
||||
this.siteOptions = this.siteTypeOptions.reduce((result, typeItem) => {
|
||||
return result.concat(typeItem.children || [])
|
||||
}, [])
|
||||
const defaultSiteId = this.isAvailableSite(this.currentSiteId) ? this.currentSiteId : (this.siteOptions[0]?.value || '')
|
||||
if (defaultSiteId) {
|
||||
this.siteId = defaultSiteId
|
||||
this.$store.commit('SET_CURRENTSITEID', defaultSiteId)
|
||||
this.updateSiteInfo()
|
||||
}
|
||||
})
|
||||
},
|
||||
updateMapCenter() {
|
||||
@ -202,10 +287,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([
|
||||
getDzjkHomeTotalView(this.siteId),
|
||||
getProjectDisplayData(this.siteId)
|
||||
]).then(([homeResponse, displayResponse]) => {
|
||||
this.runningInfo = homeResponse?.data || {}
|
||||
this.runningDisplayData = displayResponse?.data || []
|
||||
})
|
||||
},
|
||||
getRevenueChartData() {
|
||||
@ -284,6 +371,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()
|
||||
@ -319,58 +414,6 @@
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.site-sections-list {
|
||||
background: linear-gradient(to right, #547ef4, #679ff5);
|
||||
padding: 30rpx 30rpx;
|
||||
padding-bottom: 100rpx;
|
||||
color: #fff;
|
||||
|
||||
|
||||
.site-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.site-radio {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.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;
|
||||
|
||||
&.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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.base-info {
|
||||
margin-top: -80rpx;
|
||||
border-radius: 80rpx 80rpx 0 0;
|
||||
|
||||
@ -123,6 +123,9 @@
|
||||
},
|
||||
loadImage: function () {
|
||||
var _this = this
|
||||
uni.showLoading({
|
||||
title: '图片加载中...',
|
||||
})
|
||||
|
||||
uni.getImageInfo({
|
||||
src: _this.imageSrc,
|
||||
@ -188,7 +191,14 @@
|
||||
isShowImg: true
|
||||
})
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
fail() {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '图片加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
// 拖动时候触发的touchStart事件
|
||||
|
||||
@ -54,31 +54,6 @@
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
</uni-group>
|
||||
<!-- 子设备表格 -->
|
||||
<uni-group mode="card" class="child-card-group" style="margin-bottom:20rpx;">
|
||||
<uni-table border stripe emptyText="暂无数据" class="child-table">
|
||||
<!-- 表头行 -->
|
||||
<uni-tr>
|
||||
<uni-th align="center">名称</uni-th>
|
||||
<uni-th align="center">单体平均值</uni-th>
|
||||
<uni-th align="center">单体最小值</uni-th>
|
||||
<uni-th align="center">单体最小值ID</uni-th>
|
||||
<uni-th align="center">单体最大值</uni-th>
|
||||
<uni-th align="center">单体最大值ID</uni-th>
|
||||
</uni-tr>
|
||||
<!-- 表格数据行 -->
|
||||
<uni-tr v-for="(tableItem, tableIndex) in item.batteryDataList"
|
||||
:key="tableIndex+'batteryDataList'">
|
||||
<uni-td align="center"
|
||||
v-html="`${tableItem.dataName}(${unitObj[tableItem.dataName]})`"></uni-td>
|
||||
<uni-td align="center">{{tableItem.avgData}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.minData}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.minDataID}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxData}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxDataID}}</uni-td>
|
||||
</uni-tr>
|
||||
</uni-table>
|
||||
</uni-group>
|
||||
</view>
|
||||
</uni-collapse-item>
|
||||
</uni-collapse>
|
||||
@ -91,7 +66,9 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
getBMSBatteryCluster
|
||||
getProjectDisplayData,
|
||||
getStackNameList,
|
||||
getClusterNameList
|
||||
} from '@/api/ems/site.js'
|
||||
import {
|
||||
mapState
|
||||
@ -107,11 +84,8 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
unitObj: {
|
||||
'电压': 'V',
|
||||
'温度': '℃',
|
||||
'SOC': '%'
|
||||
},
|
||||
displayData: [],
|
||||
clusterDeviceList: [],
|
||||
list: [],
|
||||
siteId: '',
|
||||
infoData: [{
|
||||
@ -186,26 +160,147 @@
|
||||
return !(Object.keys(this.CLUSTERWorkStatusOptions).includes(item.workStatus)) ? "timing-collapse-item" :
|
||||
workStatus === '9' ? 'warning-collapse-item' : 'running-collapse-item'
|
||||
},
|
||||
getModuleRows(menuCode, sectionName) {
|
||||
return (this.displayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
const raw = String(fieldCode || '').trim()
|
||||
if (!raw) return ''
|
||||
const index = raw.lastIndexOf('__')
|
||||
return index >= 0 ? raw.slice(index + 2) : raw
|
||||
},
|
||||
getFieldRowMap(rows = [], deviceId = '') {
|
||||
const map = {}
|
||||
const targetDeviceId = String(deviceId || '')
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== targetDeviceId) return
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
map[fieldName] = item
|
||||
const displayName = String(item.fieldName || '').trim()
|
||||
if (displayName && !map[displayName]) {
|
||||
map[displayName] = item
|
||||
}
|
||||
})
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== '') return
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
if (map[fieldName] === undefined || map[fieldName] === null || map[fieldName] === '') {
|
||||
map[fieldName] = item
|
||||
}
|
||||
const displayName = String(item.fieldName || '').trim()
|
||||
if (displayName && !map[displayName]) {
|
||||
map[displayName] = item
|
||||
}
|
||||
})
|
||||
return map
|
||||
},
|
||||
getFieldMap(rows = [], deviceId = '') {
|
||||
const rowMap = this.getFieldRowMap(rows, deviceId)
|
||||
return Object.keys(rowMap).reduce((acc, fieldName) => {
|
||||
const row = rowMap[fieldName]
|
||||
if (acc[fieldName] === undefined) {
|
||||
acc[fieldName] = row?.fieldValue
|
||||
}
|
||||
return acc
|
||||
}, {})
|
||||
},
|
||||
getLatestTime(menuCode) {
|
||||
const times = (this.displayData || [])
|
||||
.filter(item => item.menuCode === menuCode && item.valueTime)
|
||||
.map(item => new Date(item.valueTime).getTime())
|
||||
.filter(ts => !isNaN(ts))
|
||||
if (times.length === 0) {
|
||||
return '-'
|
||||
}
|
||||
const date = new Date(Math.max(...times))
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${p(date.getMonth() + 1)}-${p(date.getDate())} ${p(date.getHours())}:${p(date.getMinutes())}:${p(date.getSeconds())}`
|
||||
},
|
||||
getClusterDeviceList() {
|
||||
return getStackNameList(this.siteId)
|
||||
.then(response => {
|
||||
const stackList = response?.data || []
|
||||
if (!stackList.length) {
|
||||
this.clusterDeviceList = []
|
||||
return
|
||||
}
|
||||
const requests = stackList.map(stack => {
|
||||
const stackDeviceId = stack.deviceId || stack.id || ''
|
||||
return getClusterNameList({
|
||||
stackDeviceId,
|
||||
siteId: this.siteId
|
||||
})
|
||||
.then(clusterResponse => {
|
||||
const clusterList = clusterResponse?.data || []
|
||||
return clusterList.map(cluster => ({
|
||||
...cluster,
|
||||
parentDeviceName: stack.deviceName || stack.name || stackDeviceId || '',
|
||||
}))
|
||||
})
|
||||
.catch(() => [])
|
||||
})
|
||||
return Promise.all(requests).then(results => {
|
||||
this.clusterDeviceList = results.flat()
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
this.clusterDeviceList = []
|
||||
})
|
||||
},
|
||||
buildList() {
|
||||
const devices = (this.clusterDeviceList && this.clusterDeviceList.length > 0) ? this.clusterDeviceList : [{
|
||||
deviceId: this.siteId,
|
||||
deviceName: 'BMS电池簇',
|
||||
parentDeviceName: ''
|
||||
}]
|
||||
this.list = devices.map(device => {
|
||||
const deviceId = device.deviceId || device.id || this.siteId
|
||||
const infoMap = this.getFieldMap(this.getModuleRows('SBJK_BMSDCC', '簇信息'), deviceId)
|
||||
const statusMap = this.getFieldMap(this.getModuleRows('SBJK_BMSDCC', '状态'), deviceId)
|
||||
return {
|
||||
...infoMap,
|
||||
workStatus: statusMap.workStatus,
|
||||
pcsCommunicationStatus: statusMap.pcsCommunicationStatus,
|
||||
emsCommunicationStatus: statusMap.emsCommunicationStatus,
|
||||
currentSoc: infoMap.currentSoc,
|
||||
siteId: this.siteId,
|
||||
deviceId,
|
||||
parentDeviceName: device.parentDeviceName || '',
|
||||
deviceName: device.deviceName || device.name || device.deviceId || device.id || 'BMS电池簇',
|
||||
dataUpdateTime: this.getLatestTime('SBJK_BMSDCC'),
|
||||
alarmNum: 0,
|
||||
}
|
||||
})
|
||||
},
|
||||
updateData() {
|
||||
return Promise.all([
|
||||
getProjectDisplayData(this.siteId),
|
||||
this.getClusterDeviceList()
|
||||
]).then(([displayResponse]) => {
|
||||
this.displayData = displayResponse?.data || []
|
||||
this.buildList()
|
||||
}).catch(() => {
|
||||
this.displayData = []
|
||||
this.list = []
|
||||
})
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
uni.showLoading()
|
||||
this.siteId = options.siteId || ''
|
||||
getBMSBatteryCluster({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
this.list = response?.data || []
|
||||
this.updateData().finally(() => {
|
||||
if (this.list.length > 0) {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
// this.$refs.collapse.resize()
|
||||
uni.hideLoading()
|
||||
}, 100)
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
return
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
@ -53,42 +53,6 @@
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
</uni-group>
|
||||
<!-- 子设备表格 -->
|
||||
<uni-group mode="card" class="child-card-group" style="margin-bottom:20rpx;">
|
||||
<uni-table border stripe emptyText="暂无数据" class="child-table">
|
||||
<!-- 表头行 -->
|
||||
<uni-tr>
|
||||
<uni-th align="center">簇号</uni-th>
|
||||
<uni-th align="center">簇电压</uni-th>
|
||||
<uni-th align="center">簇电流</uni-th>
|
||||
<uni-th align="center">簇SOC</uni-th>
|
||||
<uni-th align="center">单体最高电压</uni-th>
|
||||
<uni-th align="center">电池号码</uni-th>
|
||||
<uni-th align="center">单体最低电压</uni-th>
|
||||
<uni-th align="center">电池号码</uni-th>
|
||||
<uni-th align="center">单体最高温度</uni-th>
|
||||
<uni-th align="center">电池号码</uni-th>
|
||||
<uni-th align="center">单体最低温度</uni-th>
|
||||
<uni-th align="center">电池号码</uni-th>
|
||||
</uni-tr>
|
||||
<!-- 表格数据行 -->
|
||||
<uni-tr v-for="(tableItem, tableIndex) in item.batteryDataList"
|
||||
:key="tableIndex+'batteryDataList'">
|
||||
<uni-td align="center">{{tableItem.clusterId}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.clusterVoltage}}V</uni-td>
|
||||
<uni-td align="center">{{tableItem.clusterCurrent}}A</uni-td>
|
||||
<uni-td align="center">{{tableItem.currentSoc}}%</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxCellVoltage}}V</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxCellVoltageId}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.minCellVoltage}}V</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxCellVoltageId}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxCellTemp}}℃</uni-td>
|
||||
<uni-td align="center">{{tableItem.maxCellTempId}}</uni-td>
|
||||
<uni-td align="center">{{tableItem.minCellTemp}}℃</uni-td>
|
||||
<uni-td align="center">{{tableItem.minCellTempId}}</uni-td>
|
||||
</uni-tr>
|
||||
</uni-table>
|
||||
</uni-group>
|
||||
</view>
|
||||
</uni-collapse-item>
|
||||
</uni-collapse>
|
||||
@ -101,7 +65,8 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
getBMSOverView
|
||||
getProjectDisplayData,
|
||||
getStackNameList
|
||||
} from '@/api/ems/site.js'
|
||||
import {
|
||||
mapState
|
||||
@ -117,6 +82,8 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
displayData: [],
|
||||
stackDeviceList: [],
|
||||
list: [],
|
||||
siteId: '',
|
||||
infoData: [{
|
||||
@ -184,6 +151,69 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getModuleRows(menuCode, sectionName) {
|
||||
return (this.displayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
const raw = String(fieldCode || '').trim()
|
||||
if (!raw) return ''
|
||||
const index = raw.lastIndexOf('__')
|
||||
return index >= 0 ? raw.slice(index + 2) : raw
|
||||
},
|
||||
isEmptyValue(value) {
|
||||
return value === undefined || value === null || value === ''
|
||||
},
|
||||
getFieldRowMap(rows = [], deviceId = '') {
|
||||
const map = {}
|
||||
const targetDeviceId = String(deviceId || '')
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== targetDeviceId) return
|
||||
map[this.getFieldName(item.fieldCode)] = item
|
||||
})
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== '') return
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
const existRow = map[fieldName]
|
||||
if (!existRow || this.isEmptyValue(existRow.fieldValue)) {
|
||||
map[fieldName] = item
|
||||
}
|
||||
})
|
||||
return map
|
||||
},
|
||||
getFieldMap(rowMap = {}) {
|
||||
const map = {}
|
||||
Object.keys(rowMap || {}).forEach((fieldName) => {
|
||||
map[fieldName] = rowMap[fieldName]?.fieldValue
|
||||
})
|
||||
return map
|
||||
},
|
||||
buildBaseInfoList() {
|
||||
const devices = (this.stackDeviceList && this.stackDeviceList.length > 0) ? this.stackDeviceList : [{
|
||||
deviceId: this.siteId,
|
||||
deviceName: 'BMS总览'
|
||||
}]
|
||||
this.list = devices.map(device => {
|
||||
const id = device.deviceId || device.id || this.siteId
|
||||
const infoRowMap = this.getFieldRowMap(this.getModuleRows('SBJK_BMSZL', '堆信息'), id)
|
||||
const statusRowMap = this.getFieldRowMap(this.getModuleRows('SBJK_BMSZL', '状态'), id)
|
||||
const infoMap = this.getFieldMap(infoRowMap)
|
||||
const statusMap = this.getFieldMap(statusRowMap)
|
||||
return {
|
||||
...infoMap,
|
||||
workStatus: statusMap.workStatus,
|
||||
pcsCommunicationStatus: statusMap.pcsCommunicationStatus,
|
||||
emsCommunicationStatus: statusMap.emsCommunicationStatus,
|
||||
siteId: this.siteId,
|
||||
deviceId: id,
|
||||
deviceName: device.deviceName || device.name || device.deviceId || device.id || 'BMS总览',
|
||||
batteryDataList: []
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCardClass(item) {
|
||||
const {
|
||||
workStatus = ''
|
||||
@ -191,25 +221,35 @@
|
||||
return !Object.keys(this.STACKWorkStatusOptions).find(i => i === workStatus) ? "timing-collapse-item" :
|
||||
workStatus === '9' ? 'warning-collapse-item' : 'running-collapse-item'
|
||||
},
|
||||
updateData() {
|
||||
return Promise.all([
|
||||
getProjectDisplayData(this.siteId),
|
||||
getStackNameList(this.siteId)
|
||||
]).then(([displayResponse, stackResponse]) => {
|
||||
this.displayData = displayResponse?.data || []
|
||||
this.stackDeviceList = stackResponse?.data || []
|
||||
this.buildBaseInfoList()
|
||||
}).catch(() => {
|
||||
this.displayData = []
|
||||
this.stackDeviceList = []
|
||||
this.list = []
|
||||
})
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
uni.showLoading()
|
||||
this.siteId = options.siteId || ''
|
||||
getBMSOverView({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
this.list = response?.data || []
|
||||
if (this.list.length > 0) {
|
||||
this.updateData().then(() => {
|
||||
if (this.list.length === 0) {
|
||||
uni.hideLoading()
|
||||
return
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.collapse.resize()
|
||||
this.$refs.collapse && this.$refs.collapse.resize()
|
||||
uni.hideLoading()
|
||||
}, 100)
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<view class='content'>
|
||||
<uni-group mode="card" class="data-card-group">
|
||||
<uni-row v-for="(tempDataItem,tempDataIndex) in
|
||||
(deviceIdTypeMsg[item.deviceId] || otherTypeMsg)" :key="tempDataIndex+'dbTempData'" class="data-row">
|
||||
(item.fieldConfigs || otherTypeMsg)" :key="tempDataIndex+'dbTempData'" class="data-row">
|
||||
<uni-col :span="8">
|
||||
<view class="title">{{tempDataItem.name}}</view>
|
||||
</uni-col>
|
||||
@ -42,7 +42,8 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
getAmmeterDataList
|
||||
getProjectDisplayData,
|
||||
getDeviceList
|
||||
} from '@/api/ems/site.js'
|
||||
import {
|
||||
mapState
|
||||
@ -57,108 +58,9 @@
|
||||
data() {
|
||||
return {
|
||||
siteId: '',
|
||||
displayData: [],
|
||||
ammeterDeviceList: [],
|
||||
list: [],
|
||||
deviceIdTypeMsg: {
|
||||
'LOAD': [{
|
||||
name: '正向有功电能',
|
||||
attr: 'forwardActive',
|
||||
pointName: '正向有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '反向有功电能',
|
||||
attr: 'reverseActive',
|
||||
pointName: '反向有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '正向无功电能',
|
||||
attr: 'forwardReactive',
|
||||
pointName: '正向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '反向无功电能',
|
||||
attr: 'reverseReactive',
|
||||
pointName: '反向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '有功功率',
|
||||
attr: 'activePower',
|
||||
pointName: '总有功功率',
|
||||
unit: 'kW'
|
||||
},
|
||||
{
|
||||
name: '无功功率',
|
||||
attr: 'reactivePower',
|
||||
pointName: '总无功功率',
|
||||
unit: 'kvar'
|
||||
}
|
||||
],
|
||||
'METE': [{
|
||||
name: '正向有功电能',
|
||||
attr: 'forwardActive',
|
||||
pointName: '正向有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '反向有功电能',
|
||||
attr: 'reverseActive',
|
||||
pointName: '反向有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '正向无功电能',
|
||||
attr: 'forwardReactive',
|
||||
pointName: '正向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '反向无功电能',
|
||||
attr: 'reverseReactive',
|
||||
pointName: '反向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '有功功率',
|
||||
attr: 'activePower',
|
||||
pointName: '总有功功率',
|
||||
unit: 'kW'
|
||||
},
|
||||
{
|
||||
name: '无功功率',
|
||||
attr: 'reactivePower',
|
||||
pointName: '总无功功率',
|
||||
unit: 'kvar'
|
||||
}
|
||||
],
|
||||
'METEGF': [{
|
||||
name: '有功电能',
|
||||
attr: 'activeEnergy',
|
||||
pointName: '有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '无功电能',
|
||||
attr: 'reactiveEnergy',
|
||||
pointName: '无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '有功功率',
|
||||
attr: 'activePower',
|
||||
pointName: '总有功功率',
|
||||
unit: 'kW'
|
||||
},
|
||||
{
|
||||
name: '无功功率',
|
||||
attr: 'reactivePower',
|
||||
pointName: '总无功功率',
|
||||
unit: 'kvar'
|
||||
}
|
||||
]
|
||||
},
|
||||
otherTypeMsg: [{
|
||||
name: '正向有功电能',
|
||||
attr: 'forwardActive',
|
||||
@ -171,28 +73,141 @@
|
||||
pointName: '反向有功电能',
|
||||
unit: 'kWh'
|
||||
},
|
||||
{
|
||||
name: '正向无功电能',
|
||||
attr: 'forwardReactive',
|
||||
pointName: '正向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '反向无功电能',
|
||||
attr: 'reverseReactive',
|
||||
pointName: '反向无功电能',
|
||||
unit: 'kvarh'
|
||||
},
|
||||
{
|
||||
name: '有功功率',
|
||||
attr: 'activePower',
|
||||
pointName: '总有功功率',
|
||||
unit: 'kW'
|
||||
},
|
||||
{
|
||||
name: '无功功率',
|
||||
attr: 'reactivePower',
|
||||
pointName: '总无功功率',
|
||||
unit: 'kvar'
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getModuleRows(menuCode) {
|
||||
return (this.displayData || []).filter(item => item.menuCode === menuCode)
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
const raw = String(fieldCode || '').trim()
|
||||
if (!raw) return ''
|
||||
const index = raw.lastIndexOf('__')
|
||||
return index >= 0 ? raw.slice(index + 2) : raw
|
||||
},
|
||||
isEmptyValue(value) {
|
||||
return value === undefined || value === null || value === ''
|
||||
},
|
||||
getFieldRowMap(rows = [], deviceId = '') {
|
||||
const map = {}
|
||||
const targetDeviceId = String(deviceId || '')
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== targetDeviceId) return
|
||||
map[this.getFieldName(item.fieldCode)] = item
|
||||
})
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = String(item.deviceId || '')
|
||||
if (itemDeviceId !== '') return
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
const existRow = map[fieldName]
|
||||
if (!existRow || this.isEmptyValue(existRow.fieldValue)) {
|
||||
map[fieldName] = item
|
||||
}
|
||||
})
|
||||
return map
|
||||
},
|
||||
getFieldConfigs(rows = []) {
|
||||
const result = []
|
||||
const seen = {}
|
||||
(rows || []).forEach(item => {
|
||||
const attr = this.getFieldName(item?.fieldCode)
|
||||
const name = String(item?.fieldName || '').trim()
|
||||
if (!attr || !name || seen[name]) return
|
||||
const base = this.otherTypeMsg.find(i => i.attr === attr) || {}
|
||||
result.push({
|
||||
name,
|
||||
attr,
|
||||
pointName: base.pointName || name,
|
||||
unit: base.unit || ''
|
||||
})
|
||||
seen[name] = true
|
||||
})
|
||||
return result.length > 0 ? result : this.otherTypeMsg
|
||||
},
|
||||
buildList() {
|
||||
const rows = this.getModuleRows('SBJK_DB')
|
||||
const fieldConfigs = this.getFieldConfigs(rows)
|
||||
let devices = (this.ammeterDeviceList || []).filter(item => item.deviceCategory === 'AMMETER')
|
||||
if (devices.length === 0) {
|
||||
const grouped = {}
|
||||
rows.forEach(item => {
|
||||
const id = String(item?.deviceId || '').trim()
|
||||
if (!id || grouped[id]) return
|
||||
grouped[id] = {
|
||||
deviceId: id,
|
||||
deviceName: id
|
||||
}
|
||||
})
|
||||
devices = Object.values(grouped)
|
||||
}
|
||||
if (devices.length === 0) {
|
||||
devices = [{
|
||||
deviceId: '',
|
||||
deviceName: '电表'
|
||||
}]
|
||||
}
|
||||
this.list = devices.map(device => {
|
||||
const id = String(device.deviceId || device.id || '').trim()
|
||||
const fieldRowMap = this.getFieldRowMap(rows, id)
|
||||
const statusValue = fieldRowMap.communicationStatus?.fieldValue || fieldRowMap.emsCommunicationStatus?.fieldValue || ''
|
||||
const values = {}
|
||||
fieldConfigs.forEach(cfg => {
|
||||
values[cfg.attr] = fieldRowMap[cfg.attr]?.fieldValue
|
||||
})
|
||||
return {
|
||||
...values,
|
||||
deviceId: id,
|
||||
deviceName: device.deviceName || device.name || id || '电表',
|
||||
emsCommunicationStatus: String(statusValue || ''),
|
||||
fieldConfigs
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
uni.showLoading()
|
||||
this.siteId = options.siteId || ''
|
||||
getAmmeterDataList({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
this.list = response?.data || []
|
||||
Promise.all([
|
||||
getProjectDisplayData(this.siteId),
|
||||
getDeviceList(this.siteId)
|
||||
]).then(([displayResponse, deviceResponse]) => {
|
||||
this.displayData = displayResponse?.data || []
|
||||
this.ammeterDeviceList = deviceResponse?.data || []
|
||||
this.buildList()
|
||||
if (this.list.length > 0) {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.collapse.resize()
|
||||
uni.hideLoading()
|
||||
}, 1000)
|
||||
}, 100)
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
|
||||
@ -330,9 +330,7 @@
|
||||
}
|
||||
},
|
||||
getStackList() {
|
||||
getStackNameList({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
getStackNameList(this.siteId).then(response => {
|
||||
this.stackOptions = JSON.parse(JSON.stringify(response?.data || [])).map(item => {
|
||||
return {
|
||||
text: item.deviceName,
|
||||
|
||||
@ -1,32 +1,20 @@
|
||||
<template>
|
||||
<view class="work-container">
|
||||
<view class="site-sections-list">
|
||||
<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>
|
||||
<site-switch-header :site-id="siteId" :site-type-options="siteTypeOptions" :site-address="baseInfo.siteAddress"
|
||||
:running-time="baseInfo.runningTime" @change="selectedSite" />
|
||||
<!-- 静态信息 -->
|
||||
<view class="base-info">
|
||||
<uni-group mode="card" class="install-data">
|
||||
<uni-grid :column="2" :showBorder="false" :square="false" :highlight="false">
|
||||
<uni-grid-item>
|
||||
<view class="grid-item-box">
|
||||
<view class="title">装机功率(MW)</view>
|
||||
<view class="title">装机功率(MWh)</view>
|
||||
<view class="text">{{baseInfo.installPower | formatNumber}}</view>
|
||||
</view>
|
||||
</uni-grid-item>
|
||||
<uni-grid-item>
|
||||
<view class="grid-item-box">
|
||||
<view class="title">装机容量(MW)</view>
|
||||
<view class="title">装机容量(MWh)</view>
|
||||
<view class="text">{{baseInfo.installCapacity | formatNumber}}</view>
|
||||
</view>
|
||||
</uni-grid-item>
|
||||
@ -70,16 +58,34 @@
|
||||
mapGetters
|
||||
} from 'vuex'
|
||||
import DateRangeSelect from './DateRangeSelect.vue'
|
||||
import SiteSwitchHeader from '@/components/SiteSwitchHeader/index.vue'
|
||||
import {
|
||||
getAllSites,
|
||||
getSingleSiteBaseInfo,
|
||||
getSevenChargeData,
|
||||
getPointData,
|
||||
getProjectDisplayData,
|
||||
getPointConfigCurve,
|
||||
getSiteAllDeviceCategory
|
||||
} from '@/api/ems/site.js'
|
||||
const createSiteTypeOptions = () => ([{
|
||||
text: '储能',
|
||||
value: 'cn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '光能',
|
||||
value: 'gn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '岸电',
|
||||
value: 'ad',
|
||||
children: []
|
||||
}
|
||||
])
|
||||
export default {
|
||||
components: {
|
||||
DateRangeSelect
|
||||
DateRangeSelect,
|
||||
SiteSwitchHeader
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -88,6 +94,8 @@
|
||||
activeChartTimeRange: [],
|
||||
weekChartData: {},
|
||||
activeChartData: {},
|
||||
curveDisplayData: [],
|
||||
curveDisplayLoadingPromise: null,
|
||||
pageScrollTop: 0,
|
||||
glqxOptions: {
|
||||
padding: [10, 5, 0, 10],
|
||||
@ -141,24 +149,7 @@
|
||||
},
|
||||
// 图表数据结束
|
||||
deviceCategoryOptions: [], //当前站点包含的设备类别
|
||||
siteTypeOptions: [{
|
||||
text: '储能',
|
||||
value: 'cn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '光能',
|
||||
value: 'gn',
|
||||
disable: true,
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '岸电',
|
||||
value: 'ad',
|
||||
disable: true,
|
||||
children: []
|
||||
}
|
||||
],
|
||||
siteTypeOptions: createSiteTypeOptions(),
|
||||
siteId: '', //选择的站点ID
|
||||
baseInfo: {}, //站点基本信息
|
||||
gridList: [{
|
||||
@ -185,6 +176,12 @@
|
||||
text: '电表',
|
||||
categoryName: 'AMMETER'
|
||||
},
|
||||
{
|
||||
page: 'yl',
|
||||
icon: 'icon-gongneng-diandongji',
|
||||
text: '冷却',
|
||||
categoryName: 'COOLING'
|
||||
},
|
||||
{
|
||||
page: 'dtdc',
|
||||
icon: 'icon-dantidianchi',
|
||||
@ -195,12 +192,19 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['belongSite']),
|
||||
...mapGetters(['belongSite', 'currentSiteId']),
|
||||
siteGirdList() {
|
||||
return this.gridList.filter(i => this.deviceCategoryOptions.includes(i.categoryName))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
isAvailableSite(siteId) {
|
||||
const allSites = this.siteTypeOptions.reduce((result, typeItem) => {
|
||||
return result.concat(typeItem.children || [])
|
||||
}, [])
|
||||
const site = allSites.find(item => item.value === siteId)
|
||||
return !!(site && !site.disable)
|
||||
},
|
||||
// 更新一周冲放曲线时间范围 重置图表
|
||||
updateWeekChartDate(data) {
|
||||
this.weekChartTimeRange = data || []
|
||||
@ -222,41 +226,159 @@
|
||||
this.$tab.navigateTo(`/pages/work/${this.siteGirdList[index].page}/index?siteId=${this.siteId}`)
|
||||
},
|
||||
selectedSite(data) {
|
||||
const [typeObj, siteObj] = data.detail.value
|
||||
const {
|
||||
text,
|
||||
value
|
||||
} = siteObj
|
||||
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) return
|
||||
this.curveDisplayData = []
|
||||
this.curveDisplayLoadingPromise = null
|
||||
this.getSiteBaseInfo()
|
||||
this.getWeekChartData()
|
||||
this.getGVQXData()
|
||||
this.getSiteDeviceCategory()
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
const raw = String(fieldCode || '').trim()
|
||||
if (!raw) return ''
|
||||
const index = raw.lastIndexOf('__')
|
||||
return index >= 0 ? raw.slice(index + 2) : raw
|
||||
},
|
||||
normalizeDateTime(value, endOfDay) {
|
||||
const raw = String(value || '').trim()
|
||||
if (!raw) return ''
|
||||
if (raw.includes(' ')) return raw
|
||||
return `${raw} ${endOfDay ? '23:59:59' : '00:00:00'}`
|
||||
},
|
||||
parseToTimestamp(value) {
|
||||
if (!value) return null
|
||||
const timestamp = new Date(value).getTime()
|
||||
return Number.isNaN(timestamp) ? null : timestamp
|
||||
},
|
||||
ensureCurveDisplayData() {
|
||||
if (!this.siteId) return Promise.resolve([])
|
||||
if (this.curveDisplayData.length > 0) return Promise.resolve(this.curveDisplayData)
|
||||
if (this.curveDisplayLoadingPromise) return this.curveDisplayLoadingPromise
|
||||
this.curveDisplayLoadingPromise = getProjectDisplayData(this.siteId)
|
||||
.then(response => {
|
||||
this.curveDisplayData = response?.data || []
|
||||
return this.curveDisplayData
|
||||
})
|
||||
.catch(() => {
|
||||
this.curveDisplayData = []
|
||||
return []
|
||||
})
|
||||
.finally(() => {
|
||||
this.curveDisplayLoadingPromise = null
|
||||
})
|
||||
return this.curveDisplayLoadingPromise
|
||||
},
|
||||
fetchCurveSeries(pointId, name, startTime, endTime) {
|
||||
if (!pointId) return Promise.resolve(null)
|
||||
return getPointConfigCurve({
|
||||
siteId: this.siteId,
|
||||
pointId,
|
||||
pointType: 'data',
|
||||
rangeType: 'custom',
|
||||
startTime,
|
||||
endTime
|
||||
}).then(response => {
|
||||
const list = response?.data || []
|
||||
const points = list.map(item => {
|
||||
const timestamp = this.parseToTimestamp(item.dataTime)
|
||||
const value = Number(item.pointValue)
|
||||
if (!timestamp || Number.isNaN(value)) return null
|
||||
return {
|
||||
timestamp,
|
||||
label: item.dataTime,
|
||||
value
|
||||
}
|
||||
}).filter(Boolean)
|
||||
return {
|
||||
name,
|
||||
points
|
||||
}
|
||||
}).catch(() => null)
|
||||
},
|
||||
buildLineChartData(seriesList) {
|
||||
const validSeries = (seriesList || []).filter(item => item && (item.points || []).length > 0)
|
||||
if (validSeries.length === 0) {
|
||||
return {
|
||||
categories: [],
|
||||
series: []
|
||||
}
|
||||
}
|
||||
const labelByTimestamp = {}
|
||||
const timestampSet = new Set()
|
||||
validSeries.forEach(item => {
|
||||
item.points.forEach(point => {
|
||||
timestampSet.add(point.timestamp)
|
||||
if (!labelByTimestamp[point.timestamp]) {
|
||||
labelByTimestamp[point.timestamp] = point.label
|
||||
}
|
||||
})
|
||||
})
|
||||
const sortedTimestamps = Array.from(timestampSet).sort((a, b) => a - b)
|
||||
const categories = sortedTimestamps.map(item => labelByTimestamp[item])
|
||||
const series = validSeries.map(item => {
|
||||
const pointMap = {}
|
||||
item.points.forEach(point => {
|
||||
pointMap[point.timestamp] = point.value
|
||||
})
|
||||
return {
|
||||
name: item.name,
|
||||
data: sortedTimestamps.map(timestamp => pointMap[timestamp] ?? null)
|
||||
}
|
||||
})
|
||||
return {
|
||||
categories,
|
||||
series
|
||||
}
|
||||
},
|
||||
findActiveCurveRow(sectionRows, keywords = []) {
|
||||
const keywordSet = new Set((keywords || []).map(item => String(item || '').toLowerCase()))
|
||||
return (sectionRows || []).find(row => {
|
||||
const fieldCode = this.getFieldName(row?.fieldCode).toLowerCase()
|
||||
const fieldName = String(row?.fieldName || '').toLowerCase()
|
||||
if (keywordSet.has(fieldCode) || keywordSet.has(fieldName)) return true
|
||||
return Array.from(keywordSet).some(keyword => fieldCode.includes(keyword) || fieldName.includes(keyword))
|
||||
})
|
||||
},
|
||||
getSiteList() {
|
||||
getAllSites().then(response => {
|
||||
const data = response?.data || []
|
||||
this.siteTypeOptions.find(i => i.value === 'cn').children = data.map(item => {
|
||||
return {
|
||||
const canAccessAll = !this.belongSite || this.belongSite.length === 0 || this.belongSite.includes('all')
|
||||
const siteTypeOptions = createSiteTypeOptions().map(item => ({
|
||||
...item,
|
||||
children: []
|
||||
}))
|
||||
data.forEach(item => {
|
||||
if (!canAccessAll && !this.belongSite.includes(item.siteId)) return
|
||||
const siteType = (item.siteType || item.type || 'cn').toString().toLowerCase()
|
||||
const typeOption = siteTypeOptions.find(i => i.value === siteType) || siteTypeOptions.find(i => i.value === 'cn')
|
||||
if (!typeOption) return
|
||||
typeOption.children.push({
|
||||
text: item.siteName,
|
||||
value: item.siteId,
|
||||
id: item.id,
|
||||
disable: !this.belongSite || this.belongSite.length === 0 || this
|
||||
.belongSite.includes('all') ? false : !this.belongSite.includes(item
|
||||
.siteId)
|
||||
}
|
||||
id: item.id
|
||||
})
|
||||
})
|
||||
this.siteTypeOptions = siteTypeOptions.filter(item => (item.children || []).length > 0)
|
||||
const siteChildren = this.siteTypeOptions.reduce((result, typeItem) => {
|
||||
return result.concat(typeItem.children || [])
|
||||
}, [])
|
||||
// 设置默认展示的站点
|
||||
this.siteId = this.siteTypeOptions.find(i => i.children && i.children.length > 0)?.children
|
||||
.find(
|
||||
item => !item
|
||||
.disable)?.value || ''
|
||||
this.siteId && this.updateSiteInfo()
|
||||
const defaultSiteId = this.isAvailableSite(this.currentSiteId) ? this.currentSiteId : (siteChildren[0]?.value || '')
|
||||
if (defaultSiteId) {
|
||||
this.siteId = defaultSiteId
|
||||
this.$store.commit('SET_CURRENTSITEID', defaultSiteId)
|
||||
this.updateSiteInfo()
|
||||
}
|
||||
})
|
||||
},
|
||||
getSiteBaseInfo() {
|
||||
@ -283,94 +405,61 @@
|
||||
},
|
||||
getGVQXData() {
|
||||
this.$refs.activeChartDateRangeSelect.showBtnLoading(true)
|
||||
getPointData({
|
||||
siteId: this.siteId,
|
||||
startDate: this.activeChartTimeRange[0],
|
||||
endDate: this.activeChartTimeRange[1]
|
||||
}).then(response => {
|
||||
console.log('当日功率曲线', response)
|
||||
let data = response?.data || [],
|
||||
categories = [],
|
||||
source = [{
|
||||
const startTime = this.normalizeDateTime(this.activeChartTimeRange[0], false)
|
||||
const endTime = this.normalizeDateTime(this.activeChartTimeRange[1], true)
|
||||
this.ensureCurveDisplayData().then(displayData => {
|
||||
const sectionRows = (displayData || []).filter(item =>
|
||||
item && item.sectionName === '当日功率曲线' && item.useFixedDisplay !== 1 && item.dataPoint
|
||||
)
|
||||
const targetRows = [{
|
||||
name: '电网功率',
|
||||
attr: 'gridPower',
|
||||
data: []
|
||||
row: this.findActiveCurveRow(sectionRows, ['gridpower', '电网功率'])
|
||||
},
|
||||
{
|
||||
name: '负载功率',
|
||||
attr: 'loadPower',
|
||||
data: []
|
||||
row: this.findActiveCurveRow(sectionRows, ['loadpower', '负载功率'])
|
||||
},
|
||||
{
|
||||
name: '储能功率',
|
||||
attr: 'storagePower',
|
||||
data: []
|
||||
},
|
||||
{
|
||||
name: '光伏功率',
|
||||
attr: 'pvPower',
|
||||
data: []
|
||||
},
|
||||
{
|
||||
name: 'soc平均值',
|
||||
attr: 'avgSoc',
|
||||
data: []
|
||||
},
|
||||
{
|
||||
name: 'soh平均值',
|
||||
attr: 'avgSoh',
|
||||
data: []
|
||||
},
|
||||
{
|
||||
name: '电池平均温度平均值平均值',
|
||||
attr: 'avgTemp',
|
||||
data: []
|
||||
},
|
||||
|
||||
]
|
||||
data.forEach((item) => {
|
||||
categories.push(item.statisDate || undefined)
|
||||
source.forEach(i => i.data.push(item[i.attr]))
|
||||
row: this.findActiveCurveRow(sectionRows, ['storagepower', '储能功率'])
|
||||
}
|
||||
].filter(item => item.row && item.row.dataPoint)
|
||||
const tasks = targetRows.map(item => this.fetchCurveSeries(String(item.row.dataPoint).trim(), item.name, startTime,
|
||||
endTime))
|
||||
return Promise.all(tasks).then(series => {
|
||||
this.activeChartData = JSON.parse(JSON.stringify(this.buildLineChartData((series || []).filter(Boolean))))
|
||||
})
|
||||
this.activeChartData = JSON.parse(JSON.stringify({
|
||||
categories,
|
||||
series: source
|
||||
}))
|
||||
}).finally(() => this.$refs.activeChartDateRangeSelect.showBtnLoading(false))
|
||||
|
||||
},
|
||||
getWeekChartData() {
|
||||
this.$refs.weekChartDateRangeSelect.showBtnLoading(true)
|
||||
getSevenChargeData({
|
||||
siteId: this.siteId,
|
||||
startDate: this.weekChartTimeRange[0],
|
||||
endDate: this.weekChartTimeRange[1]
|
||||
}).then(response => {
|
||||
console.log('一周功率曲线', response)
|
||||
let data = response?.data || [],
|
||||
categories = [],
|
||||
chargedCap = [],
|
||||
disChargedCap = []
|
||||
data.forEach(item => {
|
||||
categories.push(this.handleDate(item.ammeterDate) || undefined)
|
||||
chargedCap.push(item.chargedCap)
|
||||
disChargedCap.push(item.disChargedCap)
|
||||
const startTime = this.normalizeDateTime(this.weekChartTimeRange[0], false)
|
||||
const endTime = this.normalizeDateTime(this.weekChartTimeRange[1], true)
|
||||
this.ensureCurveDisplayData().then(displayData => {
|
||||
const sectionRows = (displayData || []).filter(item =>
|
||||
item && item.sectionName === '一周充放曲线' && item.useFixedDisplay !== 1 && item.dataPoint
|
||||
)
|
||||
const tasks = sectionRows.map(row => {
|
||||
const pointId = String(row.dataPoint || '').trim()
|
||||
if (!pointId) return Promise.resolve(null)
|
||||
const name = row.fieldName || this.getFieldName(row.fieldCode) || pointId
|
||||
return this.fetchCurveSeries(pointId, name, startTime, endTime)
|
||||
})
|
||||
return Promise.all(tasks).then(series => {
|
||||
this.weekChartData = JSON.parse(JSON.stringify(this.buildLineChartData((series || []).filter(Boolean))))
|
||||
})
|
||||
this.weekChartData = JSON.parse(JSON.stringify({
|
||||
categories,
|
||||
series: [{
|
||||
"name": '充电量',
|
||||
"data": chargedCap
|
||||
},
|
||||
{
|
||||
"name": '放电量',
|
||||
"data": disChargedCap
|
||||
}
|
||||
]
|
||||
}))
|
||||
}).finally(() => this.$refs.weekChartDateRangeSelect.showBtnLoading(false))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
currentSiteId(newSiteId) {
|
||||
if (!newSiteId || newSiteId === this.siteId) return
|
||||
if (!this.isAvailableSite(newSiteId)) return
|
||||
this.siteId = newSiteId
|
||||
this.updateSiteInfo()
|
||||
}
|
||||
},
|
||||
// 页面切换不会重新调用,如果希望每次切换页面都重新调接口,使用onShow
|
||||
onLoad() {
|
||||
this.$nextTick(() => {
|
||||
@ -410,77 +499,6 @@
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
// 站点选择
|
||||
.site-sections-list {
|
||||
background: linear-gradient(to right, #547ef4, #679ff5);
|
||||
padding: 30rpx 30rpx;
|
||||
padding-bottom: 100rpx;
|
||||
|
||||
.info {
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
line-height: 30rpx;
|
||||
vertical-align: middle;
|
||||
margin-top: 20rpx;
|
||||
|
||||
>.list {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
>.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 {
|
||||
margin-top: -80rpx;
|
||||
|
||||
@ -1,24 +1,48 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<!-- 顶部6个数据 -->
|
||||
<uni-grid class="info-grid" :square="false" :column="2" :showBorder="false">
|
||||
<uni-grid-item v-for="(item,index) in runningHeadData" :key="index+'head'">
|
||||
<!-- 顶部总览横向展示 -->
|
||||
<scroll-view class="info-overview-scroll" scroll-x>
|
||||
<view class="info-overview-row">
|
||||
<view class="info-overview-card" v-for="(item,index) in runningHeadCards" :key="index+'head'">
|
||||
<view class="grid-item-box">
|
||||
<image :src="require('@/static/images/ems/pcs/'+item.img+'.jpg')" class="icon" alt=""/>
|
||||
<image :src="require('@/static/images/ems/pcs/'+item.img+'.jpg')" class="icon" alt="" />
|
||||
<view class="title">{{item.title}}</view>
|
||||
<view class="text">{{runningHeadInfo[item.attr] | formatNumber}}</view>
|
||||
<view class="text">{{item.value | formatNumber}}</view>
|
||||
</view>
|
||||
</uni-grid-item>
|
||||
</uni-grid>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<uni-collapse ref="collapse" accordion v-if="list.length > 0">
|
||||
<uni-collapse-item v-for="(item,index) in list" :key="index+'pcs'" :open="index===0"
|
||||
<!-- 设备标签横向展示 -->
|
||||
<scroll-view class="pcs-tags-scroll" scroll-x>
|
||||
<view class="pcs-tags-row">
|
||||
<view
|
||||
class="pcs-tag-item"
|
||||
:class="{ active: !selectedPcsId }"
|
||||
@click="handleTagClick('')"
|
||||
>
|
||||
全部
|
||||
</view>
|
||||
<view
|
||||
v-for="(item, index) in pcsDeviceList"
|
||||
:key="index + 'pcsTag'"
|
||||
class="pcs-tag-item"
|
||||
:class="{ active: selectedPcsId === (item.deviceId || item.id || '') }"
|
||||
@click="handleTagClick(item.deviceId || item.id || '')"
|
||||
>
|
||||
{{ item.deviceName || item.deviceId || item.id || 'PCS' }}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<uni-collapse ref="collapse" accordion v-if="filteredList.length > 0">
|
||||
<uni-collapse-item v-for="(item,index) in filteredList" :key="index+'pcs'" :open="index===0"
|
||||
class="common-collapse-item" :class="handleCardClass(item)">
|
||||
|
||||
<template v-slot:title>
|
||||
<view class='title-wrapper'>
|
||||
<view class="top">
|
||||
<view class="status">{{PCSWorkStatusOptions[item.workStatus] || '暂无数据'}}</view>
|
||||
<view class="status">{{formatDictValue((PCSWorkStatusOptions || {}), item.workStatus, '暂无数据')}}</view>
|
||||
<text class="name">{{item.deviceName}}</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -31,25 +55,25 @@
|
||||
<view class="grid-item-box">
|
||||
<view class="title">工作状态</view>
|
||||
<text
|
||||
class="text work-status-color">{{PCSWorkStatusOptions[item.workStatus] || '-'}}</text>
|
||||
class="text work-status-color">{{formatDictValue((PCSWorkStatusOptions || {}), item.workStatus)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-lists">
|
||||
<view class="grid-item-box">
|
||||
<view class="title">并网状态</view>
|
||||
<text class="text">{{gridStatusOptions[item.gridStatus] || '-'}}</text>
|
||||
<text class="text">{{formatDictValue((gridStatusOptions || {}), item.gridStatus)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-lists">
|
||||
<view class="grid-item-box">
|
||||
<view class="title">设备状态</view>
|
||||
<text class="text">{{deviceStatusOptions[item.deviceStatus] || '-'}}</text>
|
||||
<text class="text">{{formatDictValue((deviceStatusOptions || {}), item.deviceStatus)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-lists">
|
||||
<view class="grid-item-box">
|
||||
<view class="title">控制模式</view>
|
||||
<text class="text">{{controlModeOptions[item.controlMode] || '-'}}</text>
|
||||
<text class="text">{{formatDictValue((controlModeOptions || {}), item.controlMode)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -106,8 +130,8 @@
|
||||
|
||||
<script>
|
||||
import {
|
||||
getRunningHeadInfo,
|
||||
getPcsDetailInfo
|
||||
getProjectDisplayData,
|
||||
getPcsNameList
|
||||
} from '@/api/ems/site.js'
|
||||
import {
|
||||
mapState
|
||||
@ -125,42 +149,27 @@
|
||||
state.ems.gridStatusOptions,
|
||||
controlModeOptions: (state) =>
|
||||
state.ems.controlModeOptions,
|
||||
})
|
||||
}),
|
||||
runningHeadCards() {
|
||||
const sectionData = (this.runningDisplayData || []).filter(item => item.sectionName === '运行概览')
|
||||
return sectionData.map((item, index) => ({
|
||||
title: item.fieldName,
|
||||
value: item.fieldValue,
|
||||
img: this.getHeadCardImg(item, index)
|
||||
}))
|
||||
},
|
||||
filteredList() {
|
||||
if (!this.selectedPcsId) {
|
||||
return this.list || []
|
||||
}
|
||||
return (this.list || []).filter(item => (item.deviceId || '') === this.selectedPcsId)
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
runningHeadData: [{
|
||||
title: '实时有功功率(kW)',
|
||||
bgColor: '#FFF2CB',
|
||||
attr: 'totalActivePower',
|
||||
img: 'ssyggl'
|
||||
}, {
|
||||
title: '实时无功功率(kVar)',
|
||||
bgColor: '#CBD6FF',
|
||||
attr: 'totalReactivePower',
|
||||
img: 'sswggl'
|
||||
}, {
|
||||
title: '电池堆SOC',
|
||||
bgColor: '#DCCBFF',
|
||||
attr: 'soc',
|
||||
img: 'soc'
|
||||
}, {
|
||||
title: '电池堆SOH',
|
||||
bgColor: '#FFD4CB',
|
||||
attr: 'soh',
|
||||
img: 'soh'
|
||||
}, {
|
||||
title: '今日充电量(kWh)',
|
||||
bgColor: '#FFD6F8',
|
||||
attr: 'dayChargedCap',
|
||||
img: 'jrcdl'
|
||||
}, {
|
||||
title: '今日放电量(kWh)',
|
||||
bgColor: '#E1FFCA',
|
||||
attr: 'dayDisChargedCap',
|
||||
img: 'jrfdl'
|
||||
}],
|
||||
runningHeadInfo: {},
|
||||
runningDisplayData: [],
|
||||
pcsDeviceList: [],
|
||||
selectedPcsId: '',
|
||||
list: [],
|
||||
siteId: '',
|
||||
infoData: [{
|
||||
@ -259,27 +268,139 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
normalizeDictKey(value) {
|
||||
const raw = String(value == null ? '' : value).trim()
|
||||
if (!raw) return ''
|
||||
if (/^-?\d+(\.0+)?$/.test(raw)) {
|
||||
return String(parseInt(raw, 10))
|
||||
}
|
||||
return raw
|
||||
},
|
||||
formatDictValue(options, value, emptyText = '-') {
|
||||
const dict = (options && typeof options === 'object') ? options : {}
|
||||
const key = this.normalizeDictKey(value)
|
||||
if (!key) return emptyText
|
||||
return dict[key] || key
|
||||
},
|
||||
normalizeDeviceId(value) {
|
||||
return String(value == null ? '' : value).trim().toUpperCase()
|
||||
},
|
||||
getModuleRows(menuCode, sectionName) {
|
||||
return (this.runningDisplayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
if (!fieldCode) {
|
||||
return ''
|
||||
}
|
||||
const index = fieldCode.lastIndexOf('__')
|
||||
return index >= 0 ? fieldCode.slice(index + 2) : fieldCode
|
||||
},
|
||||
getFieldRowMap(rows = [], deviceId = '') {
|
||||
const map = {}
|
||||
const targetDeviceId = this.normalizeDeviceId(deviceId || '')
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) {
|
||||
return
|
||||
}
|
||||
const itemDeviceId = this.normalizeDeviceId(item.deviceId || '')
|
||||
if (itemDeviceId !== targetDeviceId) {
|
||||
return
|
||||
}
|
||||
map[this.getFieldName(item.fieldCode)] = item
|
||||
})
|
||||
rows.forEach(item => {
|
||||
if (!item || !item.fieldCode) {
|
||||
return
|
||||
}
|
||||
const itemDeviceId = this.normalizeDeviceId(item.deviceId || '')
|
||||
if (itemDeviceId !== '') {
|
||||
return
|
||||
}
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
if (map[fieldName] === undefined || map[fieldName] === null || map[fieldName] === '') {
|
||||
map[fieldName] = item
|
||||
}
|
||||
})
|
||||
return map
|
||||
},
|
||||
getFieldMap(rows = [], deviceId = '') {
|
||||
const rowMap = this.getFieldRowMap(rows, deviceId)
|
||||
return Object.keys(rowMap).reduce((acc, fieldName) => {
|
||||
const row = rowMap[fieldName] || {}
|
||||
acc[fieldName] = row.fieldValue
|
||||
return acc
|
||||
}, {})
|
||||
},
|
||||
getLatestTime(menuCode) {
|
||||
const times = (this.runningDisplayData || [])
|
||||
.filter(item => item.menuCode === menuCode && item.valueTime)
|
||||
.map(item => new Date(item.valueTime).getTime())
|
||||
.filter(ts => !isNaN(ts))
|
||||
if (times.length === 0) {
|
||||
return '-'
|
||||
}
|
||||
const date = new Date(Math.max(...times))
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${p(date.getMonth() + 1)}-${p(date.getDate())} ${p(date.getHours())}:${p(date.getMinutes())}:${p(date.getSeconds())}`
|
||||
},
|
||||
getPcsDeviceList() {
|
||||
return getPcsNameList(this.siteId).then((response) => {
|
||||
this.pcsDeviceList = response?.data || []
|
||||
}).catch(() => {
|
||||
this.pcsDeviceList = []
|
||||
})
|
||||
},
|
||||
buildPcsList() {
|
||||
const devices = this.pcsDeviceList || []
|
||||
this.list = devices.map((device) => ({
|
||||
...this.getFieldMap(this.getModuleRows('SBJK_PCS', '电参量'), device.deviceId || device.id || ''),
|
||||
deviceId: device.deviceId || device.id || '',
|
||||
deviceName: device.deviceName || device.name || device.deviceId || device.id || 'PCS',
|
||||
...this.getFieldMap(this.getModuleRows('SBJK_PCS', '状态'), device.deviceId || device.id || ''),
|
||||
dataUpdateTime: this.getLatestTime('SBJK_PCS'),
|
||||
alarmNum: 0,
|
||||
pcsBranchInfoList: [],
|
||||
}))
|
||||
},
|
||||
getHeadCardImg(item, index) {
|
||||
const imgMap = {
|
||||
totalActivePower: 'ssyggl',
|
||||
totalReactivePower: 'sswggl',
|
||||
soc: 'soc',
|
||||
soh: 'soh',
|
||||
dayChargedCap: 'jrcdl',
|
||||
dayChargedCap_rt: 'jrcdl',
|
||||
dayDisChargedCap: 'jrfdl',
|
||||
dayDisChargedCap_rt: 'jrfdl'
|
||||
}
|
||||
const defaultImgs = ['ssyggl', 'sswggl', 'soc', 'soh', 'jrcdl', 'jrfdl']
|
||||
return imgMap[item.fieldCode] || defaultImgs[index % defaultImgs.length]
|
||||
},
|
||||
handleCardClass(item) {
|
||||
const {
|
||||
workStatus = ''
|
||||
} = item
|
||||
return workStatus === '1' || !Object.keys(this.PCSWorkStatusOptions).find(i => i === workStatus) ?
|
||||
"timing-collapse-item" : workStatus === '2' ? 'warning-collapse-item' : 'running-collapse-item'
|
||||
const workStatus = this.normalizeDictKey((item && item.workStatus) || '')
|
||||
const statusOptions = (this.PCSWorkStatusOptions && typeof this.PCSWorkStatusOptions === 'object')
|
||||
? this.PCSWorkStatusOptions
|
||||
: {}
|
||||
const hasStatus = Object.prototype.hasOwnProperty.call(statusOptions, workStatus)
|
||||
return workStatus === '1' || !hasStatus
|
||||
? "timing-collapse-item"
|
||||
: workStatus === '2'
|
||||
? 'warning-collapse-item'
|
||||
: 'running-collapse-item'
|
||||
},
|
||||
handleTagClick(deviceId) {
|
||||
this.selectedPcsId = deviceId || ''
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
uni.showLoading()
|
||||
this.siteId = options.siteId || ''
|
||||
getRunningHeadInfo({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
this.runningHeadInfo = response?.data || {}
|
||||
})
|
||||
|
||||
getPcsDetailInfo({
|
||||
siteId: this.siteId
|
||||
}).then(response => {
|
||||
this.list = response?.data || []
|
||||
Promise.all([
|
||||
getProjectDisplayData(this.siteId),
|
||||
this.getPcsDeviceList()
|
||||
]).then(([displayResponse]) => {
|
||||
this.runningDisplayData = displayResponse?.data || []
|
||||
this.buildPcsList()
|
||||
if (this.list.length > 0) {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
@ -297,23 +418,36 @@
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.info-grid {
|
||||
.info-overview-scroll {
|
||||
background: #fff;
|
||||
padding: 0 20rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uni-grid-item {
|
||||
padding: 20rpx;
|
||||
.info-overview-row {
|
||||
display: inline-flex;
|
||||
gap: 20rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.info-overview-card {
|
||||
width: 280rpx;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.grid-item-box {
|
||||
box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.08);
|
||||
border-radius: 20rpx;
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.title {
|
||||
.grid-item-box .title {
|
||||
color: #333;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
.grid-item-box .text {
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
@ -321,9 +455,6 @@
|
||||
overflow-x: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.icon {
|
||||
height: 100rpx;
|
||||
@ -331,5 +462,32 @@
|
||||
display: block;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.pcs-tags-scroll {
|
||||
background: #fff;
|
||||
padding: 0 20rpx 20rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pcs-tags-row {
|
||||
display: inline-flex;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.pcs-tag-item {
|
||||
flex: 0 0 auto;
|
||||
padding: 8rpx 22rpx;
|
||||
border-radius: 999rpx;
|
||||
border: 1px solid #dcdfe6;
|
||||
color: #606266;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.4;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.pcs-tag-item.active {
|
||||
color: #fff;
|
||||
background: #007aff;
|
||||
border-color: #007aff;
|
||||
}
|
||||
</style>
|
||||
242
pages/work/yl/index.vue
Normal file
242
pages/work/yl/index.vue
Normal file
@ -0,0 +1,242 @@
|
||||
<template>
|
||||
<view class="page-container">
|
||||
<uni-collapse ref="collapse" accordion v-if="list.length > 0">
|
||||
<uni-collapse-item
|
||||
v-for="(item,index) in list"
|
||||
:key="index + 'ylList'"
|
||||
:open="index === 0"
|
||||
class="common-collapse-item"
|
||||
:class="handleCardClass(item)"
|
||||
>
|
||||
<template v-slot:title>
|
||||
<view class="title-wrapper">
|
||||
<view class="top">
|
||||
<view class="status">{{ item.statusText }}</view>
|
||||
<text class="name">{{ item.deviceName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<view class="content">
|
||||
<uni-group mode="card" class="data-card-group">
|
||||
<uni-row
|
||||
v-for="(field, fieldIndex) in (item.fieldConfigs || fallbackFieldConfigs)"
|
||||
:key="fieldIndex + 'ylField'"
|
||||
class="data-row"
|
||||
>
|
||||
<uni-col :span="8">
|
||||
<view class="title">{{ field.name }}</view>
|
||||
</uni-col>
|
||||
<uni-col :span="16">
|
||||
<view class="value">
|
||||
{{ item[field.attr] | formatNumber }}
|
||||
<text v-if="field.unit" v-html="field.unit"></text>
|
||||
</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
</uni-group>
|
||||
</view>
|
||||
</uni-collapse-item>
|
||||
</uni-collapse>
|
||||
<view class="no-data" v-else>
|
||||
暂无数据
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getProjectDisplayData,
|
||||
getDeviceList
|
||||
} from '@/api/ems/site.js'
|
||||
import {
|
||||
mapState
|
||||
} from 'vuex'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
...mapState({
|
||||
deviceStatusOptions: (state) => state.ems.deviceStatusOptions,
|
||||
}),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
siteId: '',
|
||||
displayData: [],
|
||||
coolingDeviceList: [],
|
||||
list: [],
|
||||
fallbackFieldConfigs: [{
|
||||
name: '供水温度',
|
||||
attr: 'gsTemp',
|
||||
unit: '℃'
|
||||
}, {
|
||||
name: '回水温度',
|
||||
attr: 'hsTemp',
|
||||
unit: '℃'
|
||||
}, {
|
||||
name: '供水压力',
|
||||
attr: 'gsPressure',
|
||||
unit: 'MPa'
|
||||
}, {
|
||||
name: '回水压力',
|
||||
attr: 'hsPressure',
|
||||
unit: 'MPa'
|
||||
}, {
|
||||
name: '冷源水温度',
|
||||
attr: 'lysTemp',
|
||||
unit: '℃'
|
||||
}, {
|
||||
name: 'VB01开度',
|
||||
attr: 'vb01Kd',
|
||||
unit: '%'
|
||||
}, {
|
||||
name: 'VB02开度',
|
||||
attr: 'vb02Kd',
|
||||
unit: '%'
|
||||
}]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
normalizeDeviceId(value) {
|
||||
return String(value == null ? '' : value).trim().toUpperCase()
|
||||
},
|
||||
getModuleRows(menuCode) {
|
||||
return (this.displayData || []).filter((item) => item.menuCode === menuCode)
|
||||
},
|
||||
getFieldName(fieldCode) {
|
||||
const raw = String(fieldCode || '').trim()
|
||||
if (!raw) return ''
|
||||
const index = raw.lastIndexOf('__')
|
||||
return index >= 0 ? raw.slice(index + 2) : raw
|
||||
},
|
||||
getFieldUnit(attr) {
|
||||
const field = (this.fallbackFieldConfigs || []).find((item) => item.attr === attr)
|
||||
return field ? (field.unit || '') : ''
|
||||
},
|
||||
getFieldConfigs(rows = []) {
|
||||
const result = []
|
||||
const seen = {}
|
||||
;(rows || []).forEach((item) => {
|
||||
const attr = this.getFieldName(item?.fieldCode)
|
||||
const name = String(item?.fieldName || '').trim()
|
||||
if (!attr || !name || seen[name]) return
|
||||
result.push({
|
||||
name,
|
||||
attr,
|
||||
unit: this.getFieldUnit(attr),
|
||||
})
|
||||
seen[name] = true
|
||||
})
|
||||
return result.length > 0 ? result : this.fallbackFieldConfigs
|
||||
},
|
||||
getFieldRowMap(rows = [], deviceId = '') {
|
||||
const map = {}
|
||||
const targetDeviceId = this.normalizeDeviceId(deviceId || '')
|
||||
rows.forEach((item) => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = this.normalizeDeviceId(item.deviceId || '')
|
||||
if (itemDeviceId !== targetDeviceId) return
|
||||
map[this.getFieldName(item.fieldCode)] = item
|
||||
})
|
||||
rows.forEach((item) => {
|
||||
if (!item || !item.fieldCode) return
|
||||
const itemDeviceId = this.normalizeDeviceId(item.deviceId || '')
|
||||
if (itemDeviceId !== '') return
|
||||
const fieldName = this.getFieldName(item.fieldCode)
|
||||
if (!map[fieldName]) {
|
||||
map[fieldName] = item
|
||||
}
|
||||
})
|
||||
return map
|
||||
},
|
||||
getLatestUpdateTime(rows = []) {
|
||||
const times = (rows || [])
|
||||
.map((item) => new Date(item?.valueTime).getTime())
|
||||
.filter((ts) => !isNaN(ts))
|
||||
if (times.length === 0) return '-'
|
||||
const date = new Date(Math.max(...times))
|
||||
const p = (n) => String(n).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${p(date.getMonth() + 1)}-${p(date.getDate())} ${p(date.getHours())}:${p(date.getMinutes())}:${p(date.getSeconds())}`
|
||||
},
|
||||
formatStatusText(statusValue) {
|
||||
const key = String(statusValue == null ? '' : statusValue).trim()
|
||||
if (!key) return '暂无数据'
|
||||
return (this.deviceStatusOptions || {})[key] || key
|
||||
},
|
||||
handleCardClass(item) {
|
||||
const key = String(item?.statusValue == null ? '' : item.statusValue).trim()
|
||||
if (key === '1') return 'running-collapse-item'
|
||||
if (key === '2') return 'warning-collapse-item'
|
||||
return 'timing-collapse-item'
|
||||
},
|
||||
buildList() {
|
||||
const rows = this.getModuleRows('SBJK_YL')
|
||||
const fieldConfigs = this.getFieldConfigs(rows)
|
||||
let devices = (this.coolingDeviceList || []).filter((item) => item.deviceCategory === 'COOLING')
|
||||
if (devices.length === 0) {
|
||||
const grouped = {}
|
||||
rows.forEach((item) => {
|
||||
const id = this.normalizeDeviceId(item?.deviceId || '')
|
||||
if (!id || grouped[id]) return
|
||||
grouped[id] = {
|
||||
deviceId: id,
|
||||
deviceName: item?.deviceName || id,
|
||||
deviceStatus: ''
|
||||
}
|
||||
})
|
||||
devices = Object.values(grouped)
|
||||
}
|
||||
if (devices.length === 0) {
|
||||
devices = [{
|
||||
deviceId: '',
|
||||
deviceName: '冷却',
|
||||
deviceStatus: ''
|
||||
}]
|
||||
}
|
||||
|
||||
this.list = devices.map((device) => {
|
||||
const id = this.normalizeDeviceId(device.deviceId || device.id || '')
|
||||
const fieldRowMap = this.getFieldRowMap(rows, id)
|
||||
const values = {}
|
||||
fieldConfigs.forEach((cfg) => {
|
||||
values[cfg.attr] = fieldRowMap[cfg.attr]?.fieldValue
|
||||
})
|
||||
const statusField = Object.values(fieldRowMap).find((row) => String(row?.fieldName || '').includes('状态'))
|
||||
const statusValue = statusField?.fieldValue || device.deviceStatus || ''
|
||||
return {
|
||||
...values,
|
||||
deviceId: id,
|
||||
deviceName: device.deviceName || device.name || id || '冷却',
|
||||
statusValue: String(statusValue || ''),
|
||||
statusText: this.formatStatusText(statusValue),
|
||||
fieldConfigs,
|
||||
dataUpdateTime: this.getLatestUpdateTime(Object.values(fieldRowMap)),
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
uni.showLoading()
|
||||
this.siteId = options.siteId || ''
|
||||
Promise.all([
|
||||
getProjectDisplayData(this.siteId),
|
||||
getDeviceList(this.siteId)
|
||||
]).then(([displayResponse, deviceResponse]) => {
|
||||
this.displayData = displayResponse?.data || []
|
||||
this.coolingDeviceList = deviceResponse?.data || []
|
||||
this.buildList()
|
||||
if (this.list.length > 0) {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.$refs.collapse.resize()
|
||||
uni.hideLoading()
|
||||
}, 100)
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}).catch(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -5,6 +5,7 @@ const getters = {
|
||||
name: state => state.user.name,
|
||||
roles: state => state.user.roles,
|
||||
permissions: state => state.user.permissions,
|
||||
belongSite: state => state.user.belongSite
|
||||
belongSite: state => state.user.belongSite,
|
||||
currentSiteId: state => state.user.currentSiteId
|
||||
}
|
||||
export default getters
|
||||
109
store/modules/site.js
Normal file
109
store/modules/site.js
Normal file
@ -0,0 +1,109 @@
|
||||
import { getAllSites } from '@/api/ems/site.js'
|
||||
|
||||
const createSiteTypeOptions = () => ([
|
||||
{
|
||||
text: '储能',
|
||||
value: 'cn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '光能',
|
||||
value: 'gn',
|
||||
children: []
|
||||
},
|
||||
{
|
||||
text: '岸电',
|
||||
value: 'ad',
|
||||
children: []
|
||||
}
|
||||
])
|
||||
|
||||
const site = {
|
||||
state: {
|
||||
siteOptions: [],
|
||||
siteTypeOptions: [],
|
||||
currentSiteId: '',
|
||||
loaded: false
|
||||
},
|
||||
mutations: {
|
||||
SET_SITE_OPTIONS: (state, siteOptions) => {
|
||||
state.siteOptions = siteOptions || []
|
||||
},
|
||||
SET_SITE_TYPE_OPTIONS: (state, siteTypeOptions) => {
|
||||
state.siteTypeOptions = siteTypeOptions || createSiteTypeOptions()
|
||||
},
|
||||
SET_CURRENT_SITE_ID: (state, siteId) => {
|
||||
state.currentSiteId = siteId || ''
|
||||
},
|
||||
SET_SITE_LOADED: (state, loaded) => {
|
||||
state.loaded = !!loaded
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
LoadSites({ state, rootState, commit }, payload = {}) {
|
||||
const { force = false } = payload
|
||||
if (state.loaded && !force) {
|
||||
return Promise.resolve({
|
||||
siteOptions: state.siteOptions,
|
||||
siteTypeOptions: state.siteTypeOptions,
|
||||
siteId: state.currentSiteId
|
||||
})
|
||||
}
|
||||
return getAllSites().then(response => {
|
||||
const belongSite = rootState?.user?.belongSite || []
|
||||
const canAccessAll = !belongSite || belongSite.length === 0 || belongSite.includes('all')
|
||||
const siteOptions = (response?.data || []).filter(item => {
|
||||
const siteId = item.siteId || ''
|
||||
return canAccessAll || belongSite.includes(siteId)
|
||||
}).map(item => {
|
||||
const siteId = item.siteId || ''
|
||||
const siteType = (item.siteType || item.type || 'cn').toString().toLowerCase()
|
||||
return {
|
||||
text: item.siteName,
|
||||
value: siteId,
|
||||
id: item.id,
|
||||
longitude: Number(item.longitude || 0),
|
||||
latitude: Number(item.latitude || 0),
|
||||
siteType
|
||||
}
|
||||
})
|
||||
const siteTypeOptions = createSiteTypeOptions().map(typeItem => ({
|
||||
...typeItem,
|
||||
children: []
|
||||
}))
|
||||
siteOptions.forEach(item => {
|
||||
const typeOption = siteTypeOptions.find(i => i.value === item.siteType) || siteTypeOptions.find(i => i.value === 'cn')
|
||||
if (!typeOption) return
|
||||
typeOption.children.push({
|
||||
text: item.text,
|
||||
value: item.value,
|
||||
id: item.id
|
||||
})
|
||||
})
|
||||
const filteredSiteTypeOptions = siteTypeOptions.filter(item => (item.children || []).length > 0)
|
||||
const availableSite = siteOptions[0]
|
||||
const keepCurrent = siteOptions.find(item => item.value === state.currentSiteId)
|
||||
commit('SET_SITE_OPTIONS', siteOptions)
|
||||
commit('SET_SITE_TYPE_OPTIONS', filteredSiteTypeOptions)
|
||||
commit('SET_CURRENT_SITE_ID', keepCurrent ? keepCurrent.value : (availableSite?.value || ''))
|
||||
commit('SET_SITE_LOADED', true)
|
||||
return {
|
||||
siteOptions,
|
||||
siteTypeOptions: filteredSiteTypeOptions,
|
||||
siteId: keepCurrent ? keepCurrent.value : (availableSite?.value || '')
|
||||
}
|
||||
})
|
||||
},
|
||||
SetCurrentSiteId({ commit }, siteId) {
|
||||
commit('SET_CURRENT_SITE_ID', siteId)
|
||||
},
|
||||
ClearSiteState({ commit }) {
|
||||
commit('SET_SITE_OPTIONS', [])
|
||||
commit('SET_SITE_TYPE_OPTIONS', [])
|
||||
commit('SET_CURRENT_SITE_ID', '')
|
||||
commit('SET_SITE_LOADED', false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default site
|
||||
@ -27,7 +27,8 @@ const user = {
|
||||
avatar: storage.get(constant.avatar),
|
||||
roles: storage.get(constant.roles),
|
||||
permissions: storage.get(constant.permissions),
|
||||
belongSite: storage.get(constant.belongSite)
|
||||
belongSite: storage.get(constant.belongSite),
|
||||
currentSiteId: storage.get(constant.currentSiteId)
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@ -57,6 +58,10 @@ const user = {
|
||||
SET_BELONGSITE: (state, belongSite = []) => {
|
||||
state.belongSite = belongSite || []
|
||||
storage.set(constant.belongSite, belongSite || [])
|
||||
},
|
||||
SET_CURRENTSITEID: (state, currentSiteId = '') => {
|
||||
state.currentSiteId = currentSiteId || ''
|
||||
storage.set(constant.currentSiteId, currentSiteId || '')
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -3,7 +3,8 @@ const constant = {
|
||||
id: 'user_id',
|
||||
name: 'user_name',
|
||||
roles: 'user_roles',
|
||||
permissions: 'user_permissions'
|
||||
permissions: 'user_permissions',
|
||||
currentSiteId: 'current_site_id'
|
||||
}
|
||||
|
||||
export default constant
|
||||
|
||||
@ -21,16 +21,25 @@ const request = config => {
|
||||
config.url = url
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const requestUrl = config.baseUrl || baseUrl + config.url
|
||||
const requestMethod = (config.method || 'get').toUpperCase()
|
||||
uni.request({
|
||||
method: config.method || 'get',
|
||||
timeout: config.timeout || timeout,
|
||||
url: config.baseUrl || baseUrl + config.url,
|
||||
url: requestUrl,
|
||||
data: config.data,
|
||||
header: config.header,
|
||||
dataType: 'json'
|
||||
}).then(response => {
|
||||
let [error, res] = response
|
||||
if (error) {
|
||||
const errorType = error?.errMsg || error?.message || 'UNKNOWN_ERROR'
|
||||
console.error('[request:error]', {
|
||||
url: requestUrl,
|
||||
method: requestMethod,
|
||||
errorType,
|
||||
rawError: error
|
||||
})
|
||||
toast('后端接口连接异常')
|
||||
reject('后端接口连接异常')
|
||||
return
|
||||
@ -57,6 +66,15 @@ const request = config => {
|
||||
})
|
||||
.catch(error => {
|
||||
let { message } = error
|
||||
const rawMessage = message || ''
|
||||
let errorType = 'UNKNOWN_ERROR'
|
||||
if (rawMessage === 'Network Error') {
|
||||
errorType = 'NETWORK_ERROR'
|
||||
} else if (rawMessage.includes('timeout')) {
|
||||
errorType = 'TIMEOUT'
|
||||
} else if (rawMessage.includes('Request failed with status code')) {
|
||||
errorType = 'HTTP_STATUS_ERROR'
|
||||
}
|
||||
if (message === 'Network Error') {
|
||||
message = '后端接口连接异常'
|
||||
} else if (message.includes('timeout')) {
|
||||
@ -64,6 +82,13 @@ const request = config => {
|
||||
} else if (message.includes('Request failed with status code')) {
|
||||
message = '系统接口' + message.substr(message.length - 3) + '异常'
|
||||
}
|
||||
console.error('[request:catch]', {
|
||||
url: requestUrl,
|
||||
method: requestMethod,
|
||||
errorType,
|
||||
message: rawMessage,
|
||||
rawError: error
|
||||
})
|
||||
toast(message)
|
||||
reject(error)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user