diff --git a/api/ems/site.js b/api/ems/site.js
index ab066d4..3b252ce 100644
--- a/api/ems/site.js
+++ b/api/ems/site.js
@@ -24,14 +24,22 @@ export function getBMSBatteryCluster(data) {
})
}
-//获取电表数据
-export function getAmmeterDataList(data) {
- return request({
- url: `/ems/siteMonitor/getAmmeterDataList`, //?siteId=${siteId}
- method: 'get',
- data
- })
-}
+//获取电表数据
+export function getAmmeterDataList(data) {
+ return request({
+ url: `/ems/siteMonitor/getAmmeterDataList`, //?siteId=${siteId}
+ method: 'get',
+ data
+ })
+}
+
+//获取所有设备
+export function getDeviceList(siteId) {
+ return request({
+ url: `/ems/siteConfig/getDeviceList?siteId=${siteId}`,
+ method: 'get'
+ })
+}
//获取pcs头部的设备信息
export function getRunningHeadInfo(data) {
@@ -41,47 +49,51 @@ export function getRunningHeadInfo(data) {
data
})
}
-//获取pcs列表
-export function getPcsDetailInfo(data) {
- return request({
- url: `/ems/siteMonitor/getPcsDetailInfo`, //?siteId=${siteId}
- method: 'get',
- data
- })
-}
+//获取pcs列表
+export function getPcsDetailInfo(data) {
+ return request({
+ url: `/ems/siteMonitor/getPcsDetailInfo`, //?siteId=${siteId}
+ method: 'get',
+ data
+ })
+}
+
+//获取pcs名称列表
+export function getPcsNameList(siteId) {
+ return request({
+ url: `/ems/siteMonitor/getPcsNameList?siteId=${siteId}`,
+ method: 'get'
+ })
+}
-//获取单体电池 电池堆列表数据
-export function getStackNameList(data) {
- return request({
- url: `/ems/siteMonitor/getStackNameList`, //?siteId=${siteId}
- method: 'get',
- data
- })
-}
-//获取单体电池 电池簇列表数据
-export function getClusterNameList(data) {
- return request({
- url: `/ems/siteMonitor/getClusterNameList`, //?stackDeviceId=${stackDeviceId}&siteId=${siteId}
- method: 'get',
- data
- })
-}
-//单体电池表格数据
-export function getClusterDataInfoList(data) {
- return request({
- url: `/ems/siteMonitor/getClusterDataInfoList?`, //clusterDeviceId=${clusterDeviceId}&siteId=${siteId}&stackDeviceId=${stackDeviceId}&pageSize=${pageSize}&pageNum=${pageNum}
- method: 'get',
- data
- })
-}
-// 单体电池图表
-export function getSingleBatteryData(data) {
- return request({
- url: `/ems/siteMonitor/getSingleBatteryData`, //?siteId=${siteId}&deviceId=${deviceId}&startDate=${startDate}&endDate=${endDate}&clusterDeviceId=${clusterDeviceId}`,
- method: 'get',
- data
- })
-}
+//获取单体电池 电池堆列表数据
+export function getStackNameList(siteId) {
+ return request({
+ url: `/ems/siteMonitor/getStackNameList?siteId=${siteId}`,
+ method: 'get'
+ })
+}
+//获取单体电池 电池簇列表数据
+export function getClusterNameList({ stackDeviceId, siteId }) {
+ return request({
+ url: `/ems/siteMonitor/getClusterNameList?stackDeviceId=${stackDeviceId}&siteId=${siteId}`,
+ method: 'get'
+ })
+}
+//单体电池表格数据
+export function getClusterDataInfoList({ siteId, stackDeviceId, clusterDeviceId, batteryId, pageSize, pageNum }) {
+ return request({
+ url: `/ems/siteMonitor/getClusterDataInfoList?clusterDeviceId=${clusterDeviceId}&siteId=${siteId}&stackDeviceId=${stackDeviceId}&batteryId=${batteryId}&pageSize=${pageSize}&pageNum=${pageNum}`,
+ method: 'get'
+ })
+}
+// 单体电池图表
+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'
+ })
+}
//获取单个站点的基本信息
export function getSingleSiteBaseInfo(data) {
@@ -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'
})
}
@@ -119,18 +138,30 @@ export function getSevenChargeData(data) {
})
}
-//单站监控 首页 当日功率曲线
-export function getPointData(data) {
- return request({
- url: `/ems/siteMonitor/getPointData`,
- method: 'get',
- data
- })
-}
-
-// 获取站点包含的设备种类 用来判断单站监控设备监控的菜单栏展示
-export function getSiteAllDeviceCategory(data) {
- return request({
+//单站监控 首页 当日功率曲线
+export function getPointData(data) {
+ return request({
+ url: `/ems/siteMonitor/getPointData`,
+ method: 'get',
+ data
+ })
+}
+
+// 点位配置-曲线数据(与管理端一致)
+export function getPointConfigCurve(data) {
+ return request({
+ url: `/ems/pointConfig/curve`,
+ method: 'post',
+ data,
+ headers: {
+ repeatSubmit: false
+ }
+ })
+}
+
+// 获取站点包含的设备种类 用来判断单站监控设备监控的菜单栏展示
+export function getSiteAllDeviceCategory(data) {
+ return request({
url: `/ems/siteConfig/getSiteAllDeviceCategory`,
method: 'get',
data
diff --git a/components/SiteSelector/index.vue b/components/SiteSelector/index.vue
new file mode 100644
index 0000000..bc03748
--- /dev/null
+++ b/components/SiteSelector/index.vue
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/components/SiteSwitchHeader/index.vue b/components/SiteSwitchHeader/index.vue
new file mode 100644
index 0000000..0747bdd
--- /dev/null
+++ b/components/SiteSwitchHeader/index.vue
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
diff --git a/config.js b/config.js
index da71398..82fbb5d 100644
--- a/config.js
+++ b/config.js
@@ -1,10 +1,11 @@
// 应用全局配置
module.exports = {
- // todo 打包项目时切换baseUrl
+ // 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: {
// 应用名称
diff --git a/pages.json b/pages.json
index 0fedc4e..af828f6 100644
--- a/pages.json
+++ b/pages.json
@@ -102,17 +102,23 @@
"navigationBarTitleText": "电表"
}
},
- {
- "path": "pages/work/pcs/index",
- "style": {
- "navigationBarTitleText": "PCS"
- }
- },
- {
- "path": "pages/work/dtdc/index",
- "style": {
- "navigationBarTitleText": "单体电池",
- "onReachBottomDistance": 100
+ {
+ "path": "pages/work/pcs/index",
+ "style": {
+ "navigationBarTitleText": "PCS"
+ }
+ },
+ {
+ "path": "pages/work/yl/index",
+ "style": {
+ "navigationBarTitleText": "冷却"
+ }
+ },
+ {
+ "path": "pages/work/dtdc/index",
+ "style": {
+ "navigationBarTitleText": "单体电池",
+ "onReachBottomDistance": 100
}
}
diff --git a/pages/index.vue b/pages/index.vue
index 922fcbc..aacfb8b 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1,16 +1,7 @@
-
- 站点选择
-
-
-
-
+
@@ -22,16 +13,16 @@
总累计运行数据
总收入
- {{ format2(runningInfo.totalRevenue) }}
+ {{ format2(totalRevenueDisplayValue) }}
元
-
+
{{ item.title }}
- {{ format2(runningInfo[item.attr]) }}
+ {{ format2(item.value) }}
@@ -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;
diff --git a/pages/mine/avatar/index.vue b/pages/mine/avatar/index.vue
index ffa407d..8b91915 100644
--- a/pages/mine/avatar/index.vue
+++ b/pages/mine/avatar/index.vue
@@ -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事件
diff --git a/pages/work/bmsdcc/index.vue b/pages/work/bmsdcc/index.vue
index 455f29b..2db7765 100644
--- a/pages/work/bmsdcc/index.vue
+++ b/pages/work/bmsdcc/index.vue
@@ -41,9 +41,9 @@
-
-
+
+
{{infoDataItem.label}}
@@ -51,37 +51,12 @@
{{item[infoDataItem.attr] | formatNumber}}
-
-
-
-
-
-
-
-
- 名称
- 单体平均值
- 单体最小值
- 单体最小值ID
- 单体最大值
- 单体最大值ID
-
-
-
-
- {{tableItem.avgData}}
- {{tableItem.minData}}
- {{tableItem.minDataID}}
- {{tableItem.maxData}}
- {{tableItem.maxDataID}}
-
-
-
-
-
-
+
+
+
+
+
+
暂无数据
@@ -89,14 +64,16 @@
-
\ No newline at end of file
+ methods: {
+ handleCardClass(item) {
+ const {
+ workStatus = ''
+ } = item
+ 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 || ''
+ this.updateData().finally(() => {
+ if (this.list.length > 0) {
+ this.$nextTick(() => {
+ setTimeout(() => {
+ uni.hideLoading()
+ }, 100)
+ })
+ return
+ }
+ uni.hideLoading()
+ })
+ }
+ }
+
diff --git a/pages/work/bmszl/index.vue b/pages/work/bmszl/index.vue
index ad43480..c5912e5 100644
--- a/pages/work/bmszl/index.vue
+++ b/pages/work/bmszl/index.vue
@@ -53,45 +53,9 @@
-
-
-
-
-
- 簇号
- 簇电压
- 簇电流
- 簇SOC
- 单体最高电压
- 电池号码
- 单体最低电压
- 电池号码
- 单体最高温度
- 电池号码
- 单体最低温度
- 电池号码
-
-
-
- {{tableItem.clusterId}}
- {{tableItem.clusterVoltage}}V
- {{tableItem.clusterCurrent}}A
- {{tableItem.currentSoc}}%
- {{tableItem.maxCellVoltage}}V
- {{tableItem.maxCellVoltageId}}
- {{tableItem.minCellVoltage}}V
- {{tableItem.maxCellVoltageId}}
- {{tableItem.maxCellTemp}}℃
- {{tableItem.maxCellTempId}}
- {{tableItem.minCellTemp}}℃
- {{tableItem.minCellTempId}}
-
-
-
-
-
-
+
+
+
暂无数据
@@ -99,14 +63,15 @@
-
\ No newline at end of file
+ },
+ 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 = ''
+ } = item
+ 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 || ''
+ this.updateData().then(() => {
+ if (this.list.length === 0) {
+ uni.hideLoading()
+ return
+ }
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.$refs.collapse && this.$refs.collapse.resize()
+ uni.hideLoading()
+ }, 100)
+ })
+ }).catch(() => {
+ uni.hideLoading()
+ })
+ }
+ }
+
diff --git a/pages/work/db/index.vue b/pages/work/db/index.vue
index 6c0db1c..b702325 100644
--- a/pages/work/db/index.vue
+++ b/pages/work/db/index.vue
@@ -17,12 +17,12 @@
-
-
-
- {{tempDataItem.name}}
-
+
+
+
+ {{tempDataItem.name}}
+
{{item[tempDataItem.attr] | formatNumber}}
@@ -40,129 +40,31 @@
-
-
\ No newline at end of file
+
diff --git a/pages/work/yl/index.vue b/pages/work/yl/index.vue
new file mode 100644
index 0000000..bde1a40
--- /dev/null
+++ b/pages/work/yl/index.vue
@@ -0,0 +1,242 @@
+
+
+
+
+
+
+
+ {{ item.statusText }}
+ {{ item.deviceName }}
+
+
+
+
+
+
+
+ {{ field.name }}
+
+
+
+ {{ item[field.attr] | formatNumber }}
+
+
+
+
+
+
+
+
+
+ 暂无数据
+
+
+
+
+
diff --git a/store/getters.js b/store/getters.js
index 2874d96..4935286 100644
--- a/store/getters.js
+++ b/store/getters.js
@@ -2,9 +2,10 @@ const getters = {
token: state => state.user.token,
avatar: state => state.user.avatar,
id: state => state.user.id,
- name: state => state.user.name,
- roles: state => state.user.roles,
- permissions: state => state.user.permissions,
- belongSite: state => state.user.belongSite
-}
-export default getters
\ No newline at end of file
+ name: state => state.user.name,
+ roles: state => state.user.roles,
+ permissions: state => state.user.permissions,
+ belongSite: state => state.user.belongSite,
+ currentSiteId: state => state.user.currentSiteId
+}
+export default getters
diff --git a/store/modules/site.js b/store/modules/site.js
new file mode 100644
index 0000000..d5d1b8b
--- /dev/null
+++ b/store/modules/site.js
@@ -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
diff --git a/store/modules/user.js b/store/modules/user.js
index 7ec9c06..e268fe1 100644
--- a/store/modules/user.js
+++ b/store/modules/user.js
@@ -24,11 +24,12 @@ const user = {
token: getToken(),
id: storage.get(constant.id),
name: storage.get(constant.name),
- avatar: storage.get(constant.avatar),
- roles: storage.get(constant.roles),
- permissions: storage.get(constant.permissions),
- belongSite: storage.get(constant.belongSite)
- },
+ avatar: storage.get(constant.avatar),
+ roles: storage.get(constant.roles),
+ permissions: storage.get(constant.permissions),
+ belongSite: storage.get(constant.belongSite),
+ currentSiteId: storage.get(constant.currentSiteId)
+ },
mutations: {
SET_TOKEN: (state, token) => {
@@ -54,11 +55,15 @@ const user = {
state.permissions = permissions
storage.set(constant.permissions, permissions)
},
- SET_BELONGSITE: (state, belongSite = []) => {
- state.belongSite = belongSite || []
- storage.set(constant.belongSite, belongSite || [])
- }
- },
+ SET_BELONGSITE: (state, belongSite = []) => {
+ state.belongSite = belongSite || []
+ storage.set(constant.belongSite, belongSite || [])
+ },
+ SET_CURRENTSITEID: (state, currentSiteId = '') => {
+ state.currentSiteId = currentSiteId || ''
+ storage.set(constant.currentSiteId, currentSiteId || '')
+ }
+ },
actions: {
// 登录
@@ -133,4 +138,4 @@ const user = {
}
}
-export default user
\ No newline at end of file
+export default user
diff --git a/utils/constant.js b/utils/constant.js
index 6b93379..8e8b5ae 100644
--- a/utils/constant.js
+++ b/utils/constant.js
@@ -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
diff --git a/utils/request.js b/utils/request.js
index 860f0ef..66cb4c1 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -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)
})