Files
emsapp/pages/work/index.vue

605 lines
14 KiB
Vue
Raw Normal View History

2025-07-29 23:05:58 +08:00
<template>
<view class="work-container">
2026-01-19 17:30:03 +08:00
<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>
2025-08-15 17:41:26 +08:00
</view>
2026-01-19 17:30:03 +08:00
</view>
<!-- 静态信息 -->
<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>
2026-01-21 10:22:50 +08:00
<view class="text">{{baseInfo.installPower | formatNumber}}</view>
2026-01-19 17:30:03 +08:00
</view>
</uni-grid-item>
<uni-grid-item>
2025-08-15 17:41:26 +08:00
<view class="grid-item-box">
2026-01-19 17:30:03 +08:00
<view class="title">装机容量(MW)</view>
2026-01-21 10:22:50 +08:00
<view class="text">{{baseInfo.installCapacity | formatNumber}}</view>
2025-08-15 17:41:26 +08:00
</view>
</uni-grid-item>
</uni-grid>
2026-01-19 17:30:03 +08:00
</uni-group>
<!-- 工作台 -->
<uni-section title="工作台" type="line" class="sections-list">
<view class="grid-body">
<uni-grid :column="4" :showBorder="false" @change="toDetail">
<uni-grid-item v-for="(item,index) in siteGirdList" :index="index" :key="index+'work'">
<view class="grid-item-box work-box">
<view class="icon iconfont" :class="item.icon" size="30"></view>
<text class="text">{{item.text}}</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</uni-section>
<!-- 一周充放曲线 uchart的组件最好放在同级-->
<uni-section title="一周充放曲线" type="line" class="sections-list">
<date-range-select ref="weekChartDateRangeSelect" @updateDate="updateWeekChartDate" />
<view style="width:100%;height: 250px;">
<qiun-data-charts type="area" :chartData="weekChartData" :optsWatch='false' :inScrollView="true"
:pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
</view>
</uni-section>
<!-- 当日功率曲线 uchart的组件最好放在同级-->
<uni-section title="当日功率曲线" type="line" class="sections-list">
<date-range-select ref="activeChartDateRangeSelect" @updateDate="updateActiveChartDate" />
<view style="width:100%;height: 250px;">
<qiun-data-charts type="area" :chartData="activeChartData" :optsWatch='false' :inScrollView="true"
:pageScrollTop="pageScrollTop" :opts="glqxOptions" :ontouch="true" />
</view>
</uni-section>
</view>
2025-07-29 23:05:58 +08:00
</view>
</template>
<script>
2026-01-21 16:13:13 +08:00
import {
mapGetters
} from 'vuex'
2025-08-16 19:31:59 +08:00
import DateRangeSelect from './DateRangeSelect.vue'
2025-07-29 23:05:58 +08:00
import {
2025-08-15 17:41:26 +08:00
getAllSites,
getSingleSiteBaseInfo,
getSevenChargeData,
2025-10-15 18:16:56 +08:00
getPointData,
getSiteAllDeviceCategory
2025-07-29 23:05:58 +08:00
} from '@/api/ems/site.js'
export default {
2025-08-15 17:41:26 +08:00
components: {
2025-08-16 19:31:59 +08:00
DateRangeSelect
2025-08-15 17:41:26 +08:00
},
2025-07-29 23:05:58 +08:00
data() {
return {
2025-08-15 17:41:26 +08:00
// 图表数据
2025-08-16 19:31:59 +08:00
weekChartTimeRange: [],
activeChartTimeRange: [],
weekChartData: {},
activeChartData: {},
2025-08-15 17:41:26 +08:00
pageScrollTop: 0,
2025-10-15 18:16:56 +08:00
glqxOptions: {
2026-01-16 17:54:42 +08:00
padding: [10, 5, 0, 10],
2025-10-15 18:16:56 +08:00
dataLabel: false,
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 3,
disableGrid: true
},
2026-01-16 17:54:42 +08:00
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
2025-10-15 18:16:56 +08:00
// update: true,
// duration: 2,
// animation: false,
// enableScroll: true,
// padding: [10, 15, 10, 15]
},
2025-08-15 17:41:26 +08:00
options: {
2026-01-16 17:54:42 +08:00
padding: [10, 5, 0, 10],
2025-08-17 01:13:04 +08:00
dataLabel: false,
2025-08-15 17:41:26 +08:00
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 5,
2025-08-15 17:41:26 +08:00
disableGrid: true
},
2026-01-16 17:54:42 +08:00
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
2025-08-17 01:13:04 +08:00
// update: true,
2025-08-15 17:41:26 +08:00
// duration: 2,
// animation: false,
// enableScroll: true,
// padding: [10, 15, 10, 15]
},
// 图表数据结束
2025-10-15 18:16:56 +08:00
deviceCategoryOptions: [], //当前站点包含的设备类别
2025-08-15 17:41:26 +08:00
siteTypeOptions: [{
text: '储能',
2026-01-19 17:30:03 +08:00
value: 'cn',
children: []
2025-08-15 17:41:26 +08:00
},
{
text: '光能',
2026-01-19 17:30:03 +08:00
value: 'gn',
disable: true,
children: []
2025-08-15 17:41:26 +08:00
},
{
text: '岸电',
2026-01-19 17:30:03 +08:00
value: 'ad',
disable: true,
children: []
2025-08-15 17:41:26 +08:00
}
],
2025-07-29 23:05:58 +08:00
siteId: '', //选择的站点ID
2025-08-15 17:41:26 +08:00
baseInfo: {}, //站点基本信息
2025-07-29 23:05:58 +08:00
gridList: [{
page: 'bmszl',
2025-08-07 15:19:49 +08:00
icon: 'icon-BMS',
2025-07-29 23:05:58 +08:00
text: 'BMS总览',
2025-10-15 18:16:56 +08:00
categoryName: 'STACK'
2025-07-29 23:05:58 +08:00
},
{
page: 'bmsdcc',
2025-08-07 15:19:49 +08:00
icon: 'icon-a-dianchicunengliangkuai',
2025-07-29 23:05:58 +08:00
text: 'BMS电池簇',
2025-10-15 18:16:56 +08:00
categoryName: 'CLUSTER'
2025-07-29 23:05:58 +08:00
},
{
page: 'pcs',
2025-08-07 15:19:49 +08:00
icon: 'icon-PCS',
2025-07-29 23:05:58 +08:00
text: 'PCS',
2025-10-15 18:16:56 +08:00
categoryName: 'PCS'
2025-07-29 23:05:58 +08:00
},
2026-03-05 16:34:25 +08:00
{
page: 'db',
icon: 'icon-dianbiao4',
text: '电表',
categoryName: 'AMMETER'
},
{
page: 'yl',
icon: 'icon-gongneng-diandongji',
text: '冷却',
categoryName: 'COOLING'
},
{
page: 'dtdc',
icon: 'icon-dantidianchi',
text: '单体电池',
2025-10-15 18:16:56 +08:00
categoryName: 'BATTERY'
2025-07-29 23:05:58 +08:00
}
]
}
},
2026-03-05 16:34:25 +08:00
computed: {
...mapGetters(['belongSite', 'currentSiteId']),
siteGirdList() {
return this.gridList.filter(i => this.deviceCategoryOptions.includes(i.categoryName))
}
},
methods: {
isAvailableSite(siteId) {
const site = (this.siteTypeOptions.find(i => i.value === 'cn')?.children || []).find(item => item.value === siteId)
return !!(site && !site.disable)
},
// 更新一周冲放曲线时间范围 重置图表
updateWeekChartDate(data) {
this.weekChartTimeRange = data || []
this.siteId && this.getWeekChartData()
2025-08-16 19:31:59 +08:00
},
// 更新当日功率曲线时间范围 重置图表
updateActiveChartDate(data) {
2025-10-15 18:16:56 +08:00
this.activeChartTimeRange = data || []
this.siteId && this.getGVQXData()
2025-08-16 19:31:59 +08:00
},
2025-07-29 23:05:58 +08:00
toDetail(e) {
2025-08-15 17:41:26 +08:00
if (!this.siteId) return uni.showToast({
title: "请选择清单",
icon: 'none'
})
2025-07-29 23:05:58 +08:00
const {
index
} = e.detail
2026-01-21 16:53:05 +08:00
this.$tab.navigateTo(`/pages/work/${this.siteGirdList[index].page}/index?siteId=${this.siteId}`)
2025-07-29 23:05:58 +08:00
},
2026-03-05 16:34:25 +08:00
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()
},
2025-10-15 18:16:56 +08:00
updateSiteInfo() {
if (!this.siteId) return
this.getSiteBaseInfo()
this.getWeekChartData()
this.getGVQXData()
this.getSiteDeviceCategory()
},
2025-08-15 17:41:26 +08:00
getSiteList() {
getAllSites().then(response => {
const data = response?.data || []
2026-03-05 16:34:25 +08:00
this.siteTypeOptions.find(i => i.value === 'cn').children = data.map(item => {
return {
text: item.siteName,
value: item.siteId,
2026-01-21 16:13:13 +08:00
id: item.id,
disable: !this.belongSite || this.belongSite.length === 0 || this
.belongSite.includes('all') ? false : !this.belongSite.includes(item
.siteId)
2026-03-05 16:34:25 +08:00
}
})
const siteChildren = this.siteTypeOptions.find(i => i.value === 'cn')?.children || []
// 设置默认展示的站点
const defaultSiteId = this.isAvailableSite(this.currentSiteId) ? this.currentSiteId : (siteChildren.find(item =>
!item.disable)?.value || '')
if (defaultSiteId) {
this.siteId = defaultSiteId
this.$store.commit('SET_CURRENTSITEID', defaultSiteId)
this.updateSiteInfo()
}
})
},
2025-10-15 18:16:56 +08:00
getSiteBaseInfo() {
getSingleSiteBaseInfo({
siteId: this.siteId
}).then(response => {
console.log('获取站点基本信息', response)
this.baseInfo = response?.data || {}
})
},
getSiteDeviceCategory() {
getSiteAllDeviceCategory({
siteId: this.siteId
}).then(response => {
this.deviceCategoryOptions = response?.data || []
})
},
handleDate(date) {
if (!date) return date
const time = new Date(date)
const month = time.getMonth() + 1,
day = time.getDate()
return `${month<10?'0'+month : month}/${day<10 ? '0'+day : day}`
},
2025-10-15 18:16:56 +08:00
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 = [{
name: '电网功率',
attr: 'gridPower',
data: []
},
{
name: '负载功率',
attr: 'loadPower',
data: []
},
{
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]))
})
this.activeChartData = JSON.parse(JSON.stringify({
categories,
series: source
}))
}).finally(() => this.$refs.activeChartDateRangeSelect.showBtnLoading(false))
},
2025-08-15 17:41:26 +08:00
getWeekChartData() {
2025-08-16 19:31:59 +08:00
this.$refs.weekChartDateRangeSelect.showBtnLoading(true)
2025-08-15 17:41:26 +08:00
getSevenChargeData({
siteId: this.siteId,
2025-08-16 19:31:59 +08:00
startDate: this.weekChartTimeRange[0],
endDate: this.weekChartTimeRange[1]
2025-08-15 17:41:26 +08:00
}).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)
2025-08-15 17:41:26 +08:00
})
2025-08-16 19:31:59 +08:00
this.weekChartData = JSON.parse(JSON.stringify({
2025-08-15 17:41:26 +08:00
categories,
series: [{
"name": '充电量',
"data": chargedCap
},
{
"name": '放电量',
"data": disChargedCap
}
]
}))
2025-08-16 19:31:59 +08:00
}).finally(() => this.$refs.weekChartDateRangeSelect.showBtnLoading(false))
2026-03-05 16:34:25 +08:00
}
},
watch: {
currentSiteId(newSiteId) {
if (!newSiteId || newSiteId === this.siteId) return
if (!this.isAvailableSite(newSiteId)) return
this.siteId = newSiteId
this.updateSiteInfo()
}
},
// 页面切换不会重新调用如果希望每次切换页面都重新调接口使用onShow
onLoad() {
this.$nextTick(() => {
this.getSiteList()
2025-08-16 19:31:59 +08:00
this.$refs.weekChartDateRangeSelect.init()
2025-10-15 18:16:56 +08:00
this.$refs.activeChartDateRangeSelect.init(true)
2025-08-16 19:31:59 +08:00
})
2025-08-15 17:41:26 +08:00
},
2025-08-16 19:31:59 +08:00
// 页面滚动 设置pageScrollTop chart显示需要
2025-08-15 17:41:26 +08:00
onPageScroll(e) {
this.pageScrollTop = e.scrollTop
},
2025-07-29 23:05:58 +08:00
}
</script>
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
page {
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #fff;
min-height: 100%;
height: auto;
2026-01-09 19:10:32 +08:00
font-size: 26rpx;
line-height: 30rpx;
2025-07-29 23:05:58 +08:00
}
view {
line-height: inherit;
}
/* #endif */
.text {
text-align: center;
margin-top: 10rpx;
}
2026-01-19 17:30:03 +08:00
// 站点选择
.site-sections-list {
background: linear-gradient(to right, #547ef4, #679ff5);
padding: 30rpx 30rpx;
padding-bottom: 100rpx;
2026-01-09 19:10:32 +08:00
2026-01-19 17:30:03 +08:00
.info {
color: #fff;
2026-01-09 19:10:32 +08:00
font-size: 26rpx;
line-height: 30rpx;
2026-01-19 17:30:03 +08:00
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;
}
}
2026-01-09 19:10:32 +08:00
}
2026-01-19 17:30:03 +08:00
.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;
2026-01-21 10:22:50 +08:00
line-height: 36rpx;
2026-01-19 17:30:03 +08:00
font-weight: bolder;
}
// 右侧箭头
.arrow-area {
transform: rotate(-135deg);
.input-arrow {
border-color: #fff;
}
}
}
}
}
2025-08-15 17:41:26 +08:00
}
2026-01-19 17:30:03 +08:00
// 基本信息
.base-info {
margin-top: -80rpx;
border-radius: 80rpx 80rpx 0 0;
padding: 30rpx;
background-color: #fff;
// 装机功率
.install-data {
.grid-item-box {
padding-top: 6rpx;
padding-bottom: 6rpx;
.text {
margin-top: 20rpx;
color: #000;
}
}
2026-01-09 19:10:32 +08:00
}
2026-01-19 17:30:03 +08:00
.sections-list {
margin-bottom: 10rpx;
::v-deep &>.uni-section-header {
font-weight: 700;
font-size: 26rpx;
line-height: 30rpx;
2026-01-09 19:10:32 +08:00
}
2025-11-01 13:04:26 +08:00
}
2026-01-19 17:30:03 +08:00
.sections-list:not(:first-child) {
margin-top: 40rpx;
2025-11-01 13:04:26 +08:00
}
2026-01-19 17:30:03 +08:00
::v-deep {
.uni-section__content-title {
font-size: 26rpx !important;
}
.uni-select__input-box {
width: 100%;
.uni-select__input-text {
font-size: 24rpx;
}
}
2025-07-29 23:05:58 +08:00
2026-01-19 17:30:03 +08:00
.uni-select__selector-empty,
.uni-select__selector-item {
font-size: 24rpx;
line-height: 36rpx;
padding-top: 10rpx;
padding-bottom: 10rpx;
text-align: left;
}
// .uni-date__x-input {
// height: 50rpx;
// line-height: 50rpx;
// font-size: 26rpx;
// }
2026-01-09 19:10:32 +08:00
}
2026-01-19 17:30:03 +08:00
.work-box {
.icon {
font-size: 52rpx;
color: #547ef4;
}
.text {
font-size: 26rpx;
padding-top: 10rpx;
color: #000;
}
2026-01-09 19:10:32 +08:00
}
2025-08-07 15:19:49 +08:00
2026-01-09 19:10:32 +08:00
2026-01-19 17:30:03 +08:00
.base-lists {
font-size: 24rpx;
line-height: 40rpx;
padding: 10rpx 20rpx;
padding-left: 40rpx;
2025-08-15 17:41:26 +08:00
2026-01-19 17:30:03 +08:00
.left {
width: 220rpx;
display: inline-block;
color: #666;
}
2025-08-15 17:41:26 +08:00
2026-01-19 17:30:03 +08:00
.right {
color: #333;
}
2025-08-15 17:41:26 +08:00
}
}
2025-07-29 23:05:58 +08:00
@media screen and (min-width: 500px) {}
2026-03-05 16:34:25 +08:00
</style>