Compare commits

...

29 Commits

Author SHA1 Message Date
ac7dd9dd30 重构 2026-04-01 14:28:09 +08:00
69e199e9cc 重构 2026-03-05 16:34:25 +08:00
13ee9e66cc 修改首页地图 2026-02-08 21:51:10 +08:00
fb33e5a1f6 修改首页 2026-02-08 17:26:51 +08:00
3676313439 电池簇、电池堆设备工作状态更新 2026-01-25 16:55:22 +08:00
e1eec995ca 电池簇数据同步 2026-01-23 22:33:18 +08:00
b493e331c6 电表数据同步 2026-01-23 21:46:21 +08:00
b8898311ae pcs、bmszl 设备状态枚举workStatus更新 2026-01-23 20:28:39 +08:00
5c78cbf39f 工作台跳转问题 2026-01-21 16:53:05 +08:00
b24d930f4f 所属站点 2026-01-21 16:13:13 +08:00
feaeb0c7d7 logo有背景 2026-01-21 10:23:03 +08:00
3a034b48f1 优化 2026-01-21 10:22:50 +08:00
648f031ebe 优化 2026-01-19 17:30:03 +08:00
de403e861d 优化 2026-01-16 17:54:42 +08:00
2f1e29dccd 样式优化 2026-01-15 17:51:09 +08:00
b558282529 部分样式更新 2026-01-09 19:10:32 +08:00
5e4636fd7d 枚举更新 2026-01-08 17:46:03 +08:00
26a8114840 新增生产环境baseUrl在打包项目时注意切换 2025-11-12 14:13:31 +08:00
e7bc43008f 设备状态枚举更新 2025-11-01 13:04:26 +08:00
6149cba24e pc同步 2025-10-15 18:16:56 +08:00
a8c79eef72 工单状态更新 2025-10-14 18:02:01 +08:00
fb8c8aab28 一周功率曲线横坐标展示更新 2025-09-04 16:10:44 +08:00
74b22a2ec6 图表 2025-08-17 01:13:04 +08:00
5ea121abf0 时间选择范围问题修复 2025-08-16 23:15:33 +08:00
ffefc21d96 工作台 2025-08-16 19:31:59 +08:00
76065f7287 工作台 2025-08-15 17:41:26 +08:00
84e84fca10 图标更新、我的页面更新 2025-08-07 15:19:49 +08:00
ce189108ed 单体电池 2025-08-05 17:44:20 +08:00
bc18edead5 首页滚动、单体电池滚动 2025-08-05 17:26:18 +08:00
55 changed files with 10392 additions and 7663 deletions

View File

@ -24,14 +24,22 @@ export function getBMSBatteryCluster(data) {
}) })
} }
//获取电表数据 //获取电表数据
export function getAmmeterDataList(data) { export function getAmmeterDataList(data) {
return request({ return request({
url: `/ems/siteMonitor/getAmmeterDataList`, //?siteId=${siteId} url: `/ems/siteMonitor/getAmmeterDataList`, //?siteId=${siteId}
method: 'get', method: 'get',
data data
}) })
} }
//获取所有设备
export function getDeviceList(siteId) {
return request({
url: `/ems/siteConfig/getDeviceList?siteId=${siteId}`,
method: 'get'
})
}
//获取pcs头部的设备信息 //获取pcs头部的设备信息
export function getRunningHeadInfo(data) { export function getRunningHeadInfo(data) {
@ -41,49 +49,121 @@ export function getRunningHeadInfo(data) {
data data
}) })
} }
//获取pcs列表 //获取pcs列表
export function getPcsDetailInfo(data) { export function getPcsDetailInfo(data) {
return request({ return request({
url: `/ems/siteMonitor/getPcsDetailInfo`, //?siteId=${siteId} url: `/ems/siteMonitor/getPcsDetailInfo`, //?siteId=${siteId}
method: 'get', method: 'get',
data
})
}
//获取pcs名称列表
export function getPcsNameList(siteId) {
return request({
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({ 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) {
return request({
url: `/ems/siteMap/getSingleSiteBaseInfo`, //?siteId=${siteId}`,
method: 'get',
data
})
}
//单站监控 首页 总累计运行数据(基于日表)
export function getDzjkHomeTotalView(siteId) {
return request({
url: `/ems/siteMonitor/homeTotalView?siteId=${siteId}`,
method: 'get'
})
}
// 单站监控项目展示数据(字段配置 + 最新值)
export function getProjectDisplayData(siteId) {
return request({
url: `/ems/siteMonitor/getProjectDisplayData?siteId=${siteId}`,
method: 'get'
})
}
// 电价报表(收益数据)
export function getAmmeterRevenueData(params) {
return request({
url: `/ems/statsReport/getAmmeterRevenueData`,
method: 'get',
params
})
}
// 一周冲放曲线
export function getSevenChargeData(data) {
return request({
url: `/ems/siteMap/getSevenChargeData`, //?siteId=${siteId}&startDate=${startDate}&endDate=${endDate}`,
method: 'get',
data data
}) })
} }
//获取单体电池 电池堆列表数据 //单站监控 首页 当日功率曲线
export function getStackNameList(data) { export function getPointData(data) {
return request({ return request({
url: `/ems/siteMonitor/getStackNameList`, //?siteId=${siteId} 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', method: 'get',
data 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({
siteId,
deviceId,
clusterDeviceId,
startDate,
endDate
}) {
return request({
url: `/ems/siteMonitor/getSingleBatteryData?siteId=${siteId}&deviceId=${deviceId}&startDate=${startDate}&endDate=${endDate}&clusterDeviceId=${clusterDeviceId}`,
method: 'get'
})
}

View 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>

View 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>

View File

@ -1,26 +1,30 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
baseUrl: 'http://110.40.171.179:8089', // todo 打包项目时切换baseUrl
// baseUrl: 'http://localhost:8089', // baseUrl: 'http://localhost:8089',
// 应用信息 // 测试环境
appInfo: { baseUrl: 'http://110.40.171.179:8089',
// 应用名称 // 生产环境
name: "xzzn-app", // baseUrl: 'http://1.15.120.242:8089',
// 应用版本 // 应用信息
version: "1.2.0", appInfo: {
// 应用logo // 应用名称
logo: "/static/logo.png", name: "上动EMS",
// 官方网站 // 应用版本
site_url: "http://xzzn.vip", version: "1.2.0",
// 政策协议 // 应用logo
agreements: [{ logo: "/static/logo-trans.png",
title: "隐私政策", // 官方网站
url: "https://xzzn.vip/protocol.html" site_url: "http://xzzn.vip",
}, // 政策协议
{ agreements: [{
title: "用户服务协议", title: "隐私政策",
url: "https://xzzn.vip/protocol.html" url: "https://xzzn.vip/protocol.html"
} },
] {
} title: "用户服务协议",
} url: "https://xzzn.vip/protocol.html"
}
]
}
}

1
data/ems/china.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name" : "EMS移动端", "name" : "上动EMS",
"appid" : "__UNI__B330617", "appid" : "__UNI__5FBB073",
"description" : "", "description" : "",
"versionName" : "1.2.0", "versionName" : "1.2.0",
"versionCode" : "100", "versionCode" : "100",
@ -8,6 +8,12 @@
"app-plus" : { "app-plus" : {
"usingComponents" : true, "usingComponents" : true,
"nvueCompiler" : "uni-app", "nvueCompiler" : "uni-app",
"safearea" : {
"background" : "#FFFFFF",
"top" : {
"offset" : "auto"
}
},
"splashscreen" : { "splashscreen" : {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender" : true,
"waiting" : true, "waiting" : true,
@ -35,8 +41,24 @@
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
] ]
}, },
"ios" : {}, "ios" : {
"sdkConfigs" : {} "dSYMs" : false
},
"sdkConfigs" : {},
"icons" : {
"android" : {
"hdpi" : "static/logo.png",
"xhdpi" : "static/logo.png",
"xxhdpi" : "static/logo.png",
"xxxhdpi" : "static/logo.png"
},
"ios" : {
"appstore" : ""
}
},
"splashscreen" : {
"androidStyle" : "common"
}
} }
}, },
"quickapp" : {}, "quickapp" : {},
@ -60,10 +82,12 @@
"port" : 9090, "port" : 9090,
"https" : false "https" : false
}, },
"title" : "EMS-App", "title" : "上动EMS",
"router" : { "router" : {
"mode" : "hash", "mode" : "hash",
"base" : "./" "base" : "./"
} }
} },
"locale" : "zh-Hans",
"fallbackLocale" : "zh-Hans"
} }

View File

@ -9,14 +9,13 @@
"style": { "style": {
"navigationBarTitleText": "注册" "navigationBarTitleText": "注册"
} }
}, { }, {
"path": "pages/index", "path": "pages/index",
"style": { "style": {
"navigationBarTitleText": "移动端框架", "navigationBarTitleText": "首页"
"navigationStyle": "custom" }
} }, {
}, { "path": "pages/work/index",
"path": "pages/work/index",
"style": { "style": {
"navigationBarTitleText": "工作台" "navigationBarTitleText": "工作台"
} }
@ -70,11 +69,19 @@
"style": { "style": {
"navigationBarTitleText": "浏览文本" "navigationBarTitleText": "浏览文本"
} }
}, },
{ {
"path": "pages/ticket/index", "path": "pages/ticket/list",
"style": { "style": {
"navigationBarTitleText": "工单详情" "navigationBarTitleText": "工单列表",
"navigationStyle": "custom",
"onReachBottomDistance": 100
}
},
{
"path": "pages/ticket/index",
"style": {
"navigationBarTitleText": "工单详情"
} }
}, },
{ {
@ -95,17 +102,23 @@
"navigationBarTitleText": "电表" "navigationBarTitleText": "电表"
} }
}, },
{ {
"path": "pages/work/pcs/index", "path": "pages/work/pcs/index",
"style": { "style": {
"navigationBarTitleText": "PCS" "navigationBarTitleText": "PCS"
} }
}, },
{ {
"path": "pages/work/dtdc/index", "path": "pages/work/yl/index",
"style": { "style": {
"navigationBarTitleText": "单体电池", "navigationBarTitleText": "冷却"
"onReachBottomDistance": 100 }
},
{
"path": "pages/work/dtdc/index",
"style": {
"navigationBarTitleText": "单体电池",
"onReachBottomDistance": 100
} }
} }
@ -115,16 +128,21 @@
"selectedColor": "#000000", "selectedColor": "#000000",
"borderStyle": "white", "borderStyle": "white",
"backgroundColor": "#ffffff", "backgroundColor": "#ffffff",
"list": [{ "list": [{
"pagePath": "pages/index", "pagePath": "pages/index",
"iconPath": "static/images/tabbar/home.png", "iconPath": "static/images/tabbar/home.png",
"selectedIconPath": "static/images/tabbar/home_.png", "selectedIconPath": "static/images/tabbar/home_.png",
"text": "首页" "text": "首页"
}, { }, {
"pagePath": "pages/work/index", "pagePath": "pages/work/index",
"iconPath": "static/images/tabbar/work.png", "iconPath": "static/images/tabbar/work.png",
"selectedIconPath": "static/images/tabbar/work_.png", "selectedIconPath": "static/images/tabbar/work_.png",
"text": "工作台" "text": "工作台"
}, {
"pagePath": "pages/ticket/list",
"iconPath": "static/images/tabbar/ticket.png",
"selectedIconPath": "static/images/tabbar/ticket_.png",
"text": "工单"
}, { }, {
"pagePath": "pages/mine/index", "pagePath": "pages/mine/index",
"iconPath": "static/images/tabbar/mine.png", "iconPath": "static/images/tabbar/mine.png",
@ -137,4 +155,4 @@
"navigationBarTitleText": "EMS", "navigationBarTitleText": "EMS",
"navigationBarBackgroundColor": "#FFFFFF" "navigationBarBackgroundColor": "#FFFFFF"
} }
} }

View File

@ -1,184 +1,509 @@
<template> <template>
<view class="container"> <view class="home-container">
<view class="btn-list"> <site-switch-header :site-id="siteId" :site-type-options="siteTypeOptions" :site-address="baseInfo.siteAddress"
<uni-row> :running-time="baseInfo.runningTime" @change="selectedSite" />
<uni-col :span="12">
<button type="default" class="btns" :class="{'active-btn' : active === 'undone'}" <view class="base-info">
@click="changeTab('undone')">未处理</button> <view class="map-card">
</uni-col> <image v-if="mapUrl" class="site-map" :src="mapUrl" mode="aspectFill"></image>
<uni-col :span="12"> <view v-else class="map-empty">暂无站点位置</view>
<button type="default" class="btns" :class="{'active-btn' : active === 'done'}" </view>
@click="changeTab('done')">已处理</button> <view class="total-card">
</uni-col> <view class="total-header">
</uni-row> <view class="title">总累计运行数据</view>
</view> <view class="total-revenue">
<scroll-view class="scroll-y" :scroll-y="true" @scrolltolower="lower" scrolltoupper="upper"> <text class="label">总收入</text>
<view class="content"> <text class="value">{{ format2(totalRevenueDisplayValue) }}</text>
<view class="item-list" v-for="item in list" :key="item.ticketNo+'ticket'" @click="toDetail(item.id)"> <text class="unit"></text>
<view class="item-title" :class="item.status === 1 ? 'done' : 'undone'">工单号{{item.ticketNo}}</view> </view>
<view class="item-content"> </view>
<view class="item-info">工单标题:{{item.title}}</view> <uni-grid :column="2" :showBorder="false" :square="false" :highlight="false">
<view class="item-info">问题描述:{{item.content}}</view> <uni-grid-item v-for="(item, index) in runningDataCards" :key="index + 'sjglData'">
<view class="item-info">工单状态:{{ticketStatusOptions[item.status]}}</view> <view class="grid-item-box">
<view class="item-info">预期完成时间:{{item.expectedCompleteTime || '-'}}</view> <view class="title">{{ item.title }}</view>
<view class="item-info">处理人:{{item.workName || '-'}}</view> <view class="text" :style="{ color: item.color }">
</view> {{ format2(item.value) }}
</view> </view>
<view v-if="list.length===0" class="no-data">暂无数据</view> </view>
</view> </uni-grid-item>
</scroll-view> </uni-grid>
</view> </view>
</template>
<script> <uni-section title="收入曲线" type="line" class="sections-list">
import { <view style="width:100%;height: 220px;">
mapState <qiun-data-charts type="column" :chartData="revenueChartData" :optsWatch='true'
} from 'vuex' :inScrollView="true" :pageScrollTop="pageScrollTop" :opts="revenueOptions" :ontouch="true" />
import { </view>
listTicket </uni-section>
} from 'api/ems/ticket'
export default { </view>
computed: { </view>
...mapState({ </template>
ticketStatusOptions: (state) => state.ems.ticketStatusOptions
}) <script>
}, import {
data() { mapGetters
return { } from 'vuex'
active: 'undone', import {
total: 0, formatDate
list: [], } from '@/utils/filters'
pageNum: 1, import {
pageSize: 10 getAllSites,
} getSingleSiteBaseInfo,
}, getDzjkHomeTotalView,
methods: { getProjectDisplayData,
changeTab(active) { getAmmeterRevenueData
if (active === this.active) return } from '@/api/ems/site.js'
this.active = active import SiteSwitchHeader from '@/components/SiteSwitchHeader/index.vue'
this.reset() const createSiteTypeOptions = () => ([{
this.init() text: '储能',
}, value: 'cn',
lower() { children: []
if (this.list.length >= this.total) { },
return console.log('数据已经加载完成') {
} text: '光能',
this.pageNum += 1; value: 'gn',
this.init().catch(() => { children: []
this.pageNum -= 1 },
}) {
}, text: '岸电',
init() { value: 'ad',
//0:'待处理', 1:'已处理', 2:'处理中' children: []
let url = `/ticket/list?pageNum=${this.pageNum}&pageSize=${this.pageSize}` }
if (this.active === 'done') { ])
url += `&status=1`
} else { export default {
url += `&status=0&status=2` components: {
} SiteSwitchHeader
uni.showLoading() },
return listTicket(url).then(response => { data() {
const data = JSON.parse(JSON.stringify(response?.rows || [])) return {
this.list = this.list.concat(data) pageScrollTop: 0,
this.total = response?.total || 0 siteOptions: [],
}).finally(() => { siteTypeOptions: createSiteTypeOptions(),
uni.hideLoading() siteId: '',
}) mapUrl: '',
}, baseInfo: {},
toDetail(id) { runningInfo: {},
this.$tab.navigateTo(`/pages/ticket/index?id=${id}`) runningDisplayData: [],
}, revenueChartData: {},
reset() { revenueOptions: {
this.list = [] padding: [10, 5, 0, 10],
this.total = 0 dataLabel: false,
this.pageNum = 1 enableScroll: false,
} xAxis: {
}, scrollShow: false,
onShow() { itemCount: 5,
this.reset() disableGrid: true
this.init() },
} yAxis: {
} disabled: false,
</script> splitNumber: 4
},
<style scoped lang="scss"> extra: {}
.container { },
position: relative; fallbackSjglData: [{
} title: "今日充电量kWh",
attr: "dayChargedCap",
uni-button:after { color: '#4472c4'
border: none; },
border-radius: 0; {
} title: "今日放电量kWh",
attr: "dayDisChargedCap",
.btn-list { color: '#70ad47'
position: fixed; },
top: 0; {
left: 0; title: "总充电量kWh",
width: 100%; attr: "totalChargedCap",
z-index: 2; color: '#4472c4'
},
.btns { {
border-radius: 0; title: "今日实时收入(元)",
border: none; attr: "dayRevenue",
border-bottom: 1px solid #eee; color: '#f67438'
width: 100%; },
text-align: center; {
font-size: 16px; title: "昨日充电量kWh",
line-height: 50px; attr: "yesterdayChargedCap",
background-color: #fff; color: '#4472c4'
},
&.active-btn { {
background-color: #3a98ff; title: "昨日放电量kWh",
color: #fff; attr: "yesterdayDisChargedCap",
} color: '#70ad47'
} },
} {
title: "总放电量kWh",
.scroll-y { attr: "totalDischargedCap",
height: calc(100vh - var(--window-bottom) - var(--window-top)); color: '#70ad47'
z-index: 1; },
} {
title: "昨日实时收入(元)",
.content { attr: "yesterdayRevenue",
background-color: #ffffff; color: '#f67438'
padding: 70px 20px 60px 20px; }
} ]
}
.item-list { },
border-radius: 7px; computed: {
box-shadow: 0 0 10px rgba(0, 0, 0, .1), 0 0 0 rgba(0, 0, 0, .5); ...mapGetters(['belongSite', 'currentSiteId']),
font-size: 14px; totalRunningSectionData() {
line-height: 24px; return (this.runningDisplayData || []).filter(item => item.sectionName === '总累计运行数据')
margin-bottom: 20px; },
border: 1px solid #eee; totalRevenueDisplayItem() {
const sectionData = this.totalRunningSectionData || []
.item-title { const byFieldCode = sectionData.find(item => item.fieldCode === 'totalRevenue')
border-radius: 7px 7px 0 0; if (byFieldCode) {
font-size: 16px; return byFieldCode
border-bottom: 1px solid #eee; }
padding: 10px 15px; return sectionData.find(item => item.fieldName === '总收入')
background-color: #FC6B69; },
color: #fff; totalRevenueDisplayValue() {
return this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldValue : this.runningInfo.totalRevenue
&.done { },
background-color: #05AEA3; runningDataCards() {
} const sectionData = this.totalRunningSectionData || []
} if (sectionData.length > 0) {
const revenueFieldCode = this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldCode : ''
.item-content { return sectionData
padding: 15px 15px; .filter(item => item.fieldCode !== revenueFieldCode)
.map((item, index) => ({
.item-info { title: item.fieldName,
margin-bottom: 20px; value: item.fieldValue,
} color: this.getCardColor(index)
} }))
}
.item-content .item-info:last-child { return this.fallbackSjglData.map(item => ({
margin-bottom: 0; title: item.title,
} value: this.runningInfo[item.attr],
} color: item.color
}))
.content .item-list:last-child { }
margin-bottom: 0; },
} methods: {
</style> 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'
},
getLastDaysRange(days = 7) {
const end = new Date()
const start = new Date(end.getTime() - (days - 1) * 24 * 60 * 60 * 1000)
return [formatDate(start), formatDate(end)]
},
buildDateList(start, end) {
const list = []
const startTime = new Date(start).getTime()
const endTime = new Date(end).getTime()
const dayMs = 24 * 60 * 60 * 1000
for (let t = startTime; t <= endTime; t += dayMs) {
list.push(formatDate(t))
}
return list
},
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 || []
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)
})
})
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() {
const site = this.siteOptions.find(item => item.value === this.siteId)
if (!site || !site.latitude || !site.longitude) {
this.mapUrl = ''
return
}
const lat = Number(site.latitude)
const lon = Number(site.longitude)
const zoom = 12
const width = 640
const height = 360
const tk = '01e99ab4472430e1c7dbfe4b5db99787'
const layers = 'vec_c,cva_c'
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() {
return Promise.all([
getDzjkHomeTotalView(this.siteId),
getProjectDisplayData(this.siteId)
]).then(([homeResponse, displayResponse]) => {
this.runningInfo = homeResponse?.data || {}
this.runningDisplayData = displayResponse?.data || []
})
},
getRevenueChartData() {
const [startTime, endTime] = this.getLastDaysRange(7)
const dateList = this.buildDateList(startTime, endTime)
const requests = [getAmmeterRevenueData({
siteId: this.siteId,
startTime,
endTime,
pageSize: 200,
pageNum: 1
}).then(response => response?.rows || [])]
Promise.all(requests).then(list => {
const rows = list[0] || []
const categories = dateList.map(day => day.slice(5))
const sumMap = {}
dateList.forEach(day => {
sumMap[day] = 0
})
rows.forEach(row => {
const day = row.dataTime || row.statisDate || row.date
if (!day) return
if (!Object.prototype.hasOwnProperty.call(sumMap, day)) {
sumMap[day] = 0
}
const value = Number(row.actualRevenue || row.revenue || 0)
sumMap[day] += Number.isFinite(value) ? value : 0
})
const series = [{
name: '收入',
data: dateList.map(day => Number((sumMap[day] || 0).toFixed(2)))
}]
const values = series[0].data
let minVal = Math.min(...values)
let maxVal = Math.max(...values)
if (!Number.isFinite(minVal)) minVal = 0
if (!Number.isFinite(maxVal)) maxVal = 0
if (minVal === maxVal) {
minVal -= 1
maxVal += 1
}
const lower = Math.min(minVal, 0)
const upper = Math.max(maxVal, 0)
const padding = Math.max((upper - lower) * 0.1, 1)
this.revenueOptions = {
...this.revenueOptions,
yAxis: {
...(this.revenueOptions.yAxis || {}),
data: [{
min: lower - padding,
max: upper + padding,
format: (val) => Number(val).toFixed(2)
}]
},
extra: {
...(this.revenueOptions.extra || {}),
markLine: {
type: 'solid',
data: [{
value: 0,
lineColor: '#ff4d4f',
showLabel: true,
labelText: '0',
labelFontColor: '#ff4d4f',
labelBgColor: '#fff1f0',
labelBgOpacity: 0.9,
labelAlign: 'left'
}]
}
}
}
this.revenueChartData = JSON.parse(JSON.stringify({
categories,
series
}))
})
}
},
watch: {
currentSiteId(newSiteId) {
if (!newSiteId || newSiteId === this.siteId) return
if (!this.isAvailableSite(newSiteId)) return
this.siteId = newSiteId
this.updateSiteInfo()
}
},
onLoad() {
this.$nextTick(() => {
this.getSiteList()
})
},
onPageScroll(e) {
this.pageScrollTop = e.scrollTop
}
}
</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;
font-size: 26rpx;
line-height: 30rpx;
}
view {
line-height: inherit;
}
/* #endif */
.home-container {
background-color: #fff;
padding-top: 0;
}
.base-info {
margin-top: -80rpx;
border-radius: 80rpx 80rpx 0 0;
padding: 30rpx;
background-color: #fff;
.map-card {
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.08);
margin-top: 30rpx;
background: #f3f5f8;
.site-map {
width: 100%;
height: 220px;
}
.map-empty {
height: 220px;
display: flex;
align-items: center;
justify-content: center;
color: #8a8f98;
font-size: 24rpx;
}
}
.total-card {
margin-top: 30rpx;
border-radius: 16rpx;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.08);
padding: 20rpx;
.total-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.title {
font-weight: 700;
font-size: 28rpx;
}
.total-revenue {
display: flex;
align-items: baseline;
gap: 6rpx;
font-size: 22rpx;
color: #19242d;
.value {
font-size: 28rpx;
font-weight: 700;
color: #f67438;
}
}
}
.grid-item-box {
padding-top: 6rpx;
padding-bottom: 6rpx;
text-align: left;
.title {
font-size: 22rpx;
color: #666;
}
.text {
margin-top: 10rpx;
font-size: 26rpx;
font-weight: 600;
}
}
}
.sections-list {
margin-bottom: 10rpx;
::v-deep &>.uni-section-header {
font-weight: 700;
font-size: 26rpx;
line-height: 30rpx;
}
}
.sections-list:not(:first-child) {
margin-top: 40rpx;
}
}
</style>

View File

@ -1,210 +1,213 @@
<template> <template>
<view class="normal-login-container"> <view class="normal-login-container">
<view class="logo-content align-center justify-center flex"> <view class="logo-content align-center justify-center flex">
<image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix"> <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
</image> </image>
<text class="title">EMS移动端登录</text> <text class="title">上动EMS登录</text>
</view> </view>
<view class="login-form-content"> <view class="login-form-content">
<view class="input-item flex align-center"> <view class="input-item flex align-center">
<view class="iconfont icon-user icon"></view> <view class="iconfont icon-user icon"></view>
<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" /> <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
</view> </view>
<view class="input-item flex align-center"> <view class="input-item flex align-center">
<view class="iconfont icon-password icon"></view> <view class="iconfont icon-password icon"></view>
<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" /> <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
</view> </view>
<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled"> <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
<view class="iconfont icon-code icon"></view> <view class="iconfont icon-code icon"></view>
<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" /> <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
<view class="login-code"> <view class="login-code">
<image :src="codeUrl" @click="getCode" class="login-code-img"></image> <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
</view> </view>
</view> </view>
<view class="action-btn"> <view class="action-btn">
<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button> <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
</view> </view>
<view class="reg text-center" v-if="register"> <view class="reg text-center" v-if="register">
<text class="text-grey1">没有账号</text> <text class="text-grey1">没有账号</text>
<text @click="handleUserRegister" class="text-blue">立即注册</text> <text @click="handleUserRegister" class="text-blue">立即注册</text>
</view> </view>
<view class="xieyi text-center"> <view class="xieyi text-center">
<text class="text-grey1">登录即代表同意</text> <text class="text-grey1">登录即代表同意</text>
<text @click="handleUserAgrement" class="text-blue">用户协议</text> <text @click="handleUserAgrement" class="text-blue">用户协议</text>
<text @click="handlePrivacy" class="text-blue">隐私协议</text> <text @click="handlePrivacy" class="text-blue">隐私协议</text>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { getCodeImg } from '@/api/login' import {
import { getToken } from '@/utils/auth' getCodeImg
} from '@/api/login'
export default { import {
data() { getToken
return { } from '@/utils/auth'
codeUrl: "",
captchaEnabled: true, export default {
// 用户注册开关 data() {
register: false, return {
globalConfig: getApp().globalData.config, codeUrl: "",
loginForm: { captchaEnabled: true,
username: "admin", // 用户注册开关
password: "admin123", register: false,
code: "", globalConfig: getApp().globalData.config,
uuid: "" loginForm: {
} username: "admin",
} password: "admin123",
}, code: "",
created() { uuid: ""
this.getCode() }
}, }
onLoad() { },
//#ifdef H5 created() {
if (getToken()) { this.getCode()
this.$tab.reLaunch('/pages/index') },
} onLoad() {
//#endif //#ifdef H5
}, if (getToken()) {
methods: { this.$tab.reLaunch('/pages/index')
// 用户注册 }
handleUserRegister() { //#endif
this.$tab.redirectTo(`/pages/register`) },
}, methods: {
// 隐私协议 // 用户注册
handlePrivacy() { handleUserRegister() {
let site = this.globalConfig.appInfo.agreements[0] this.$tab.redirectTo(`/pages/register`)
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`) },
}, // 隐私协议
// 用户协议 handlePrivacy() {
handleUserAgrement() { let site = this.globalConfig.appInfo.agreements[0]
let site = this.globalConfig.appInfo.agreements[1] this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`) },
}, // 用户协议
// 获取图形验证码 handleUserAgrement() {
getCode() { let site = this.globalConfig.appInfo.agreements[1]
getCodeImg().then(res => { this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled },
if (this.captchaEnabled) { // 获取图形验证码
this.codeUrl = 'data:image/gif;base64,' + res.img getCode() {
this.loginForm.uuid = res.uuid getCodeImg().then(res => {
} this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
}) if (this.captchaEnabled) {
}, this.codeUrl = 'data:image/gif;base64,' + res.img
// 登录方法 this.loginForm.uuid = res.uuid
async handleLogin() { }
if (this.loginForm.username === "") { })
this.$modal.msgError("请输入账号") },
} else if (this.loginForm.password === "") { // 登录方法
this.$modal.msgError("请输入密码") async handleLogin() {
} else if (this.loginForm.code === "" && this.captchaEnabled) { if (this.loginForm.username === "") {
this.$modal.msgError("请输入验证码") this.$modal.msgError("请输入账号")
} else { } else if (this.loginForm.password === "") {
this.$modal.loading("登录中,请耐心等待...") this.$modal.msgError("请输入密码")
this.pwdLogin() } else if (this.loginForm.code === "" && this.captchaEnabled) {
} this.$modal.msgError("请输入验证码")
}, } else {
// 密码登录 this.$modal.loading("登录中,请耐心等待...")
async pwdLogin() { this.pwdLogin()
this.$store.dispatch('Login', this.loginForm).then(() => { }
this.$modal.closeLoading() },
this.loginSuccess() // 密码登录
}).catch(() => { async pwdLogin() {
if (this.captchaEnabled) { this.$store.dispatch('Login', this.loginForm).then(() => {
this.getCode() this.$modal.closeLoading()
} this.loginSuccess()
}) }).catch(() => {
}, if (this.captchaEnabled) {
// 登录成功后,处理函数 this.getCode()
loginSuccess(result) { }
// 设置用户信息 })
this.$store.dispatch('GetInfo').then(res => { },
this.$tab.reLaunch('/pages/index') // 登录成功后,处理函数
}) loginSuccess(result) {
} // 设置用户信息
} this.$store.dispatch('GetInfo').then(res => {
} this.$tab.reLaunch('/pages/index')
</script> })
}
<style lang="scss" scoped> }
page { }
background-color: #ffffff; </script>
}
<style lang="scss" scoped>
.normal-login-container { page {
width: 100%; background-color: #ffffff;
}
.logo-content {
width: 100%; .normal-login-container {
font-size: 21px; width: 100%;
text-align: center;
padding-top: 15%; .logo-content {
width: 100%;
image { font-size: 21px;
border-radius: 4px; text-align: center;
} padding-top: 15%;
.title { image {
margin-left: 10px; border-radius: 4px;
} }
}
.title {
.login-form-content { margin-left: 10px;
text-align: center; }
margin: 20px auto; }
margin-top: 15%;
width: 80%; .login-form-content {
text-align: center;
.input-item { margin: 20px auto;
margin: 20px auto; margin-top: 15%;
background-color: #f5f6f7; width: 80%;
height: 45px;
border-radius: 20px; .input-item {
margin: 20px auto;
.icon { background-color: #f5f6f7;
font-size: 38rpx; height: 45px;
margin-left: 10px; border-radius: 20px;
color: #999;
} .icon {
font-size: 38rpx;
.input { margin-left: 10px;
width: 100%; color: #999;
font-size: 14px; }
line-height: 20px;
text-align: left; .input {
padding-left: 15px; width: 100%;
} font-size: 14px;
line-height: 20px;
} text-align: left;
padding-left: 15px;
.login-btn { }
margin-top: 40px;
height: 45px; }
}
.login-btn {
.reg { margin-top: 40px;
margin-top: 15px; height: 45px;
} }
.xieyi { .reg {
color: #333; margin-top: 15px;
margin-top: 20px; }
}
.xieyi {
.login-code { color: #333;
height: 38px; margin-top: 20px;
float: right; }
.login-code-img { .login-code {
height: 38px; height: 38px;
position: absolute; float: right;
margin-left: 10px;
width: 200rpx; .login-code-img {
} height: 38px;
} position: absolute;
} margin-left: 10px;
} width: 200rpx;
}
</style> }
}
}
</style>

View File

@ -1,75 +1,75 @@
<template> <template>
<view class="about-container"> <view class="about-container">
<view class="header-section text-center"> <view class="header-section text-center">
<image style="width: 150rpx;height: 150rpx;" src="/static/logo200.png" mode="widthFix"> <image style="width: 150rpx;height: 150rpx;" src="/static/logo-trans.png" mode="widthFix">
</image> </image>
<uni-title type="h2" title="EMS移动端"></uni-title> <uni-title type="h2" title="EMS移动端"></uni-title>
</view> </view>
<view class="content-section"> <view class="content-section">
<view class="menu-list"> <view class="menu-list">
<view class="list-cell list-cell-arrow"> <view class="list-cell list-cell-arrow">
<view class="menu-item-box"> <view class="menu-item-box">
<view>版本信息</view> <view>版本信息</view>
<view class="text-right">v{{version}}</view> <view class="text-right">v{{version}}</view>
</view> </view>
</view> </view>
<view class="list-cell list-cell-arrow"> <view class="list-cell list-cell-arrow">
<view class="menu-item-box"> <view class="menu-item-box">
<view>官方邮箱</view> <view>官方邮箱</view>
<view class="text-right">ems@xx.com</view> <view class="text-right">ems@xx.com</view>
</view> </view>
</view> </view>
<view class="list-cell list-cell-arrow"> <view class="list-cell list-cell-arrow">
<view class="menu-item-box"> <view class="menu-item-box">
<view>服务热线</view> <view>服务热线</view>
<view class="text-right">400-999-9999</view> <view class="text-right">400-999-9999</view>
</view> </view>
</view> </view>
<view class="list-cell list-cell-arrow"> <view class="list-cell list-cell-arrow">
<view class="menu-item-box"> <view class="menu-item-box">
<view>公司网站</view> <view>公司网站</view>
<view class="text-right"> <view class="text-right">
<uni-link :href="url" :text="url" showUnderLine="false"></uni-link> <uni-link :href="url" :text="url" showUnderLine="false"></uni-link>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="copyright"> <view class="copyright">
<view>Copyright &copy; 2025 上海电动工具研究所集团有限公司.</view> <view>Copyright &copy; 2025 上海电动工具研究所集团有限公司.</view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
url: getApp().globalData.config.appInfo.site_url, url: getApp().globalData.config.appInfo.site_url,
version: getApp().globalData.config.appInfo.version version: getApp().globalData.config.appInfo.version
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page { page {
background-color: #f8f8f8; background-color: #f8f8f8;
} }
.copyright { .copyright {
margin-top: 50rpx; margin-top: 50rpx;
text-align: center; text-align: center;
line-height: 60rpx; line-height: 60rpx;
color: #999; color: #999;
} }
.header-section { .header-section {
display: flex; display: flex;
padding: 30rpx 0 0; padding: 30rpx 0 0;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
</style> </style>

View File

@ -123,6 +123,9 @@
}, },
loadImage: function () { loadImage: function () {
var _this = this var _this = this
uni.showLoading({
title: '图片加载中...',
})
uni.getImageInfo({ uni.getImageInfo({
src: _this.imageSrc, src: _this.imageSrc,
@ -188,7 +191,14 @@
isShowImg: true isShowImg: true
}) })
uni.hideLoading() uni.hideLoading()
} },
fail() {
uni.hideLoading()
uni.showToast({
title: '图片加载失败',
icon: 'none'
})
},
}) })
}, },
// 拖动时候触发的touchStart事件 // 拖动时候触发的touchStart事件

View File

@ -1,37 +1,38 @@
<template> <template>
<view class="mine-container" :style="{height: `${windowHeight}px`}"> <view class="mine-container" :style="{height: `${windowHeight}px`}">
<!--顶部个人信息栏--> <!--顶部个人信息栏-->
<view class="header-section"> <view class="header-section">
<view class="flex padding justify-between"> <view class="flex padding justify-between">
<view class="flex align-center"> <view class="flex align-center">
<view v-if="!avatar" class="cu-avatar xl round bg-white"> <view v-if="!avatar" class="cu-avatar xl round bg-white">
<view class="iconfont icon-people text-gray icon"></view> <view class="iconfont icon-people text-gray icon"></view>
</view> </view>
<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix"> <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
</image> mode="widthFix">
<view v-if="!name" @click="handleToLogin" class="login-tip"> </image>
点击登录 <view v-if="!name" @click="handleToLogin" class="login-tip">
</view> 点击登录
<view v-if="name" @click="handleToInfo" class="user-info"> </view>
<view class="u_title"> <view v-if="name" @click="handleToInfo" class="user-info">
用户名{{ name }} <view class="u_title">
</view> 用户名{{ name }}
</view> </view>
</view> </view>
<view @click="handleToInfo" class="flex align-center"> </view>
<text>个人信息</text> <view @click="handleToInfo" class="flex align-center">
<view class="iconfont icon-right"></view> <text>个人信息</text>
</view> <view class="iconfont icon-right"></view>
</view> </view>
</view> </view>
</view>
<view class="content-section"> <view class="content-section">
<view class="mine-actions grid col-4 text-center"> <view class="mine-actions grid col-4 text-center">
<view class="action-item" @click="handleJiaoLiuQun"> <view class="action-item" @click="handleToEditInfo">
<view class="iconfont icon-friendfill text-pink icon"></view> <view class="iconfont icon-friendfill text-pink icon"></view>
<text class="text">交流群</text> <text class="text">个人信息</text>
</view> </view>
<view class="action-item" @click="handleBuilding"> <!-- <view class="action-item" @click="handleBuilding">
<view class="iconfont icon-service text-blue icon"></view> <view class="iconfont icon-service text-blue icon"></view>
<text class="text">在线客服</text> <text class="text">在线客服</text>
</view> </view>
@ -42,17 +43,17 @@
<view class="action-item" @click="handleBuilding"> <view class="action-item" @click="handleBuilding">
<view class="iconfont icon-dianzan text-green icon"></view> <view class="iconfont icon-dianzan text-green icon"></view>
<text class="text">点赞我们</text> <text class="text">点赞我们</text>
</view> </view> -->
</view> </view>
<view class="menu-list"> <view class="menu-list">
<view class="list-cell list-cell-arrow" @click="handleToEditInfo"> <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
<view class="menu-item-box"> <view class="menu-item-box">
<view class="iconfont icon-user menu-icon"></view> <view class="iconfont icon-user menu-icon"></view>
<view>编辑资料</view> <view>编辑资料</view>
</view> </view>
</view> </view>
<view class="list-cell list-cell-arrow" @click="handleHelp"> <!-- <view class="list-cell list-cell-arrow" @click="handleHelp">
<view class="menu-item-box"> <view class="menu-item-box">
<view class="iconfont icon-help menu-icon"></view> <view class="iconfont icon-help menu-icon"></view>
<view>常见问题</view> <view>常见问题</view>
@ -63,126 +64,126 @@
<view class="iconfont icon-aixin menu-icon"></view> <view class="iconfont icon-aixin menu-icon"></view>
<view>关于我们</view> <view>关于我们</view>
</view> </view>
</view> </view> -->
<view class="list-cell list-cell-arrow" @click="handleToSetting"> <view class="list-cell list-cell-arrow" @click="handleToSetting">
<view class="menu-item-box"> <view class="menu-item-box">
<view class="iconfont icon-setting menu-icon"></view> <view class="iconfont icon-setting menu-icon"></view>
<view>应用设置</view> <view>应用设置</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
name: this.$store.state.user.name name: this.$store.state.user.name
} }
}, },
computed: { computed: {
avatar() { avatar() {
return this.$store.state.user.avatar return this.$store.state.user.avatar
}, },
windowHeight() { windowHeight() {
return uni.getSystemInfoSync().windowHeight - 50 return uni.getSystemInfoSync().windowHeight - 50
} }
}, },
methods: { methods: {
handleToInfo() { handleToInfo() {
this.$tab.navigateTo('/pages/mine/info/index') this.$tab.navigateTo('/pages/mine/info/index')
}, },
handleToEditInfo() { handleToEditInfo() {
this.$tab.navigateTo('/pages/mine/info/edit') this.$tab.navigateTo('/pages/mine/info/edit')
}, },
handleToSetting() { handleToSetting() {
this.$tab.navigateTo('/pages/mine/setting/index') this.$tab.navigateTo('/pages/mine/setting/index')
}, },
handleToLogin() { handleToLogin() {
this.$tab.reLaunch('/pages/login') this.$tab.reLaunch('/pages/login')
}, },
handleToAvatar() { handleToAvatar() {
this.$tab.navigateTo('/pages/mine/avatar/index') this.$tab.navigateTo('/pages/mine/avatar/index')
}, },
handleHelp() { handleHelp() {
this.$tab.navigateTo('/pages/mine/help/index') this.$tab.navigateTo('/pages/mine/help/index')
}, },
handleAbout() { handleAbout() {
this.$tab.navigateTo('/pages/mine/about/index') this.$tab.navigateTo('/pages/mine/about/index')
}, },
handleJiaoLiuQun() { handleJiaoLiuQun() {
this.$modal.showToast('QQ群①133713780(满)、②146013835(满)、③189091635') this.$modal.showToast('QQ群①133713780(满)、②146013835(满)、③189091635')
}, },
handleBuilding() { handleBuilding() {
this.$modal.showToast('模块建设中~') this.$modal.showToast('模块建设中~')
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
page { page {
background-color: #f5f6f7; background-color: #f5f6f7;
} }
.mine-container { .mine-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
.header-section { .header-section {
padding: 15px 15px 45px 15px; padding: 15px 15px 45px 15px;
background-color: #3c96f3; background-color: #3c96f3;
color: white; color: white;
.login-tip { .login-tip {
font-size: 18px; font-size: 18px;
margin-left: 10px; margin-left: 10px;
} }
.cu-avatar { .cu-avatar {
border: 2px solid #eaeaea; border: 2px solid #eaeaea;
.icon { .icon {
font-size: 40px; font-size: 40px;
} }
} }
.user-info { .user-info {
margin-left: 15px; margin-left: 15px;
.u_title { .u_title {
font-size: 18px; font-size: 18px;
line-height: 30px; line-height: 30px;
} }
} }
} }
.content-section { .content-section {
position: relative; position: relative;
top: -50px; top: -50px;
.mine-actions { .mine-actions {
margin: 15px 15px; margin: 15px 15px;
padding: 20px 0px; padding: 20px 0px;
border-radius: 8px; border-radius: 8px;
background-color: white; background-color: white;
.action-item { .action-item {
.icon { .icon {
font-size: 28px; font-size: 28px;
} }
.text { .text {
display: block; display: block;
font-size: 13px; font-size: 13px;
margin: 8px 0px; margin: 8px 0px;
} }
} }
} }
} }
} }
</style> </style>

View File

@ -40,7 +40,8 @@
</uni-file-picker> </uni-file-picker>
</view> </view>
</view> </view>
<button class="button" type="primary" style="margin-top:30px;" :loading="loading" @click="submit">提交</button> <button class="submit-button" type="primary" style="margin-top:30px;" :loading="loading"
@click="submit">提交</button>
</view> </view>
</template> </template>
@ -95,11 +96,11 @@
title: '提交成功', title: '提交成功',
duration: 2000 duration: 2000
}); });
uni.switchTab({ uni.switchTab({
url: '/pages/index' url: '/pages/ticket/list'
}); });
} }
}).finally(() => this.loading = false) }).finally(() => this.loading = false)
}, },
// 获取上传状态 // 获取上传状态
@ -142,9 +143,9 @@
}) })
}, },
}, },
mounted() { onLoad(options) {
uni.showLoading() uni.showLoading()
getTicket(this.$route.query.id).then(response => { getTicket(options.id).then(response => {
this.info = JSON.parse(JSON.stringify(response?.data || {})) this.info = JSON.parse(JSON.stringify(response?.data || {}))
const { const {
images = '' images = ''
@ -163,6 +164,7 @@
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
} }
} }
</script> </script>
@ -170,26 +172,43 @@
<style scoped lang="scss"> <style scoped lang="scss">
.container { .container {
background-color: #ffffff; background-color: #ffffff;
padding: 20px 20px; padding: 40rpx;
color: #19242d;
} }
.item-lists { .item-lists {
box-shadow: 0 0 10px rgba(0, 0, 0, .1), 0 0 0 rgba(0, 0, 0, .5); box-shadow: 0 0 20rpx rgba(0, 0, 0, .1), 0 0 0 rgba(0, 0, 0, .5);
border-radius: 5px; border-radius: 10rpx;
font-size: 14px; font-size: 26rpx;
line-height: 20px; line-height: 30rpx;
margin-bottom: 20px; margin-bottom: 40rpx;
.title { .title {
font-size: 16px; border-radius: 14rpx 14rpx 0 0;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
padding: 10px 15px; padding: 20rpx 30rpx;
background-color: #e4e4e4; font-weight: 700;
color: #333; position: relative;
&::after {
content: '';
display: block;
background-color: #4c7af3;
height: 30rpx;
width: 6rpx;
position: absolute;
left: 10rpx;
top: 20rpx;
}
} }
.info { .info {
padding: 10px 15px; padding: 20rpx 30rpx;
font-size: 24rpx;
} }
} }
</style>
.submit-button {
font-size: 28rpx;
}
</style>

244
pages/ticket/list.vue Normal file
View File

@ -0,0 +1,244 @@
<template>
<view class="container">
<view class="status-bar"></view>
<view class="page-title">工单</view>
<view class="btn-list">
<uni-row>
<uni-col :span="12">
<button type="default" class="btns" :class="{'active-btn' : active === 'undone'}"
@click="changeTab('undone')">待处理</button>
</uni-col>
<uni-col :span="12">
<button type="default" class="btns" :class="{'active-btn' : active === 'done'}"
@click="changeTab('done')">已处理</button>
</uni-col>
</uni-row>
</view>
<view v-if="list.length===0" class="no-data">暂无数据</view>
<view class="content scroll-y" v-else>
<view class="item-list" v-for="item in list" :key="item.ticketNo+'ticket'" @click="toDetail(item.id)">
<view class="item-title" :class="item.status === 3 ? 'done' : item.status === 2 ? 'doing' : 'undone'">
工单号{{item.ticketNo}}
<view class="item-status">{{ticketStatusOptions[item.status]}}</view>
</view>
<view class="item-content">
<view class="item-info">工单标题:
<text class="info-value">{{item.title}}</text>
</view>
<view class="item-info">问题描述:
<text class="info-value">{{item.content}}</text>
</view>
<view class="item-info">预期完成时间:
<text class="info-value">{{item.expectedCompleteTime || '-'}}</text>
</view>
<view class="item-info">处理人:
<text class="info-value">
{{item.workName || '-'}}
</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from 'vuex'
import {
listTicket
} from 'api/ems/ticket'
export default {
computed: {
...mapState({
ticketStatusOptions: (state) => state.ems.ticketStatusOptions
})
},
data() {
return {
active: 'undone',
total: 0,
list: [],
pageNum: 1,
pageSize: 20
}
},
methods: {
changeTab(active) {
if (active === this.active) return
this.active = active
this.reset()
this.init()
},
init() {
//1: '待处理', 2: '处理中', 3: '已处理'
let url = `/ticket/list?pageNum=${this.pageNum}&pageSize=${this.pageSize}`
if (this.active === 'done') {
url += `&status=3`
} else {
url += `&status=1&status=2`
}
uni.showLoading()
return listTicket(url).then(response => {
const data = JSON.parse(JSON.stringify(response?.rows || []))
this.list = this.list.concat(data)
this.total = response?.total || 0
}).finally(() => {
uni.hideLoading()
})
},
toDetail(id) {
this.$tab.navigateTo(`/pages/ticket/index?id=${id}`)
},
reset() {
this.list = []
this.total = 0
this.pageNum = 1
}
},
onReachBottom() {
if (this.list.length >= this.total) {
return console.log('数据已经加载完成')
}
this.pageNum += 1;
this.init().catch(() => {
this.pageNum -= 1
})
},
onShow() {
this.reset()
this.init()
}
}
</script>
<style scoped lang="scss">
.container {
position: relative;
background-color: #f5f6f7;
.no-data {
padding-top: 180rpx;
}
}
uni-button:after {
border: none;
border-radius: 0;
}
.btn-list {
position: fixed;
top: calc(var(--status-bar-height) + 56rpx);
left: 0;
width: 100%;
z-index: 2;
padding: 20rpx 30rpx;
background: #ffffff;
.btns {
border: none;
border-radius: 40rpx;
width: 90%;
font-size: 26rpx;
line-height: 64rpx;
color: #19242d;
background: #d9e7fc;
&.active-btn {
background: #4c7af3;
color: #fff;
}
}
}
.content {
padding: 120px 30rpx 120rpx 30rpx;
z-index: 1;
}
.page-title {
position: fixed;
top: var(--status-bar-height);
left: 0;
width: 100%;
z-index: 3;
padding: 16rpx 30rpx 10rpx;
font-size: 32rpx;
font-weight: 700;
color: #19242d;
background: #ffffff;
text-align: center;
}
// 工单列表
.item-list {
color: #4b4951;
border-radius: 14rpx;
box-shadow: 0 0 20rpx rgba(0, 0, 0, .1), 0 0 0 rgba(0, 0, 0, .5);
font-size: 26rpx;
line-height: 40rpx;
margin-bottom: 30rpx;
border: 1px solid #eee;
background: #ffffff;
// 标题
.item-title {
border-radius: 14rpx 14rpx 0 0;
border-bottom: 1px solid #eee;
padding: 20rpx 30rpx;
font-weight: 700;
position: relative;
.item-status {
position: absolute;
right: 0;
top: 0;
padding: 2rpx 20rpx;
color: #ffffff;
font-size: 22rpx;
}
&.done {
.item-status {
background-color: #30be95;
}
}
&.doing {
.item-status {
background-color: #3c68e7;
}
}
&.undone {
.item-status {
background-color: #ed7876;
}
}
}
// 内容
.item-content {
padding: 20rpx 30rpx;
font-size: 24rpx;
.item-info {
margin-bottom: 20rpx;
.info-value {
padding-left: 10rpx;
}
}
}
.item-content .item-info:last-child {
margin-bottom: 0;
}
}
.content .item-list:last-child {
margin-bottom: 0;
}
</style>

View File

@ -0,0 +1,116 @@
<template>
<view class="time-range">
<uni-datetime-picker v-model="dateRange" type="daterange" :end="defaultDateRange[1]" :clear-icon="false"
rangeSeparator="至" @change="changeTime" />
<view class="btns-container">
<button size="mini" class="small" :disabled="loading" @click="reset">重置</button>
<!-- <button type="primary" class="small" size="mini" :disabled="loading" @click="search">搜索</button> -->
<button type="primary" class="large" size="mini" :disabled="loading"
@click="timeLine('before')">上一时段</button>
<button type="primary" class="large" size="mini" @click="timeLine('next')"
:disabled="loading || disabledNextBtn">下一时段</button>
</view>
</view>
</template>
<script>
import {
formatDate
} from '@/utils/filters'
export default {
computed: {
disabledNextBtn() {
return new Date(this.dateRange[1]) >= new Date(this.defaultDateRange[1])
}
},
data() {
return {
loading: false,
dateRange: [],
defaultDateRange: [],
}
},
methods: {
init(today = false) {
const now = new Date(),
formatNow = formatDate(now);
const weekAgo = formatDate(today ? new Date(now.getTime()) : new Date(now.getTime() - 7 * 24 * 60 * 60 *
1000))
this.dateRange = [weekAgo, formatNow];
this.defaultDateRange = [weekAgo, formatNow];
console.log('初始化完成', this.defaultDateRange)
this.$emit('updateDate', this.dateRange)
},
changeTime(val) {
this.dateRange = val || []
this.$emit('updateDate', this.dateRange)
},
showBtnLoading(status) {
this.loading = status
},
resetDate() {
this.dateRange = this.defaultDateRange
},
//重置 设置时间范围为初始化时间段
reset() {
this.resetDate()
this.$emit('reset')
this.$emit('updateDate', this.dateRange)
},
// 搜索
search() {
this.$emit('updateDate', this.dateRange)
},
timeLine(type) {
if (!this.dateRange || !this.dateRange[0] || !this.dateRange[1]) return
const nowStartTimes = new Date(this.dateRange[0]).getTime(),
nowEndTimes = new Date(this.dateRange[1]).getTime(),
maxTime = new Date(this.defaultDateRange[1]).getTime()
const nowDis = nowEndTimes - nowStartTimes //用户当前选择时间差 可能=0
//baseTime,maxTime 毫秒数
const baseDis = 24 * 60 * 60 * 1000
const calcDis = nowDis === 0 ? baseDis : nowDis
let start = type === 'before' ? nowStartTimes - calcDis : nowStartTimes + calcDis
if (start > maxTime) start = maxTime
let end = type === 'before' ? nowEndTimes - calcDis : nowEndTimes + calcDis
if (end > maxTime) end = maxTime
this.dateRange = [formatDate(start), formatDate(end)]
this.$emit('updateDate', this.dateRange)
},
}
}
</script>
<style lang="scss" scoped>
.time-range {
padding: 10rpx 22rpx;
.btns-container {
margin-top: 20rpx;
margin-bottom: 40rpx;
uni-button {
padding-left: 0;
padding-right: 0;
text-align: center;
font-size: 26rpx;
&:not(:last-child) {
margin-right: 20rpx;
}
}
.small {
width: 120rpx;
}
.large {
width: 160rpx;
background-color: #547ef4;
&[disabled][type=primary] {
background-color: #89a8ffe6;
}
}
}
}
</style>

View File

@ -1,73 +1,62 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<uni-collapse ref="collapse" accordion v-if="list.length > 0"> <uni-collapse ref="collapse" accordion v-if="list.length > 0">
<uni-collapse-item v-for="(item,index) in list" :key="item.deviceId+'bmsdcc'" :open="index===0" <uni-collapse-item v-for="(item,index) in list" :key="item.deviceId+'bmscc'" :open="index===0"
:title="`${index+1}#${item.deviceName}`" :class="item.workStatus === '0' ? 'running' :'danger'"> class="common-collapse-item" :class="handleCardClass(item)">
<view>
<uni-group mode="card" class="work-group"> <template v-slot:title>
<uni-grid :column="3" :showBorder="false"> <view class='title-wrapper'>
<uni-grid-item> <view class="top">
<view class="status">{{CLUSTERWorkStatusOptions[item.workStatus] || '暂无数据'}}</view>
<text
class="name">{{`${item.parentDeviceName?`${item.parentDeviceName} -> ` : ''}${item.deviceName}`}}</text>
</view>
</view>
</template>
<view class='content'>
<!-- 设备状态栏 -->
<uni-group mode="card" class="status-card-group">
<view class="flex-container">
<view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">工作状态</view> <view class="title">工作状态</view>
<text class="text status">{{workStatusOptions[item.workStatus]}}</text> <text
class="text work-status-color">{{CLUSTERWorkStatusOptions[item.workStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">与PCS通信</view> <view class="title">与PCS通信</view>
<text <text
class="text">{{communicationStatusOptions[item.pcsCommunicationStatus]}}</text> class="text">{{communicationStatusOptions[item.pcsCommunicationStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">与EMS通信</view> <view class="title">与EMS通信</view>
<text <text
class="text">{{communicationStatusOptions[item.emsCommunicationStatus]}}</text> class="text">{{communicationStatusOptions[item.emsCommunicationStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
</uni-grid> </view>
</uni-group> </uni-group>
<uni-group mode="card"> <!-- 设备数据 -->
<uni-grid :column="3" :showBorder="false"> <uni-group mode="card" class="data-card-group">
<uni-grid-item v-for="(infoDataItem,infoDataIndex) in infoData" <uni-row v-for="(infoDataItem,infoDataIndex) in infoData" :key="infoDataIndex+'infoData'"
:key="infoDataIndex+'infoData'"> class="data-row">
<view class="grid-item-box"> <uni-col :span="8">
<view class="title">{{infoDataItem.label}}</view> <view class="title">{{infoDataItem.label}}</view>
<text class="text">{{item[infoDataItem.attr] | formatNumber}} </uni-col>
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <uni-col :span="16">
</text> <view class="value">{{item[infoDataItem.attr] | formatNumber}}
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</view> </view>
</uni-grid-item> </uni-col>
</uni-grid> </uni-row>
</uni-group> </uni-group>
<uni-group mode="card" style="margin-bottom: 25px;"> </view>
<uni-table border stripe emptyText="暂无数据"> </uni-collapse-item>
<!-- 表头行 --> </uni-collapse>
<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>
<view class="no-data" v-else> <view class="no-data" v-else>
暂无数据 暂无数据
</view> </view>
@ -75,164 +64,245 @@
</template> </template>
<script> <script>
import { import {
getBMSBatteryCluster getProjectDisplayData,
} from '@/api/ems/site.js' getStackNameList,
import { getClusterNameList
mapState } from '@/api/ems/site.js'
} from 'vuex' import {
export default { mapState
} from 'vuex'
export default {
computed: { computed: {
...mapState({ ...mapState({
workStatusOptions: (state) => CLUSTERWorkStatusOptions: (state) =>
state.ems.workStatusOptions, state.ems.CLUSTERWorkStatusOptions,
communicationStatusOptions: (state) => communicationStatusOptions: (state) =>
state.ems.communicationStatusOptions, state.ems.communicationStatusOptions,
}) })
}, },
data() { data() {
return { return {
unitObj: { displayData: [],
'电压': 'V', clusterDeviceList: [],
'温度': '&#8451;', list: [],
'SOC': '%' siteId: '',
}, infoData: [{
list: [],
siteId: '',
infoData: [{
label: '簇电压', label: '簇电压',
attr: 'clusterVoltage', attr: 'clusterVoltage',
unit: 'V' unit: 'V',
pointName: '簇电压'
}, },
{ {
label: '可充电量', label: '可充电量',
attr: 'chargeableCapacity', attr: 'chargeableCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '可充电量'
}, },
{ {
label: '累计充电量', label: '累计充电量',
attr: 'totalChargedCapacity', attr: 'totalChargedCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '累计充电量'
}, },
{ {
label: '簇电流', label: '簇电流',
attr: 'clusterCurrent', attr: 'clusterCurrent',
unit: 'A' unit: 'A',
pointName: '簇电流'
}, },
{ {
label: '可放电量', label: '可放电量',
attr: 'dischargeableCapacity', attr: 'dischargeableCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '可放电量'
}, },
{ {
label: '累计放电量', label: '累计放电量',
attr: 'totalDischargedCapacity', attr: 'totalDischargedCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '累计放电量'
}, },
{ {
label: 'SOH', label: 'SOH',
attr: 'soh', attr: 'soh',
unit: '%' unit: '%',
pointName: 'SOH'
}, },
{ {
label: '平均温度', label: '平均温度',
attr: 'averageTemperature', attr: 'averageTemperature',
unit: '&#8451;' unit: '&#8451;',
pointName: '平均温度'
}, },
{ {
label: '绝缘电阻', label: '绝缘电阻',
attr: 'insulationResistance', attr: 'insulationResistance',
unit: '&Omega;' unit: '&Omega;',
pointName: '绝缘电阻'
}, },
{ {
label: '当前SOC', label: '当前SOC',
attr: 'currentSoc', attr: 'currentSoc',
unit: '%' unit: '%',
pointName: '当前SOC'
}, },
] ]
} }
}, },
mounted() { methods: {
uni.showLoading() handleCardClass(item) {
this.siteId = this.$route.query.siteId || '' const {
getBMSBatteryCluster({ workStatus = ''
siteId: this.siteId } = item
}).then(response => { return !(Object.keys(this.CLUSTERWorkStatusOptions).includes(item.workStatus)) ? "timing-collapse-item" :
this.list = response?.data || [] workStatus === '9' ? 'warning-collapse-item' : 'running-collapse-item'
if (this.list.length > 0) { },
this.$nextTick(() => { getModuleRows(menuCode, sectionName) {
setTimeout(() => { return (this.displayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
this.$refs.collapse.resize() },
uni.hideLoading() getFieldName(fieldCode) {
}, 100) const raw = String(fieldCode || '').trim()
}) if (!raw) return ''
} else { const index = raw.lastIndexOf('__')
uni.hideLoading() return index >= 0 ? raw.slice(index + 2) : raw
} },
getFieldRowMap(rows = [], deviceId = '') {
}).catch(() => { const map = {}
uni.hideLoading() const targetDeviceId = String(deviceId || '')
}) rows.forEach(item => {
} if (!item || !item.fieldCode) return
} const itemDeviceId = String(item.deviceId || '')
</script> if (itemDeviceId !== targetDeviceId) return
const fieldName = this.getFieldName(item.fieldCode)
<style lang="scss" scoped> map[fieldName] = item
.page-container {} const displayName = String(item.fieldName || '').trim()
if (displayName && !map[displayName]) {
.grid-item-box { map[displayName] = item
flex: 1; }
// position: relative; })
/* #ifndef APP-NVUE */ rows.forEach(item => {
display: flex; if (!item || !item.fieldCode) return
/* #endif */ const itemDeviceId = String(item.deviceId || '')
flex-direction: column; if (itemDeviceId !== '') return
align-items: center; const fieldName = this.getFieldName(item.fieldCode)
justify-content: center; if (map[fieldName] === undefined || map[fieldName] === null || map[fieldName] === '') {
padding: 10px; map[fieldName] = item
background-color: #fff; }
const displayName = String(item.fieldName || '').trim()
.title { if (displayName && !map[displayName]) {
font-size: 14px; map[displayName] = item
color: #666; }
} })
return map
.text { },
margin-top: 10px; getFieldMap(rows = [], deviceId = '') {
font-size: 16px; const rowMap = this.getFieldRowMap(rows, deviceId)
font-weight: 500; return Object.keys(rowMap).reduce((acc, fieldName) => {
color: #666; const row = rowMap[fieldName]
overflow-wrap: anywhere; if (acc[fieldName] === undefined) {
} acc[fieldName] = row?.fieldValue
}
} return acc
}, {})
::v-deep { },
.uni-collapse-item__wrap { getLatestTime(menuCode) {
background-color: #eee; const times = (this.displayData || [])
} .filter(item => item.menuCode === menuCode && item.valueTime)
.map(item => new Date(item.valueTime).getTime())
.running { .filter(ts => !isNaN(ts))
.uni-collapse-item__title-text { if (times.length === 0) {
color: #05AEA3; return '-'
} }
const date = new Date(Math.max(...times))
.status { const p = (n) => String(n).padStart(2, '0')
color: #05AEA3; 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 => {
.danger { const stackList = response?.data || []
.uni-collapse-item__title-text { if (!stackList.length) {
color: #FC6B69; this.clusterDeviceList = []
} return
}
.status { const requests = stackList.map(stack => {
color: #FC6B69; const stackDeviceId = stack.deviceId || stack.id || ''
} return getClusterNameList({
} stackDeviceId,
} siteId: this.siteId
</style> })
.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()
})
}
}
</script>

View File

@ -2,75 +2,60 @@
<view class="page-container"> <view class="page-container">
<uni-collapse ref="collapse" accordion v-if="list.length > 0"> <uni-collapse ref="collapse" accordion v-if="list.length > 0">
<uni-collapse-item v-for="(item,index) in list" :key="item.deviceId+'bmszl'" :open="index===0" <uni-collapse-item v-for="(item,index) in list" :key="item.deviceId+'bmszl'" :open="index===0"
:title="`${index+1}#${item.deviceName}`" :class="item.workStatus === '0' ? 'running' :'danger'"> class="common-collapse-item" :class="handleCardClass(item,index)">
<view>
<uni-group mode="card" class="work-group"> <template v-slot:title>
<uni-grid :column="3" :showBorder="false"> <view class='title-wrapper'>
<uni-grid-item> <view class="top">
<view class="status">{{STACKWorkStatusOptions[item.workStatus] || '暂无数据'}}</view>
<text class="name">{{item.deviceName}}</text>
</view>
</view>
</template>
<view class='content'>
<!-- 设备状态栏 -->
<uni-group mode="card" class="status-card-group">
<view class="flex-container">
<view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">工作状态</view> <view class="title">工作状态</view>
<text class="text status">{{workStatusOptions[item.workStatus]}}</text> <text
class="text work-status-color">{{STACKWorkStatusOptions[item.workStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">与PCS通信</view> <view class="title">与PCS通信</view>
<text <text
class="text">{{communicationStatusOptions[item.pcsCommunicationStatus]}}</text> class="text">{{communicationStatusOptions[item.pcsCommunicationStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">与EMS通信</view> <view class="title">与EMS通信</view>
<text <text
class="text">{{communicationStatusOptions[item.emsCommunicationStatus]}}</text> class="text">{{communicationStatusOptions[item.emsCommunicationStatus] || '-'}}</text>
</view> </view>
</uni-grid-item> </view>
</uni-grid> </view>
</uni-group> </uni-group>
<uni-group mode="card"> <!-- 设备数据 -->
<uni-grid :column="3" :showBorder="false"> <uni-group mode="card" class="data-card-group">
<uni-grid-item v-for="(infoDataItem,infoDataIndex) in infoData" <uni-row v-for="(infoDataItem,infoDataIndex) in infoData" :key="infoDataIndex+'infoData'"
:key="infoDataIndex+'infoData'"> class="data-row">
<view class="grid-item-box"> <uni-col :span="8">
<view class="title">{{infoDataItem.label}}</view> <view class="title">{{infoDataItem.label}}</view>
<text class="text">{{item[infoDataItem.attr] | formatNumber}} </uni-col>
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <uni-col :span="16">
</text> <view class="value">{{item[infoDataItem.attr] | formatNumber}}
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</view> </view>
</uni-grid-item> </uni-col>
</uni-grid> </uni-row>
</uni-group> </uni-group>
<uni-group mode="card" style="margin-bottom: 25px;"> </view>
<uni-table border stripe emptyText="暂无数据"> </uni-collapse-item>
<!-- 表头行 --> </uni-collapse>
<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-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.minCellVoltage}}V</uni-td>
<uni-td align="center">{{tableItem.maxCellTemp}}&#8451;</uni-td>
<uni-td align="center">{{tableItem.minCellTemp}}&#8451;</uni-td>
</uni-tr>
</uni-table>
</uni-group>
</view>
</uni-collapse-item>
</uni-collapse>
<view class="no-data" v-else> <view class="no-data" v-else>
暂无数据 暂无数据
</view> </view>
@ -78,157 +63,196 @@
</template> </template>
<script> <script>
import { import {
getBMSOverView getProjectDisplayData,
} from '@/api/ems/site.js' getStackNameList
import { } from '@/api/ems/site.js'
mapState import {
} from 'vuex' mapState
export default { } from 'vuex'
export default {
computed: { computed: {
...mapState({ ...mapState({
workStatusOptions: (state) => STACKWorkStatusOptions: (state) =>
state.ems.workStatusOptions, state.ems.STACKWorkStatusOptions,
communicationStatusOptions: (state) => communicationStatusOptions: (state) =>
state.ems.communicationStatusOptions, state.ems.communicationStatusOptions,
}) })
}, },
data() { data() {
return { return {
list: [], displayData: [],
siteId: '', stackDeviceList: [],
infoData: [{ list: [],
siteId: '',
infoData: [{
label: '电池堆总电压', label: '电池堆总电压',
attr: 'stackVoltage', attr: 'stackVoltage',
unit: 'V' unit: 'V',
pointName: '电池堆电压'
}, },
{ {
label: '可充电量', label: '可充电量',
attr: 'availableChargeCapacity', attr: 'availableChargeCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '可充电量'
}, },
{ {
label: '累计充电量', label: '累计充电量',
attr: 'totalChargeCapacity', attr: 'totalChargeCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '累计充电量'
}, },
{ {
label: '电池堆总电流', label: '电池堆总电流',
attr: 'stackCurrent', attr: 'stackCurrent',
unit: 'A' unit: 'A',
pointName: '电池堆总电流'
}, },
{ {
label: '可放电量', label: '可放电量',
attr: 'availableDischargeCapacity', attr: 'availableDischargeCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '可放电量'
}, },
{ {
label: '累计放电量', label: '累计放电量',
attr: 'totalDischargeCapacity', attr: 'totalDischargeCapacity',
unit: 'kWh' unit: 'kWh',
pointName: '累计放电量'
}, },
{ {
label: 'SOH', label: 'SOH',
attr: 'stackSoh', attr: 'stackSoh',
unit: '%' unit: '%',
pointName: 'SOH'
}, },
{ {
label: '平均温度', label: '平均温度',
attr: 'operatingTemp', attr: 'operatingTemp',
unit: '&#8451;' unit: '&#8451;',
pointName: '平均温度'
}, },
{ {
label: '绝缘电阻', label: '绝缘电阻',
attr: 'stackInsulationResistance', attr: 'stackInsulationResistance',
unit: '&Omega;' unit: '&Omega;',
pointName: '绝缘电阻'
}, },
{ {
label: '当前SOC', label: '当前SOC',
attr: 'stackSoc', attr: 'stackSoc',
unit: '%' unit: '%',
pointName: '当前SOC'
}, },
] ]
} }
}, },
mounted() { methods: {
uni.showLoading() getModuleRows(menuCode, sectionName) {
this.siteId = this.$route.query.siteId || '' return (this.displayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
getBMSOverView({ },
siteId: this.siteId getFieldName(fieldCode) {
}).then(response => { const raw = String(fieldCode || '').trim()
this.list = response?.data || [] if (!raw) return ''
if (this.list.length > 0) { const index = raw.lastIndexOf('__')
this.$nextTick(() => { return index >= 0 ? raw.slice(index + 2) : raw
setTimeout(() => { },
this.$refs.collapse.resize() isEmptyValue(value) {
uni.hideLoading() return value === undefined || value === null || value === ''
}, 100) },
}) getFieldRowMap(rows = [], deviceId = '') {
} else { const map = {}
uni.hideLoading() const targetDeviceId = String(deviceId || '')
} rows.forEach(item => {
if (!item || !item.fieldCode) return
}).catch(() => { const itemDeviceId = String(item.deviceId || '')
uni.hideLoading() if (itemDeviceId !== targetDeviceId) return
}) map[this.getFieldName(item.fieldCode)] = item
} })
} rows.forEach(item => {
</script> if (!item || !item.fieldCode) return
const itemDeviceId = String(item.deviceId || '')
<style lang="scss" scoped> if (itemDeviceId !== '') return
.grid-item-box { const fieldName = this.getFieldName(item.fieldCode)
flex: 1; const existRow = map[fieldName]
// position: relative; if (!existRow || this.isEmptyValue(existRow.fieldValue)) {
/* #ifndef APP-NVUE */ map[fieldName] = item
display: flex; }
/* #endif */ })
flex-direction: column; return map
align-items: center; },
justify-content: center; getFieldMap(rowMap = {}) {
padding: 10px; const map = {}
background-color: #fff; Object.keys(rowMap || {}).forEach((fieldName) => {
map[fieldName] = rowMap[fieldName]?.fieldValue
.title { })
font-size: 14px; return map
color: #666; },
} buildBaseInfoList() {
const devices = (this.stackDeviceList && this.stackDeviceList.length > 0) ? this.stackDeviceList : [{
.text { deviceId: this.siteId,
margin-top: 10px; deviceName: 'BMS总览'
font-size: 16px; }]
font-weight: 500; this.list = devices.map(device => {
color: #666; const id = device.deviceId || device.id || this.siteId
overflow-wrap: anywhere; 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 {
::v-deep { ...infoMap,
.uni-collapse-item__wrap { workStatus: statusMap.workStatus,
background-color: #eee; pcsCommunicationStatus: statusMap.pcsCommunicationStatus,
} emsCommunicationStatus: statusMap.emsCommunicationStatus,
siteId: this.siteId,
.running { deviceId: id,
.uni-collapse-item__title-text { deviceName: device.deviceName || device.name || device.deviceId || device.id || 'BMS总览',
color: #05AEA3; batteryDataList: []
} }
})
.status { },
color: #05AEA3; handleCardClass(item) {
} const {
workStatus = ''
} } = item
return !Object.keys(this.STACKWorkStatusOptions).find(i => i === workStatus) ? "timing-collapse-item" :
.danger { workStatus === '9' ? 'warning-collapse-item' : 'running-collapse-item'
.uni-collapse-item__title-text { },
color: #FC6B69; updateData() {
} return Promise.all([
getProjectDisplayData(this.siteId),
.status { getStackNameList(this.siteId)
color: #FC6B69; ]).then(([displayResponse, stackResponse]) => {
} this.displayData = displayResponse?.data || []
} this.stackDeviceList = stackResponse?.data || []
} this.buildBaseInfoList()
</style> }).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()
})
}
}
</script>

View File

@ -1,219 +1,231 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<uni-collapse ref="collapse"> <uni-collapse ref="collapse" accordion v-if="list.length > 0">
<!-- 总表 --> <uni-collapse-item v-for="(item,index) in list" :key="index+'dbList'" :open="index===0"
<uni-collapse-item open :class="zbInfo.emsCommunicationStatus !== '0' ? 'danger' :'running'"> class="common-collapse-item" :class="{
'timing-collapse-item':!['0','2'].includes(item.emsCommunicationStatus),
'warning-collapse-item':item.emsCommunicationStatus === '2',
'running-collapse-item':item.emsCommunicationStatus === '0'
}">
<template v-slot:title> <template v-slot:title>
<view class="title-row"> <view class='title-wrapper'>
<view class="title">{{`1#${zbInfo.deviceName || ''}`}}</view> <view class="top">
<view class="msg"> <view class="status">{{communicationStatusOptions[item.emsCommunicationStatus] || '暂无数据'}}
<view>{{communicationStatusOptions[zbInfo.emsCommunicationStatus] || ''}}</view> </view>
<view>数据更新时间{{zbInfo.dataUpdateTime || ''}}</view> <text class="name">{{item.deviceName}}</text>
</view> </view>
</view> </view>
</template> </template>
<uni-group :title=" item.category" mode="card" v-for="(item,index) in zbInfo.loadDataDetailInfo" <view class='content'>
:key="index+'zbInfo'"> <uni-group mode="card" class="data-card-group">
<uni-row> <uni-row v-for="(tempDataItem,tempDataIndex) in
<uni-col :span="8"> (item.fieldConfigs || otherTypeMsg)" :key="tempDataIndex+'dbTempData'" class="data-row">
<view>/kWh</view> <uni-col :span="8">
</uni-col> <view class="title">{{tempDataItem.name}}</view>
<uni-col :span="16"> </uni-col>
<view>{{item.totalKwh}}</view> <uni-col :span="16">
</uni-col> <view class="value">{{item[tempDataItem.attr] | formatNumber}}
</uni-row> <text v-if="tempDataItem.unit" v-html="tempDataItem.unit"></text>
<uni-row> </view>
<uni-col :span="8"> </uni-col>
<view>/kWh</view> </uni-row>
</uni-col> </uni-group>
<uni-col :span="16"> </view>
<view>{{item.peakKwh}}</view>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="8">
<view>/kWh</view>
</uni-col>
<uni-col :span="16">
<view>{{item.highKwh}}</view>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="8">
<view>/kWh</view>
</uni-col>
<uni-col :span="16">
<view>{{item.flatKwh}}</view>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="8">
<view>/kWh</view>
</uni-col>
<uni-col :span="16">
<view>{{item.valleyKwh}}</view>
</uni-col>
</uni-row>
</uni-group>
</uni-collapse-item>
<!-- 储能表 -->
<uni-collapse-item open :class="cnbInfo.emsCommunicationStatus !== '0' ? 'danger' :'running'">
<template v-slot:title>
<view class="title-row">
<view class="title">{{`2#${cnbInfo.deviceName || ''}`}}</view>
<view class="msg">
<view>{{communicationStatusOptions[cnbInfo.emsCommunicationStatus] || ''}}</view>
<view>数据更新时间{{cnbInfo.dataUpdateTime || ''}}</view>
</view>
</view>
</template>
<uni-group :title="item.category" mode="card" v-for="(item,index) in cnbInfo.meteDataDetailInfo"
:key="index+'cnbInfo'">
<uni-row>
<uni-col :span="8">
<view>有功功率</view>
</uni-col>
<uni-col :span="16">
<view>{{item.activePower}}</view>
</uni-col>
</uni-row>
<uni-row>
<uni-col :span="8">
<view>无功功率</view>
</uni-col>
<uni-col :span="16">
<view>{{item.reactivePower}}</view>
</uni-col>
</uni-row>
</uni-group>
</uni-collapse-item> </uni-collapse-item>
</uni-collapse> </uni-collapse>
<view class="no-data" v-else>
暂无数据
</view>
</view> </view>
</template> </template>
<script> <script>
import { import {
getAmmeterDataList getProjectDisplayData,
} from '@/api/ems/site.js' getDeviceList
import { } from '@/api/ems/site.js'
mapState import {
} from 'vuex' mapState
export default { } from 'vuex'
export default {
computed: { computed: {
...mapState({ ...mapState({
communicationStatusOptions: (state) => communicationStatusOptions: (state) =>
state.ems.communicationStatusOptions, state.ems.communicationStatusOptions,
}) })
}, },
data() { data() {
return { return {
siteId: '', siteId: '',
zbInfo: {}, displayData: [],
cnbInfo: {}, ammeterDeviceList: [],
} list: [],
}, otherTypeMsg: [{
mounted() { name: '正向有功电能',
uni.showLoading() attr: 'forwardActive',
this.siteId = this.$route.query.siteId || '' pointName: '正向有功电能',
getAmmeterDataList({ unit: 'kWh'
siteId: this.siteId },
}).then(response => { {
this.zbInfo = JSON.parse(JSON.stringify(response?.data?.ammeterLoadData || {})); name: '反向有功电能',
this.cnbInfo = JSON.parse(JSON.stringify(response?.data?.ammeterMeteData || {})); attr: 'reverseActive',
this.$nextTick(() => { pointName: '反向有功电能',
setTimeout(() => { unit: 'kWh'
this.$refs.collapse.resize() },
uni.hideLoading() {
}, 100) 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 || ''
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()
}, 100)
})
} else {
uni.hideLoading()
}
}).catch(() => { }).catch(() => {
uni.hideLoading() uni.hideLoading()
}) })
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.title-row { .unknow-bd-device {
padding: 0 15px; text-align: center;
position: relative; padding: 20rpx;
height: 50px; font-size: 28rpx;
line-height: 50rpx;
.title { background-color: #fff;
font-weight: 500; color: #000;
line-height: 50px;
}
.msg {
position: absolute;
right: 15px;
top: 50%;
transform: translateY(-50%);
text-align: right;
}
} }
</style>
::v-deep {
.uni-group__title {
background-color: #959595;
.uni-group__title-text {
color: #fff;
}
}
.uni-collapse-item__wrap-content {
.uni-group--card:last-child {
margin-bottom: 25px;
}
}
// row-行样式
.uni-group__content {
padding: 10px 15px;
.uni-row {
padding: 5px 0;
}
}
// 折叠面板内容区域背景颜色
.uni-collapse-item__wrap {
background-color: #eee;
}
// 运行状态颜色区分
.running {
.uni-group__title {
background-color: #05AEA3;
}
.uni-collapse-item__title-text {
color: #05AEA3;
}
.title-row {
color: #05AEA3;
}
}
.danger {
.uni-group__title {
background-color: #FC6B69;
}
.uni-collapse-item__title-text {
color: #FC6B69;
}
.title-row {
color: #FC6B69;
}
}
}
</style>

View File

@ -1,181 +0,0 @@
<template>
<uni-popup ref="popup" type="center" @maskClick="show = false">
<view class="chart-popup">
<uni-datetime-picker v-model="range" type="daterange" start="2000-01-01" :end="end" rangeSeparator="至"
@change="changeTime" />
<view class="button-group" style="text-align: center;margin-top:20px;">
<button type="default" size="mini" @click="onReset">重置</button>
<button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button>
</view>
<view class="chart-container">
<qiun-data-charts type="line" :reload="show" :chartData="chartsData" :canvas2d="true"
canvasId="scrollcolumnid" :optsWatch='false' :inScrollView="true" :pageScrollTop="pageScrollTop"
:opts="options" :ontouch="true" />
</view>
</view>
</uni-popup>
</template>
<script>
import {
getSingleBatteryData
} from '@/api/ems/site.js'
export default {
props: {
pageScrollTop: {
type: Number,
default: 0
}
},
data() {
return {
options: {
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 4,
disableGrid: true
},
update: true,
duration: 0,
animation: false,
// enableScroll: true,
// padding: [10, 15, 10, 15]
},
show: false,
range: [],
end: "",
siteId: '',
deviceId: '',
clusterDeviceId: '',
dataType: '', //展示的数据类型 空值展示所有数据
loading: false,
chartsData: {},
}
},
methods: {
open({
siteId,
clusterDeviceId,
deviceId
}, dataType) {
this.$refs.popup.open()
this.loading = false
this.siteId = siteId
this.clusterDeviceId = clusterDeviceId
this.deviceId = deviceId
this.dataType = dataType
this.range = []
setTimeout(() => {
this.show = true
this.getData()
}, 300)
},
changeTime(val) {
this.range = val || []
},
onReset() {
this.range = []
this.getData()
},
onSearch() {
this.getData()
},
getData() {
if (this.loading) return
this.loading = true;
const {
siteId,
deviceId,
clusterDeviceId,
range: [startDate = '', endDate = '']
} = this;
this.chartsData?.series && (this.chartsData.series = [])
return getSingleBatteryData({
siteId,
deviceId,
clusterDeviceId,
startDate,
endDate
}).then(response => {
console.log('单体电池图表返回数据', response.data)
this.handledata(response?.data || [])
}).finally(() => {
this.loading = false;
})
},
handledata(data) {
let obj = {
voltage: '电压',
temperature: '温度',
soc: 'SOC',
soh: 'SOH',
},
categories = [],
dataTypeList = []
if (this.dataType) {
dataTypeList = [{
attr: this.dataType,
title: obj[this.dataType],
data: []
}]
} else {
dataTypeList = Object.entries(obj).map(([key, value]) => {
return {
attr: key,
title: value,
data: []
}
})
}
data.forEach(item => {
categories.push(item.dataTimestamp)
dataTypeList.forEach(i => {
i.data.push(item[i.attr] || undefined)
})
})
const series = dataTypeList.map(item => {
return {
"name": item.title,
"data": item.data
}
})
this.chartsData = JSON.parse(JSON.stringify({
categories,
series
}))
console.log('this.chartsData', this.chartsData)
}
},
mounted() {
const now = new Date(),
year = now.getFullYear(),
month = now.getMonth() + 1,
day = now.getDate()
this.end = year + '-' + month + '-' + day
}
}
</script>
<style lang="scss" scoped>
.chart-popup {
width: 360px;
background-color: #fff;
padding: 10px 15px;
.chart-container {
width: 100%;
height: 250px;
margin-top: 20px;
}
::v-deep {
uni-canvas {
height: 250px;
width: 100%;
}
}
}
</style>

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="container"> <view class="container">
<view class="search-icon" @click="openSearch"> <view class="search-icon" @click="openSearch">
<uni-icons type="search" size="40" color="#fff"></uni-icons> <uni-icons type="search" size="25" color="#fff"></uni-icons>
</view> </view>
<view class="list-container"> <view class="list-container">
<view class="no-data" v-if="list.length === 0">暂无数据</view> <view class="no-data" v-if="list.length === 0">暂无数据</view>
@ -10,7 +10,7 @@
<template v-slot:header> <template v-slot:header>
<view class="list-header"> <view class="list-header">
单体编号:{{item.deviceId}} 单体编号:{{item.deviceId}}
<button type="primary" size="mini" class="charts" @click="toDetail(item)">图表</button> <button type="primary" size="mini" class="charts-btn" @click="toDetail(item)">图表</button>
</view> </view>
</template> </template>
<template v-slot:body> <template v-slot:body>
@ -19,16 +19,17 @@
<uni-col :span="8"> <uni-col :span="8">
<view>簇号</view> <view>簇号</view>
</uni-col> </uni-col>
<uni-col :span="14"> <uni-col :span="16">
<view class="right">{{item.clusterDeviceId}}</view> <view class="right">{{item.clusterDeviceId || '-'}}</view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<uni-row> <uni-row>
<uni-col :span="8"> <uni-col :span="8">
<view>电压V</view> <view>电压V</view>
</uni-col> </uni-col>
<uni-col :span="14"> <uni-col :span="16">
<view class="right color" @click="toDetail(item,'voltage')">{{item.voltage}} <view class="right color">
<text @click="toDetail(item,'voltage')">{{item.voltage | formatNumber}}</text>
</view> </view>
</uni-col> </uni-col>
</uni-row> </uni-row>
@ -36,9 +37,10 @@
<uni-col :span="8"> <uni-col :span="8">
<view>温度</view> <view>温度</view>
</uni-col> </uni-col>
<uni-col :span="14"> <uni-col :span="16">
<view class="right color" @click="toDetail(item,'temperature')"> <view class="right color">
{{item.temperature}} <text
@click="toDetail(item,'temperature')">{{item.temperature | formatNumber}}</text>
</view> </view>
</uni-col> </uni-col>
</uni-row> </uni-row>
@ -46,16 +48,20 @@
<uni-col :span="8"> <uni-col :span="8">
<view>SOC%</view> <view>SOC%</view>
</uni-col> </uni-col>
<uni-col :span="14"> <uni-col :span="16">
<view class="right color" @click="toDetail(item,'soc')">{{item.soc}}</view> <view class="right color">
<text @click="toDetail(item,'soc')">{{item.soc | formatNumber}}</text>
</view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<uni-row> <uni-row>
<uni-col :span="8"> <uni-col :span="8">
<view>SOH%</view> <view>SOH%</view>
</uni-col> </uni-col>
<uni-col :span="14"> <uni-col :span="16">
<view class="right color" @click="toDetail(item,'soh')">{{item.soh}}</view> <view class="right color">
<text @click="toDetail(item,'soh')">{{item.soh | formatNumber}}</text>
</view>
</uni-col> </uni-col>
</uni-row> </uni-row>
</view> </view>
@ -63,7 +69,17 @@
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
</view> </view>
<chart ref="chart" :pageScrollTop="pageScrollTop" /> <uni-popup ref="popup" type="center" :animation="false" :mask-click="false" :is-mask-click="false"
@maskClick="maskClick">
<view class="chart-popup" v-if="showChart">
<date-range-select ref="chartDateRangeSelect" @updateDate="updateChartDate"
style="margin-bottom: 10px;" />
<view class="chart-container">
<qiun-data-charts type="area" :reload="showChart" :optsWatch='false' :opts="options"
:chartData="chartsData" :ontouch="true" :inScrollView="true" :pageScrollTop="pageScrollTop" />
</view>
</view>
</uni-popup>
<uni-popup ref="searchPopup" type="center"> <uni-popup ref="searchPopup" type="center">
<view class="uni-pa-5 search-container"> <view class="uni-pa-5 search-container">
<uni-forms ref="form"> <uni-forms ref="form">
@ -75,6 +91,9 @@
<uni-data-select :clear="false" v-model="search.clusterId" <uni-data-select :clear="false" v-model="search.clusterId"
:localdata="clusterOptions"></uni-data-select> :localdata="clusterOptions"></uni-data-select>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="编号">
<uni-easyinput type="text" v-model="search.batteryId" placeholder="请输入编号" />
</uni-forms-item>
</uni-forms> </uni-forms>
<view class="button-group" style="text-align: center;"> <view class="button-group" style="text-align: center;">
<button type="default" size="mini" @click="onReset">重置</button> <button type="default" size="mini" @click="onReset">重置</button>
@ -86,26 +105,19 @@
</template> </template>
<script> <script>
import Chart from './Chart.vue' import DateRangeSelect from './../DateRangeSelect.vue'
import { import {
getStackNameList, getStackNameList,
getClusterNameList, getClusterNameList,
getClusterDataInfoList, getClusterDataInfoList,
getSingleBatteryData
} from '@/api/ems/site.js' } from '@/api/ems/site.js'
import { import {
mapState mapState
} from 'vuex' } from 'vuex'
export default { export default {
components: { components: {
Chart DateRangeSelect
},
computed: {
...mapState({
workStatusOptions: (state) =>
state.ems.workStatusOptions,
communicationStatusOptions: (state) =>
state.ems.communicationStatusOptions,
})
}, },
data() { data() {
return { return {
@ -116,17 +128,160 @@
clusterOptions: [], clusterOptions: [],
search: { search: {
stackId: '', stackId: '',
clusterId: '' clusterId: '',
batteryId: ''
}, },
list: [], list: [],
siteId: '', siteId: '',
pageScrollTop: 0, pageScrollTop: 0,
// ucharts数据
showChart: false,
chartSearchData: {
},
options: {
padding: [10, 5, 0, 10],
duration: 0,
animation: false,
dataLabel: false,
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 3,
disableGrid: true
},
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
},
range: [],
end: Date.now(),
loading: false,
chartsData: {},
// ucharts数据结束
} }
}, },
onPageScroll(e) { onPageScroll(e) {
this.pageScrollTop = e.scrollTop this.pageScrollTop = e.scrollTop
}, },
onReachBottom() {
if (this.list.length >= this.total) {
return console.log('数据已经加载完成')
}
this.pageNum += 1 //每次搜索从1开始搜索
this.getTableData()
},
methods: { methods: {
//ucharts方法
maskClick() {
this.showChart = false
this.$refs.popup.close()
},
chartOpen({
siteId,
clusterDeviceId,
deviceId
}, dataType) {
this.loading = false
this.chartSearchData = {
clusterDeviceId,
deviceId,
dataType
}
this.$refs.popup.open()
setTimeout(() => {
this.showChart = true
this.$nextTick(() => {
this.$refs.chartDateRangeSelect.init()
})
}, 500)
},
updateChartDate(data) {
this.range = data || []
this.getChartData()
},
getChartData() {
if (this.loading) return
this.loading = true;
const {
siteId,
chartSearchData: {
deviceId,
clusterDeviceId
},
range: [startDate = '', endDate = '']
} = this;
this.chartsData = {}
return getSingleBatteryData({
siteId,
deviceId,
clusterDeviceId,
startDate,
endDate
}).then(response => {
this.handledata(response?.data || [])
}).finally(() => {
this.loading = false;
})
},
handledata(data) {
let obj = {
voltage: '电压',
temperature: '温度',
soc: 'SOC',
soh: 'SOH',
},
categories = [],
dataTypeList = [],
{
dataType
} = this.chartSearchData
if (dataType) {
dataTypeList = [{
attr: dataType,
title: obj[dataType],
data: []
}]
} else {
dataTypeList = Object.entries(obj).map(([key, value]) => {
return {
attr: key,
title: value,
data: []
}
})
}
data.forEach(item => {
categories.push(item.dataTimestamp)
dataTypeList.forEach(i => {
i.data.push(item[i.attr] || undefined)
})
})
const series = dataTypeList.map(item => {
return {
"name": item.title,
"data": item.data
}
})
this.chartsData = JSON.parse(JSON.stringify({
categories,
series
}))
console.log('this.chartsData', this.chartsData)
},
//ucharts方法结束
openSearch() { openSearch() {
this.$refs.searchPopup.open() this.$refs.searchPopup.open()
}, },
@ -140,17 +295,13 @@
} = item, { } = item, {
siteId siteId
} = this } = this
this.$refs.chart.open({ // this.$refs.chart.open({
this.chartOpen({
siteId, siteId,
clusterDeviceId, clusterDeviceId,
deviceId deviceId
}, dataType) }, dataType)
}, },
onReachBottom() {
console.log('触底了')
this.pageNum += 1 //每次搜索从1开始搜索
this.getTableData()
},
// 搜索 // 搜索
onSearch() { onSearch() {
this.pageNum = 1 //每次搜索从1开始搜索 this.pageNum = 1 //每次搜索从1开始搜索
@ -163,7 +314,8 @@
onReset() { onReset() {
this.search = { this.search = {
stackId: '', stackId: '',
clusterId: '' clusterId: '',
batteryId: ''
} }
this.clusterOptions = [] this.clusterOptions = []
this.pageNum = 1 this.pageNum = 1
@ -177,14 +329,12 @@
this.getClusterList() this.getClusterList()
} }
}, },
getStackList() { getStackList() {
getStackNameList({ getStackNameList(this.siteId).then(response => {
siteId: this.siteId this.stackOptions = JSON.parse(JSON.stringify(response?.data || [])).map(item => {
}).then(response => { return {
this.stackOptions = JSON.parse(JSON.stringify(response?.data || [])).map(item => { text: item.deviceName,
return { value: item.id
text: item.deviceName,
value: item.id
} }
}) })
}) })
@ -212,7 +362,8 @@
} }
const { const {
stackId: stackDeviceId, stackId: stackDeviceId,
clusterId: clusterDeviceId clusterId: clusterDeviceId,
batteryId
} = this.search } = this.search
const { const {
siteId, siteId,
@ -222,20 +373,21 @@
getClusterDataInfoList({ getClusterDataInfoList({
stackDeviceId, stackDeviceId,
clusterDeviceId, clusterDeviceId,
batteryId,
siteId, siteId,
pageNum, pageNum,
pageSize pageSize
}).then(response => { }).then(response => {
this.list = this.list.concat(response?.rows || []); this.list = this.list.concat(response?.rows?.[0]?.batteryList || []);
this.total = response?.total || 0 this.total = response?.total || 0
}).finally(() => { }).finally(() => {
uni.hideLoading() uni.hideLoading()
}) })
}, },
}, },
mounted() { onLoad(options) {
// uni.showLoading() // uni.showLoading()
this.siteId = this.$route.query.siteId || '' this.siteId = options.siteId || ''
this.getStackList() this.getStackList()
this.getTableData(true) this.getTableData(true)
} }
@ -245,21 +397,18 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
position: relative; position: relative;
background: #f5f5f5;
// position: fixed;
// width: 100%;
// height: 100%;
// overflow-y: auto;
.search-icon { .search-icon {
position: fixed; position: fixed;
bottom: 20px; bottom: 40rpx;
right: 20px; right: 40rpx;
z-index: 1; z-index: 1;
height: 50px; height: 60rpx;
width: 50px; width: 60rpx;
background-color: #007aff; background-color: #007aff;
border-radius: 100%; border-radius: 100%;
line-height: 50px; line-height: 60rpx;
text-align: center; text-align: center;
} }
@ -270,14 +419,26 @@
} }
.list-container { .list-container {
// z-index: 10; padding-top: 40rpx;
padding-top: 20px; padding-bottom: 100rpx;
padding-bottom: 50px; background: transparent;
background: #ffffff;
::v-deep { ::v-deep {
.uni-list {
background: transparent;
}
.uni-list-item {
padding: 10rpx 30rpx;
background-color: transparent !important;
}
.uni-list-item__container { .uni-list-item__container {
background-color: #ffffff;
padding: 0;
display: block; display: block;
border-radius: 10rpx;
box-shadow: 0 1px 16rpx 1px rgba($color: #a5a5a5, $alpha: 0.2);
} }
.uni-list--border-top, .uni-list--border-top,
@ -288,45 +449,69 @@
} }
.list-header { .list-header {
background-color: #05AEA3; border-radius: 14rpx 14rpx 0 0;
color: #fff; border-bottom: 1px solid #eee;
padding: 10px 15px; padding: 20rpx 30rpx;
border-radius: 5px 5px 0 0; font-weight: 700;
font-size: 28rpx;
position: relative; position: relative;
color: #333;
.charts { .charts-btn {
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 15px; right: 20rpx;
font-size: 26rpx;
transform: translateY(-50%); transform: translateY(-50%);
// background-color: #ff7300; background-color: #4c7af3;
} }
} }
.list-body { .list-body {
padding: 10px 15px; padding: 10rpx 0;
border: 1px solid #eee;
border-top: none;
border-radius: 0 0 5px 5px;
font-size: 14px;
color: #666;
.right { >.uni-row {
font-size: 26rpx;
line-height: 36rpx;
color: #000; color: #000;
} padding: 12rpx 30rpx;
.color { .left {
color: #007aff; color: #333;
} text-align: left;
.uni-row {
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
} }
.right {
text-align: right;
&.color {
color: #4c7af3;
font-weight: 700;
}
}
}
}
}
.chart-popup {
width: 720rpx;
background-color: #fff;
padding: 20rpx 30rpx;
.chart-container {
width: 100%;
height: 500rpx;
margin-top: 40rpx;
}
::v-deep {
uni-canvas {
height: 500rpx;
width: 100%;
} }
} }
} }
} }
</style> </style>

View File

@ -1,90 +1,477 @@
<template> <template>
<view class="work-container"> <view class="work-container">
<!-- 站点选择列表 --> <site-switch-header :site-id="siteId" :site-type-options="siteTypeOptions" :site-address="baseInfo.siteAddress"
<uni-section title="站点选择" type="line" titleFontSize='16px' class="uni-pa-5"> :running-time="baseInfo.runningTime" @change="selectedSite" />
<uni-data-select :clear="false" v-model="siteId" :localdata="siteList" <!-- 静态信息 -->
@change="selectedSite"></uni-data-select> <view class="base-info">
</uni-section> <uni-group mode="card" class="install-data">
<!-- 菜单 --> <uni-grid :column="2" :showBorder="false" :square="false" :highlight="false">
<!-- <uni-section title="工作台" type="line" titleFontSize='16px'></uni-section> --> <uni-grid-item>
<view class="grid-body"> <view class="grid-item-box">
<uni-grid :column="4" :showBorder="false" @change="toDetail"> <view class="title">装机功率(MWh)</view>
<uni-grid-item v-for="(item,index) in gridList" :index="index" :key="index+'work'"> <view class="text">{{baseInfo.installPower | formatNumber}}</view>
<view class="grid-item-box"> </view>
<uni-icons :type="item.icon" size="30"></uni-icons> </uni-grid-item>
<text class="text">{{item.text}}</text> <uni-grid-item>
</view> <view class="grid-item-box">
</uni-grid-item> <view class="title">装机容量(MWh)</view>
<view class="text">{{baseInfo.installCapacity | formatNumber}}</view>
</uni-grid> </view>
</uni-grid-item>
</uni-grid>
</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> </view>
</view> </view>
</template> </template>
<script> <script>
import { import {
getAllSites mapGetters
} from '@/api/ems/site.js' } from 'vuex'
export default { import DateRangeSelect from './DateRangeSelect.vue'
import SiteSwitchHeader from '@/components/SiteSwitchHeader/index.vue'
import {
getAllSites,
getSingleSiteBaseInfo,
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,
SiteSwitchHeader
},
data() { data() {
return { return {
siteList: [], // 图表数据
weekChartTimeRange: [],
activeChartTimeRange: [],
weekChartData: {},
activeChartData: {},
curveDisplayData: [],
curveDisplayLoadingPromise: null,
pageScrollTop: 0,
glqxOptions: {
padding: [10, 5, 0, 10],
dataLabel: false,
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 3,
disableGrid: true
},
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
// update: true,
// duration: 2,
// animation: false,
// enableScroll: true,
// padding: [10, 15, 10, 15]
},
options: {
padding: [10, 5, 0, 10],
dataLabel: false,
enableScroll: true,
xAxis: {
scrollShow: true,
itemCount: 5,
disableGrid: true
},
extra: {
area: {
type: "curve",
opacity: 0.2,
addLine: true,
width: 2,
gradient: true,
activeType: "hollow"
}
}
// update: true,
// duration: 2,
// animation: false,
// enableScroll: true,
// padding: [10, 15, 10, 15]
},
// 图表数据结束
deviceCategoryOptions: [], //当前站点包含的设备类别
siteTypeOptions: createSiteTypeOptions(),
siteId: '', //选择的站点ID siteId: '', //选择的站点ID
baseInfo: {}, //站点基本信息
gridList: [{ gridList: [{
page: 'bmszl', page: 'bmszl',
icon: 'map-filled', icon: 'icon-BMS',
text: 'BMS总览', text: 'BMS总览',
categoryName: 'STACK'
}, },
{ {
page: 'bmsdcc', page: 'bmsdcc',
icon: 'map', icon: 'icon-a-dianchicunengliangkuai',
text: 'BMS电池簇', text: 'BMS电池簇',
categoryName: 'CLUSTER'
}, },
{ {
page: 'pcs', page: 'pcs',
icon: 'flag-filled', icon: 'icon-PCS',
text: 'PCS', text: 'PCS',
categoryName: 'PCS'
}, },
{ {
page: 'db', page: 'db',
icon: 'smallcircle', icon: 'icon-dianbiao4',
text: '电表', text: '电表',
}, categoryName: 'AMMETER'
{ },
page: 'dtdc', {
icon: 'smallcircle-filled', page: 'yl',
text: '单体电池', icon: 'icon-gongneng-diandongji',
text: '冷却',
categoryName: 'COOLING'
},
{
page: 'dtdc',
icon: 'icon-dantidianchi',
text: '单体电池',
categoryName: 'BATTERY'
} }
] ]
} }
}, },
methods: { computed: {
...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 || []
this.siteId && this.getWeekChartData()
},
// 更新当日功率曲线时间范围 重置图表
updateActiveChartDate(data) {
this.activeChartTimeRange = data || []
this.siteId && this.getGVQXData()
},
toDetail(e) { toDetail(e) {
if (!this.siteId) return uni.showToast({
title: "请选择清单",
icon: 'none'
})
const { const {
index index
} = e.detail } = e.detail
this.$tab.navigateTo(`/pages/work/${this.gridList[index].page}/index?siteId=${this.siteId}`) this.$tab.navigateTo(`/pages/work/${this.siteGirdList[index].page}/index?siteId=${this.siteId}`)
}, },
selectedSite(id) { selectedSite(data) {
this.siteId = id const siteObj = (data.detail.value || [])[1]
} const value = siteObj?.value
}, if (!value) return
// 页面切换不会重新调用如果希望每次切换页面都重新调接口使用onShow if (value === this.siteId) return
mounted() { this.siteId = value
getAllSites().then(response => { this.$store.commit('SET_CURRENTSITEID', value)
console.log('返回数据', response) this.updateSiteInfo()
const data = response?.data || [] },
this.siteList = data.map(item => { updateSiteInfo() {
return { if (!this.siteId) return
text: item.siteName, this.curveDisplayData = []
value: item.siteId, this.curveDisplayLoadingPromise = null
id: item.id 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 || []
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
})
})
this.siteTypeOptions = siteTypeOptions.filter(item => (item.children || []).length > 0)
const siteChildren = this.siteTypeOptions.reduce((result, typeItem) => {
return result.concat(typeItem.children || [])
}, [])
// 设置默认展示的站点
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() {
getSingleSiteBaseInfo({
siteId: this.siteId
}).then(response => {
console.log('获取站点基本信息', response)
this.baseInfo = response?.data || {}
}) })
// 设置默认展示的站点 },
data.length > 0 && (this.siteId = data[0].siteId) 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}`
},
getGVQXData() {
this.$refs.activeChartDateRangeSelect.showBtnLoading(true)
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: '电网功率',
row: this.findActiveCurveRow(sectionRows, ['gridpower', '电网功率'])
},
{
name: '负载功率',
row: this.findActiveCurveRow(sectionRows, ['loadpower', '负载功率'])
},
{
name: '储能功率',
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))))
})
}).finally(() => this.$refs.activeChartDateRangeSelect.showBtnLoading(false))
},
getWeekChartData() {
this.$refs.weekChartDateRangeSelect.showBtnLoading(true)
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))))
})
}).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(() => {
this.getSiteList()
this.$refs.weekChartDateRangeSelect.init()
this.$refs.activeChartDateRangeSelect.init(true)
}) })
} },
// 页面滚动 设置pageScrollTop chart显示需要
onPageScroll(e) {
this.pageScrollTop = e.scrollTop
},
} }
</script> </script>
@ -97,10 +484,11 @@
background-color: #fff; background-color: #fff;
min-height: 100%; min-height: 100%;
height: auto; height: auto;
font-size: 26rpx;
line-height: 30rpx;
} }
view { view {
font-size: 14px;
line-height: inherit; line-height: inherit;
} }
@ -108,27 +496,107 @@
.text { .text {
text-align: center; text-align: center;
font-size: 26rpx;
margin-top: 10rpx; margin-top: 10rpx;
} }
.grid-item-box { // 基本信息
flex: 1; .base-info {
/* #ifndef APP-NVUE */ margin-top: -80rpx;
display: flex; border-radius: 80rpx 80rpx 0 0;
/* #endif */ padding: 30rpx;
flex-direction: column; background-color: #fff;
align-items: center;
justify-content: center;
padding: 15px 0;
}
.uni-margin-wrap { // 装机功率
width: 690rpx; .install-data {
width: 100%; .grid-item-box {
; padding-top: 6rpx;
} padding-bottom: 6rpx;
.text {
margin-top: 20rpx;
color: #000;
}
}
}
.sections-list {
margin-bottom: 10rpx;
::v-deep &>.uni-section-header {
font-weight: 700;
font-size: 26rpx;
line-height: 30rpx;
}
}
.sections-list:not(:first-child) {
margin-top: 40rpx;
}
::v-deep {
.uni-section__content-title {
font-size: 26rpx !important;
}
.uni-select__input-box {
width: 100%;
.uni-select__input-text {
font-size: 24rpx;
}
}
.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;
// }
}
.work-box {
.icon {
font-size: 52rpx;
color: #547ef4;
}
.text {
font-size: 26rpx;
padding-top: 10rpx;
color: #000;
}
}
.base-lists {
font-size: 24rpx;
line-height: 40rpx;
padding: 10rpx 20rpx;
padding-left: 40rpx;
.left {
width: 220rpx;
display: inline-block;
color: #666;
}
.right {
color: #333;
}
}
}
@media screen and (min-width: 500px) {} @media screen and (min-width: 500px) {}
</style> </style>

View File

@ -1,390 +1,493 @@
<template> <template>
<view class="page-container"> <view class="page-container">
<!-- 顶部6个数据 --> <!-- 顶部总览横向展示 -->
<uni-grid class="info-grid" :column="2" :showBorder="false" style="margin-bottom: 10px;"> <scroll-view class="info-overview-scroll" scroll-x>
<uni-grid-item v-for="(item,index) in runningHeadData" :key="index+'head'"> <view class="info-overview-row">
<view class="grid-item-box"> <view class="info-overview-card" v-for="(item,index) in runningHeadCards" :key="index+'head'">
<view class="title">{{item.title}}</view> <view class="grid-item-box">
<text class="text">{{runningHeadInfo[item.attr] | formatNumber}}</text> <image :src="require('@/static/images/ems/pcs/'+item.img+'.jpg')" class="icon" alt="" />
</view> <view class="title">{{item.title}}</view>
</uni-grid-item> <view class="text">{{item.value | formatNumber}}</view>
</uni-grid> </view>
</view>
</view>
</scroll-view>
<!-- 设备标签横向展示 -->
<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)">
<uni-collapse ref="collapse" accordion v-if="list.length > 0">
<uni-collapse-item v-for="(item,index) in list" :key="item.deviceId+'pcs'" :open="index===0"
:class="item.workStatus === '1' ? 'danger' : item.workStatus === '2' ? 'close' : 'running'">
<template v-slot:title> <template v-slot:title>
<view class="title-row"> <view class='title-wrapper'>
<view class="title">{{index+1}}#{{item.deviceName || ''}}</view> <view class="top">
<view class="msg"> <view class="status">{{formatDictValue((PCSWorkStatusOptions || {}), item.workStatus, '暂无数据')}}</view>
<view>{{communicationStatusOptions[item.communicationStatus] || ''}}</view> <text class="name">{{item.deviceName}}</text>
<view>数据更新时间{{item.dataUpdateTime || ''}}</view>
</view> </view>
</view> </view>
</template> </template>
<view> <view class='content'>
<uni-group mode="card"> <!-- 设备状态栏 -->
<uni-grid :column="4" :showBorder="false"> <uni-group mode="card" class="status-card-group no-wrapper-padding">
<uni-grid-item> <view class="flex-container">
<view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">工作状态</view> <view class="title">工作状态</view>
<text class="text" <text
:class="item.workStatus === '0' ? 'status-running' : 'status-danger'">{{workStatusOptions[item.workStatus]}}</text> class="text work-status-color">{{formatDictValue((PCSWorkStatusOptions || {}), item.workStatus)}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">并网状态</view> <view class="title">并网状态</view>
<text class="text">{{gridStatusOptions[item.gridStatus]}}</text> <text class="text">{{formatDictValue((gridStatusOptions || {}), item.gridStatus)}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">设备状态</view> <view class="title">设备状态</view>
<text class="text" <text class="text">{{formatDictValue((deviceStatusOptions || {}), item.deviceStatus)}}</text>
:class="item.deviceStatus === '0' ? 'status-running' : 'status-danger'">{{deviceStatusOptions[item.deviceStatus]}}</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">控制模式</view> <view class="title">控制模式</view>
<text class="text">{{controlModeOptions[item.controlMode]}}</text> <text class="text">{{formatDictValue((controlModeOptions || {}), item.controlMode)}}</text>
</view> </view>
</uni-grid-item> </view>
</uni-grid> </view>
</uni-group> </uni-group>
<!-- infoData --> <!-- 设备数据 -->
<uni-group mode="card" <uni-group mode="card" class="data-card-group"
:style="{marginBottom:!item.pcsBranchInfoList || item.pcsBranchInfoList.length === 0 ?'25px' : ''}"> :style="{marginBottom:!item.pcsBranchInfoList || item.pcsBranchInfoList.length === 0 ?'25px' : ''}">
<uni-grid :column="2" showBorder class="info-grid"> <uni-row v-for="(infoDataItem,infoDataIndex) in infoData" :key="infoDataIndex+'infoData'"
<uni-grid-item v-for="(infoDataItem,infoDataIndex) in infoData" class="data-row">
:key="infoDataIndex+'infoData'"> <uni-col :span="8">
<view class="grid-item-box"> <view class="title">{{infoDataItem.label}}</view>
<view class="title">{{infoDataItem.label}}</view> </uni-col>
<text class="text">{{item[infoDataItem.attr] | formatNumber}} <uni-col :span="16">
<text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text> <view class="value">{{item[infoDataItem.attr] | formatNumber}}
</text> <text v-if="infoDataItem.unit" v-html="infoDataItem.unit"></text>
</view> </view>
</uni-grid-item> </uni-col>
</uni-grid> </uni-row>
</uni-group> </uni-group>
<!-- 支路 --> <!-- 支路 -->
<uni-group class="pcs-branch-group" :title="`支路${pcsBranchIndex+1}`" mode="card" <uni-group class="branch-card-group" :title="`支路${pcsBranchIndex+1}`" mode="card"
v-for="(pcsBranchItem,pcsBranchIndex) in item.pcsBranchInfoList" v-for="(pcsBranchItem,pcsBranchIndex) in item.pcsBranchInfoList"
:key="pcsBranchIndex+'pcsBranchInfoList'"> :key="pcsBranchIndex+'pcsBranchInfoList'">
<uni-grid :column="3" :showBorder="false" class="info-grid"> <view class="flex-container">
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">直流功率</view> <view class="title">直流功率</view>
<text class="text">{{pcsBranchItem.dcPower}}kW</text> <text class="text">{{pcsBranchItem.dcPower}}kW</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">直流电压</view> <view class="title">直流电压</view>
<text class="text">{{pcsBranchItem.dcVoltage}}V</text> <text class="text">{{pcsBranchItem.dcVoltage}}V</text>
</view> </view>
</uni-grid-item> </view>
<uni-grid-item> <view class="flex-lists">
<view class="grid-item-box"> <view class="grid-item-box">
<view class="title">直流电流</view> <view class="title">直流电流</view>
<text class="text">{{pcsBranchItem.dcCurrent}}A</text> <text class="text">{{pcsBranchItem.dcCurrent}}A</text>
</view> </view>
</uni-grid-item> </view>
</uni-grid> </view>
</uni-group> </uni-group>
</view> </view>
</uni-collapse-item> </uni-collapse-item>
</uni-collapse> </uni-collapse>
<view class="no-data" v-else> <view class="no-data" v-else>
暂无数据 暂无数据
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import { import {
getRunningHeadInfo, getProjectDisplayData,
getPcsDetailInfo getPcsNameList
} from '@/api/ems/site.js' } from '@/api/ems/site.js'
import { import {
mapState mapState
} from 'vuex' } from 'vuex'
export default { export default {
computed: { computed: {
...mapState({ ...mapState({
workStatusOptions: (state) => PCSWorkStatusOptions: (state) =>
state.ems.workStatusOptions, state.ems.PCSWorkStatusOptions,
communicationStatusOptions: (state) => communicationStatusOptions: (state) =>
state.ems.communicationStatusOptions, state.ems.communicationStatusOptions,
deviceStatusOptions: (state) => deviceStatusOptions: (state) =>
state.ems.deviceStatusOptions, state.ems.deviceStatusOptions,
gridStatusOptions: (state) => gridStatusOptions: (state) =>
state.ems.gridStatusOptions, state.ems.gridStatusOptions,
controlModeOptions: (state) => controlModeOptions: (state) =>
state.ems.controlModeOptions, state.ems.controlModeOptions,
}) }),
}, runningHeadCards() {
data() { const sectionData = (this.runningDisplayData || []).filter(item => item.sectionName === '运行概览')
return { return sectionData.map((item, index) => ({
runningHeadData: [{ title: item.fieldName,
title: '实时有功功率kW', value: item.fieldValue,
bgColor: '#FFF2CB', img: this.getHeadCardImg(item, index)
attr: 'totalActivePower' }))
}, { },
title: '实时无功功率kVar', filteredList() {
bgColor: '#CBD6FF', if (!this.selectedPcsId) {
attr: 'totalReactivePower' return this.list || []
}, { }
title: '电池堆SOC', return (this.list || []).filter(item => (item.deviceId || '') === this.selectedPcsId)
bgColor: '#DCCBFF', }
attr: 'soc' },
}, { data() {
title: '电池堆SOH', return {
bgColor: '#FFD4CB', runningDisplayData: [],
attr: 'soh' pcsDeviceList: [],
}, { selectedPcsId: '',
title: '今日充电量kWh', list: [],
bgColor: '#FFD6F8', siteId: '',
attr: 'dayChargedCap'
}, {
title: '今日放电量kWh',
bgColor: '#E1FFCA',
attr: 'dayDisChargedCap'
}],
runningHeadInfo: {},
list: [],
siteId: '',
infoData: [{ infoData: [{
label: '总交流有功电率', label: "总交流有功功率",
attr: 'totalActivePower', attr: "totalActivePower",
unit: 'kW' unit: "kW",
pointName: "总交流有功功率",
}, },
{ {
label: '总交流无功电率', label: "总交流无功功率",
attr: 'totalReactivePower', attr: "totalReactivePower",
unit: 'kVar' unit: "kVar",
pointName: "总交流无功功率",
}, },
{ {
label: '当天交流充电量', label: "当天交流充电量",
attr: 'dailyAcChargeEnergy', attr: "dailyAcChargeEnergy",
unit: 'kWh' unit: "kWh",
pointName: "当天交流充电量 (kWh)",
}, },
{ {
label: '当天交流放电量', label: "当天交流放电量",
attr: 'dailyAcDischargeEnergy', attr: "dailyAcDischargeEnergy",
unit: 'kWh' unit: "kWh",
pointName: "当天交流放电量 (kWh)",
}, },
{ {
label: '总交流视在功率', label: "A相电压",
attr: 'totalApparentPower', attr: "aPhaseVoltage",
unit: 'kVA' unit: "V",
pointName: ""
}, },
{ {
label: '总交流功率因数', label: "A相电流",
attr: 'totalPowerFactor', attr: "aPhaseCurrent",
unit: '' unit: "A",
pointName: "A相电流",
},
{
label: "B相电压",
attr: "bPhaseVoltage",
unit: "V",
pointName: ""
}, },
{ {
label: 'PCS模块温度', label: "B相电流",
attr: 'pcsModuleTemperature', attr: "bPhaseCurrent",
unit: '&#8451;' unit: "A",
pointName: "B相电流",
}, },
{ {
label: 'PCS环境温度', label: "总交流视在功率",
attr: 'pcsEnvironmentTemperature', attr: "totalApparentPower",
unit: '&#8451;' unit: "kVA",
pointName: "总交流视在功率",
}, },
{ {
label: 'A相电压', label: "总交流功率因数",
attr: 'aPhaseVoltage', attr: "totalPowerFactor",
unit: 'V' unit: "",
pointName: "总交流功率因数",
}, },
{ {
label: 'A相电流', label: "PCS模块温度",
attr: 'aPhaseCurrent', attr: "pcsModuleTemperature",
unit: 'A' unit: "&#8451;",
pointName: "",
}, },
{ {
label: 'B相电压', label: "PCS环境温度",
attr: 'bPhaseVoltage', attr: "pcsEnvironmentTemperature",
unit: 'V' unit: "&#8451;",
pointName: "",
}, },
{ {
label: 'B相电流', label: "C相电压",
attr: 'bPhaseCurrent', attr: "cPhaseVoltage",
unit: 'A' unit: "V",
pointName: ""
}, },
{ {
label: 'C相电压', label: "C相电流",
attr: 'cPhaseVoltage', attr: "cPhaseCurrent",
unit: 'V' unit: "A",
pointName: "C相电流",
}, },
{ {
label: 'C相电流', label: "交流频率",
attr: 'cPhaseCurrent', attr: "acFrequency",
unit: 'A' unit: "Hz",
pointName: "交流频率",
}, },
{
label: '交流频率',
attr: 'acFrequency',
unit: 'Hz'
}
] ]
} }
}, },
mounted() { methods: {
uni.showLoading() normalizeDictKey(value) {
this.siteId = this.$route.query.siteId || '' const raw = String(value == null ? '' : value).trim()
getRunningHeadInfo({ if (!raw) return ''
siteId: this.siteId if (/^-?\d+(\.0+)?$/.test(raw)) {
}).then(response => { return String(parseInt(raw, 10))
this.runningHeadInfo = response?.data || {} }
}) return raw
},
getPcsDetailInfo({ formatDictValue(options, value, emptyText = '-') {
siteId: this.siteId const dict = (options && typeof options === 'object') ? options : {}
}).then(response => { const key = this.normalizeDictKey(value)
this.list = response?.data || [] if (!key) return emptyText
if (this.list.length > 0) { return dict[key] || key
this.$nextTick(() => { },
setTimeout(() => { normalizeDeviceId(value) {
this.$refs.collapse.resize() return String(value == null ? '' : value).trim().toUpperCase()
uni.hideLoading() },
}, 100) getModuleRows(menuCode, sectionName) {
}) return (this.runningDisplayData || []).filter(item => item.menuCode === menuCode && item.sectionName === sectionName)
} else { },
uni.hideLoading() getFieldName(fieldCode) {
} if (!fieldCode) {
}).catch(() => { return ''
uni.hideLoading() }
}) 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 = 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 || ''
Promise.all([
getProjectDisplayData(this.siteId),
this.getPcsDeviceList()
]).then(([displayResponse]) => {
this.runningDisplayData = displayResponse?.data || []
this.buildPcsList()
if (this.list.length > 0) {
this.$nextTick(() => {
setTimeout(() => {
this.$refs.collapse.resize()
uni.hideLoading()
}, 100)
})
} else {
uni.hideLoading()
}
}).catch(() => {
uni.hideLoading()
})
}
} }
</script> </script>
<style lang="scss" scoped>
<style lang="scss" scoped> .info-overview-scroll {
.title-row { background: #fff;
padding: 0 15px; padding: 0 20rpx;
position: relative; white-space: nowrap;
height: 50px; }
.title { .info-overview-row {
font-weight: 500; display: inline-flex;
line-height: 50px; gap: 20rpx;
} padding: 20rpx 0;
}
.msg {
position: absolute; .info-overview-card {
right: 15px; width: 280rpx;
top: 50%; flex: 0 0 auto;
transform: translateY(-50%); }
text-align: right;
} .grid-item-box {
} box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.08);
border-radius: 20rpx;
.grid-item-box { padding: 20rpx;
flex: 1; background: #fff;
// position: relative; }
/* #ifndef APP-NVUE */
display: flex; .grid-item-box .title {
/* #endif */ color: #333;
flex-direction: column; margin-top: 10rpx;
align-items: center; }
justify-content: center;
padding: 10px; .grid-item-box .text {
background-color: #fff; color: #000;
white-space: nowrap;
.title { text-overflow: ellipsis;
font-size: 14px; width: 100%;
color: #666; overflow-x: hidden;
} text-align: center;
}
.text {
margin-top: 10px; .icon {
font-size: 16px; height: 100rpx;
font-weight: 500; width: 100rpx;
color: #666; display: block;
overflow-wrap: anywhere; border-radius: 20rpx;
} }
.status-danger { .pcs-tags-scroll {
color: #FC6B69; background: #fff;
} padding: 0 20rpx 20rpx;
white-space: nowrap;
.status-running { }
color: #05AEA3;
} .pcs-tags-row {
display: inline-flex;
} gap: 16rpx;
}
::v-deep {
.info-grid { .pcs-tag-item {
.uni-grid-item { flex: 0 0 auto;
height: 80px !important; padding: 8rpx 22rpx;
border-radius: 999rpx;
.grid-item-box { border: 1px solid #dcdfe6;
padding: 0; color: #606266;
} font-size: 24rpx;
} line-height: 1.4;
} background: #fff;
}
.uni-collapse-item__wrap {
background-color: #eee; .pcs-tag-item.active {
} color: #fff;
background: #007aff;
.running { border-color: #007aff;
.uni-collapse-item__title-text { }
color: #05AEA3; </style>
}
.title-row {
color: #05AEA3;
}
}
.danger {
.uni-collapse-item__title-text {
color: #FC6B69;
}
.title-row {
color: #FC6B69;
}
}
.close {
.uni-collapse-item__title-text {
color: #666666;
}
.title-row {
color: #666666;
}
}
// 支路样式
.pcs-branch-group {
.uni-group__title {
background-color: #959595;
.uni-group__title-text {
color: #fff;
}
}
.uni-group__content {
padding: 0;
}
&.uni-group--card:last-child {
margin-bottom: 25px;
}
}
}
</style>

242
pages/work/yl/index.vue Normal file
View 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: '&#8451;'
}, {
name: '回水温度',
attr: 'hsTemp',
unit: '&#8451;'
}, {
name: '供水压力',
attr: 'gsPressure',
unit: 'MPa'
}, {
name: '回水压力',
attr: 'hsPressure',
unit: 'MPa'
}, {
name: '冷源水温度',
attr: 'lysTemp',
unit: '&#8451;'
}, {
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>

View File

@ -0,0 +1,87 @@
@font-face {
font-family: "iconfont";
/* Project id 4993552 */
src: url('@/static/font_ems/iconfont.woff2?t=1754546965003') format('woff2'),
url('@/static/font_ems/iconfont.woff?t=1754546965003') format('woff'),
url('@/static/font_ems/iconfont.ttf?t=1754546965003') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-a-dianchicunengliangkuai:before {
content: "\e7a1";
}
.icon-dianbiao:before {
content: "\eacb";
}
.icon-batterypx:before {
content: "\e610";
}
.icon-dianbiao_shiti:before {
content: "\eca1";
}
.icon-bianyaqiyunhangpingjia:before {
content: "\e600";
}
.icon-dianbiao1:before {
content: "\e602";
}
.icon-pcs:before {
content: "\e611";
}
.icon-dianbiao2:before {
content: "\e688";
}
.icon-ziyuan:before {
content: "\e866";
}
.icon-pcs1:before {
content: "\e601";
}
.icon-gongneng-diandongji:before {
content: "\e65a";
}
.icon-dianbiao3:before {
content: "\e6a7";
}
.icon-weibiaoti-1-02-02:before {
content: "\e612";
}
.icon-dianbiao4:before {
content: "\e625";
}
.icon-dantidianchi:before {
content: "\e76b";
}
.icon-BMS:before {
content: "\e63e";
}
.icon-BMStongyong:before {
content: "\e80c";
}
.icon-PCS:before {
content: "\e603";
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,135 @@
{
"id": "4993552",
"name": "EMS",
"font_family": "iconfont",
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "43871958",
"name": "电池簇、能量块",
"font_class": "a-dianchicunengliangkuai",
"unicode": "e7a1",
"unicode_decimal": 59297
},
{
"icon_id": "5387412",
"name": "电表",
"font_class": "dianbiao",
"unicode": "eacb",
"unicode_decimal": 60107
},
{
"icon_id": "6141230",
"name": "battery 32 px.1",
"font_class": "batterypx",
"unicode": "e610",
"unicode_decimal": 58896
},
{
"icon_id": "6775643",
"name": "电表_实体",
"font_class": "dianbiao_shiti",
"unicode": "eca1",
"unicode_decimal": 60577
},
{
"icon_id": "6826531",
"name": "变压器运行评价",
"font_class": "bianyaqiyunhangpingjia",
"unicode": "e600",
"unicode_decimal": 58880
},
{
"icon_id": "7045021",
"name": "电表",
"font_class": "dianbiao1",
"unicode": "e602",
"unicode_decimal": 58882
},
{
"icon_id": "8057318",
"name": "pcs",
"font_class": "pcs",
"unicode": "e611",
"unicode_decimal": 58897
},
{
"icon_id": "8441718",
"name": "电表",
"font_class": "dianbiao2",
"unicode": "e688",
"unicode_decimal": 59016
},
{
"icon_id": "12293731",
"name": "资源 2",
"font_class": "ziyuan",
"unicode": "e866",
"unicode_decimal": 59494
},
{
"icon_id": "12718310",
"name": "pcs",
"font_class": "pcs1",
"unicode": "e601",
"unicode_decimal": 58881
},
{
"icon_id": "22678712",
"name": "功能-电动机",
"font_class": "gongneng-diandongji",
"unicode": "e65a",
"unicode_decimal": 58970
},
{
"icon_id": "23420639",
"name": "电表",
"font_class": "dianbiao3",
"unicode": "e6a7",
"unicode_decimal": 59047
},
{
"icon_id": "31086873",
"name": "PCS",
"font_class": "weibiaoti-1-02-02",
"unicode": "e612",
"unicode_decimal": 58898
},
{
"icon_id": "38212288",
"name": "电表",
"font_class": "dianbiao4",
"unicode": "e625",
"unicode_decimal": 58917
},
{
"icon_id": "40121596",
"name": "单体电池",
"font_class": "dantidianchi",
"unicode": "e76b",
"unicode_decimal": 59243
},
{
"icon_id": "42346006",
"name": "BMS-copy",
"font_class": "BMS",
"unicode": "e63e",
"unicode_decimal": 58942
},
{
"icon_id": "43101168",
"name": "BMS通用",
"font_class": "BMStongyong",
"unicode": "e80c",
"unicode_decimal": 59404
},
{
"icon_id": "43866831",
"name": "PCS-copy",
"font_class": "PCS",
"unicode": "e603",
"unicode_decimal": 58883
}
]
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

BIN
static/logo-trans.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

File diff suppressed because one or more lines are too long

View File

@ -88,7 +88,15 @@
} }
} }
} }
.status-bar{
background: #fff;
width: 100%;
height: var(--status-bar-height);
position: fixed;
top:0;
left: 0;
z-index:99;
}
// 暂无数据通用样式 // 暂无数据通用样式
@ -97,6 +105,255 @@
text-align: center; text-align: center;
line-height: 100px; line-height: 100px;
height: 100px; height: 100px;
background-color: #fff; font-size: 30rpx;
font-size: 18px; background-color: transparent;
}
// 九宫格
.grid-item-box {
flex: 1;
// position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20rpx;
background-color: #fff;
.title {
font-size: 26rpx;
color: #666;
}
.text {
margin-top: 20rpx;
font-size: 32rpx;
font-weight: 500;
color: #666;
overflow-wrap: anywhere;
}
}
.flex-container{
display: flex;
.flex-lists{
flex:1;
}
}
// 设备详情页面 状态公共样式
.common-collapse-item{
.content{
background: linear-gradient(to bottom, #22bb5873, #45db7a26);
padding: 1rpx 0 1rpx 0;
}
// 标题
.title-wrapper{
// 设备状态栏
padding:20rpx 30rpx;
font-size: 28rpx;
line-height: 30rpx;
font-weight: 700;
color: #000000;
.top{
.status{
display: inline-block;
vertical-align: middle;
color:#fff;
padding:0 10rpx;
margin-right: 10rpx;
font-size: 22rpx;
line-height: 38rpx;
border-radius: 10rpx;
}
.name{
display: inline-block;
vertical-align: middle;
}
}
}
// 设备状态卡片
.status-card-group{
.uni-group__content{
padding-top:0;
padding-bottom:0;
}
// 设备状态九宫格
.grid-item-box{
background-color: transparent;
.title{
color:#333;
}
.text{
color:#000;
font-weight: bolder;
&.work-status-color{
color:#000;
}
}
}
}
// 设备数据卡片
.data-card-group{
.uni-group__content{
padding-top:0;
padding-bottom:0;
}
// 数据列表
.data-row{
font-size: 26rpx;
line-height: 36rpx;
color: #000;
padding:24rpx 0;
&:not(:last-child){
border-bottom: 1px solid #ebedf0;
}
.title{
color:#333;
text-align: left;
}
.value{
text-align: right;
}
}
}
// 子设备表格卡片
.child-card-group{
.child-table{
.uni-table-th{
color:#333;
font-size: 26rpx;
}
.uni-table-td{
color:#000;
font-size: 26rpx;
}
.table--border{
border-color:#ebedf0;
}
}
}
// 支路卡片
.branch-card-group{
.uni-group__title {
background-color: #959595;
height: 70rpx;
.uni-group__title-text {
color: #fff;
font-size:26rpx;
line-height: 30rpx;
}
}
.uni-group__content {
padding: 0;
.title{
color:#333;
}
.text{
color:#000;
font-weight: normal;
}
}
&.uni-group--card:last-child {
margin-bottom: 50rpx;
}
}
}
//运行中
.running-collapse-item{
// 标题
.title-wrapper{
.top{
.status{
background-color: #30be95;
}
}
}
.content{
background-color:rgba(69,219,122,0.15);
}
// 状态九宫格
.status-card-group{
.grid-item-box{
.text{
&.work-status-color{
color:#30be95;
}
}
}
}
//支路设备
.branch-card-group{
.uni-group__title {
background-color: #30be95;
}
}
}
//故障
.warning-collapse-item{
// 标题
.title-wrapper{
.top{
.status{
background-color: #ed7876;
}
}
}
.content{
background: rgba(245,96,78,0.15);
}
// 状态九宫格
.status-card-group{
.grid-item-box{
.text{
&.work-status-color{
color:#ed7876;
}
}
}
}
//支路设备
.branch-card-group{
.uni-group__title {
background-color: #ed7876;
}
}
}
// 停机
.timing-collapse-item{
// 标题
.title-wrapper{
.top{
.status{
background-color: #000;
}
}
}
.content{
background: rgba(140,140,140,0.15);
}
// 状态九宫格
.status-card-group{
.grid-item-box{
.text{
&.work-status-color{
color:#000;
}
}
}
}
//支路设备
.branch-card-group{
.uni-group__title {
background-color: #000;
}
}
} }

View File

@ -3,4 +3,5 @@
// color-ui // color-ui
@import "@/static/scss/colorui.css"; @import "@/static/scss/colorui.css";
// iconfont // iconfont
@import "@/static/font/iconfont.css"; @import "@/static/font_ems/iconfont.css";
@import "@/static/font/iconfont.css";

View File

@ -1,9 +1,11 @@
const getters = { const getters = {
token: state => state.user.token, token: state => state.user.token,
avatar: state => state.user.avatar, avatar: state => state.user.avatar,
id: state => state.user.id, id: state => state.user.id,
name: state => state.user.name, name: state => state.user.name,
roles: state => state.user.roles, roles: state => state.user.roles,
permissions: state => state.user.permissions permissions: state => state.user.permissions,
belongSite: state => state.user.belongSite,
currentSiteId: state => state.user.currentSiteId
} }
export default getters export default getters

View File

@ -1,14 +1,33 @@
const ems = { const ems = {
state: { state: {
workStatusOptions: { CLUSTERWorkStatusOptions: {
'0': '正常', '0': '静置',
'1': '异常', '1': '充电',
'2': '停止' '2': '放电',
}, //工作状态 '3': '待机',
'5': '运行',
'9': "故障"
}, //电池簇工作状态
PCSWorkStatusOptions: {
'0': '运行',
'1': '停机',
'2': '故障',
'3': '待机',
'4': '充电',
'5': '放电'
}, //PCS工作状态
STACKWorkStatusOptions: {
"0": "静置",
"1": "充电",
"2": "放电",
"3": "浮充",
'4': '待机',
'5': '运行',
'9': "故障"
}, //STACKBMS总览工作状态
deviceStatusOptions: { deviceStatusOptions: {
'0': '线', '0': '线',
'1': '线', '1': '线'
'2': '维修中'
}, //设备状态 }, //设备状态
gridStatusOptions: { gridStatusOptions: {
'0': '并网', '0': '并网',
@ -49,9 +68,9 @@ const ems = {
'RTU': 'RTU' 'RTU': 'RTU'
}, //设备类型 }, //设备类型
ticketStatusOptions: { ticketStatusOptions: {
0: '待处理', 1: '待处理',
1: '处理', 2: '处理',
2: '处理' 3: '处理'
}, //工单处理状态 }, //工单处理状态
strategyStatusOptions: { strategyStatusOptions: {
'0': '未启用', '0': '未启用',
@ -62,8 +81,10 @@ const ems = {
}, //策略状态 }, //策略状态
chargeStatusOptions: { chargeStatusOptions: {
'1': '充电', '1': '充电',
'2': '待机' '2': '待机',
'3': '放电'
}, //冲放状态 }, //冲放状态
} }
} }
export default ems export default ems

109
store/modules/site.js Normal file
View 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

View File

@ -1,110 +1,141 @@
import config from '@/config' import config from '@/config'
import storage from '@/utils/storage' import storage from '@/utils/storage'
import constant from '@/utils/constant' import constant from '@/utils/constant'
import { isHttp, isEmpty } from "@/utils/validate" import {
import { login, logout, getInfo } from '@/api/login' isHttp,
import { getToken, setToken, removeToken } from '@/utils/auth' isEmpty
import defAva from '@/static/images/profile.jpg' } from "@/utils/validate"
import {
const baseUrl = config.baseUrl login,
logout,
const user = { getInfo
state: { } from '@/api/login'
token: getToken(), import {
id: storage.get(constant.id), getToken,
name: storage.get(constant.name), setToken,
avatar: storage.get(constant.avatar), removeToken
roles: storage.get(constant.roles), } from '@/utils/auth'
permissions: storage.get(constant.permissions) import defAva from '@/static/images/profile.jpg'
},
const baseUrl = config.baseUrl
mutations: {
SET_TOKEN: (state, token) => { const user = {
state.token = token state: {
}, token: getToken(),
SET_ID: (state, id) => { id: storage.get(constant.id),
state.id = id name: storage.get(constant.name),
storage.set(constant.id, id) avatar: storage.get(constant.avatar),
}, roles: storage.get(constant.roles),
SET_NAME: (state, name) => { permissions: storage.get(constant.permissions),
state.name = name belongSite: storage.get(constant.belongSite),
storage.set(constant.name, name) currentSiteId: storage.get(constant.currentSiteId)
}, },
SET_AVATAR: (state, avatar) => {
state.avatar = avatar mutations: {
storage.set(constant.avatar, avatar) SET_TOKEN: (state, token) => {
}, state.token = token
SET_ROLES: (state, roles) => { },
state.roles = roles SET_ID: (state, id) => {
storage.set(constant.roles, roles) state.id = id
}, storage.set(constant.id, id)
SET_PERMISSIONS: (state, permissions) => { },
state.permissions = permissions SET_NAME: (state, name) => {
storage.set(constant.permissions, permissions) state.name = name
} storage.set(constant.name, name)
}, },
SET_AVATAR: (state, avatar) => {
actions: { state.avatar = avatar
// 登录 storage.set(constant.avatar, avatar)
Login({ commit }, userInfo) { },
const username = userInfo.username.trim() SET_ROLES: (state, roles) => {
const password = userInfo.password state.roles = roles
const code = userInfo.code storage.set(constant.roles, roles)
const uuid = userInfo.uuid },
return new Promise((resolve, reject) => { SET_PERMISSIONS: (state, permissions) => {
login(username, password, code, uuid).then(res => { state.permissions = permissions
setToken(res.token) storage.set(constant.permissions, permissions)
commit('SET_TOKEN', res.token) },
resolve() SET_BELONGSITE: (state, belongSite = []) => {
}).catch(error => { state.belongSite = belongSite || []
reject(error) storage.set(constant.belongSite, belongSite || [])
}) },
}) SET_CURRENTSITEID: (state, currentSiteId = '') => {
}, state.currentSiteId = currentSiteId || ''
storage.set(constant.currentSiteId, currentSiteId || '')
// 获取用户信息 }
GetInfo({ commit, state }) { },
return new Promise((resolve, reject) => {
getInfo().then(res => { actions: {
const user = res.user // 登录
let avatar = user.avatar || "" Login({
if (!isHttp(avatar)) { commit
avatar = (isEmpty(avatar)) ? defAva : baseUrl + avatar }, userInfo) {
} const username = userInfo.username.trim()
const userid = (isEmpty(user) || isEmpty(user.userId)) ? "" : user.userId const password = userInfo.password
const username = (isEmpty(user) || isEmpty(user.userName)) ? "" : user.userName const code = userInfo.code
if (res.roles && res.roles.length > 0) { const uuid = userInfo.uuid
commit('SET_ROLES', res.roles) return new Promise((resolve, reject) => {
commit('SET_PERMISSIONS', res.permissions) login(username, password, code, uuid).then(res => {
} else { setToken(res.token)
commit('SET_ROLES', ['ROLE_DEFAULT']) commit('SET_TOKEN', res.token)
} resolve()
commit('SET_ID', userid) }).catch(error => {
commit('SET_NAME', username) reject(error)
commit('SET_AVATAR', avatar) })
resolve(res) })
}).catch(error => { },
reject(error)
}) // 获取用户信息
}) GetInfo({
}, commit,
state
// 退出系统 }) {
LogOut({ commit, state }) { return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => { getInfo().then(res => {
logout(state.token).then(() => { const user = res.user
commit('SET_TOKEN', '') const belongSite = user?.belongSite ? JSON.parse(user?.belongSite) || [] : []
commit('SET_ROLES', []) let avatar = user.avatar || ""
commit('SET_PERMISSIONS', []) if (!isHttp(avatar)) {
removeToken() avatar = (isEmpty(avatar)) ? defAva : baseUrl + avatar
storage.clean() }
resolve() const userid = (isEmpty(user) || isEmpty(user.userId)) ? "" : user.userId
}).catch(error => { const username = (isEmpty(user) || isEmpty(user.userName)) ? "" : user.userName
reject(error) if (res.roles && res.roles.length > 0) {
}) commit('SET_ROLES', res.roles)
}) commit('SET_PERMISSIONS', res.permissions)
} } else {
} commit('SET_ROLES', ['ROLE_DEFAULT'])
} }
commit('SET_ID', userid)
commit('SET_NAME', username)
commit('SET_AVATAR', avatar)
commit('SET_BELONGSITE', belongSite)
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 退出系统
LogOut({
commit,
state
}) {
return new Promise((resolve, reject) => {
logout(state.token).then(() => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
commit('SET_PERMISSIONS', [])
removeToken()
storage.clean()
resolve()
}).catch(error => {
reject(error)
})
})
}
}
}
export default user export default user

View File

@ -636,12 +636,20 @@ export default {
}, },
}, },
methods: { methods: {
beforeInit(){ beforeInit(){
this.mixinDatacomErrorMessage = null; this.mixinDatacomErrorMessage = null;
if (typeof this.chartData === 'object' && this.chartData != null && this.chartData.series !== undefined && this.chartData.series.length > 0) { console.log('[map-debug] beforeInit', {
//拷贝一下chartData为了opts变更后统一数据来源 echarts: this.echarts,
this.drawData = deepCloneAssign({}, this.chartData); type: this.type,
this.mixinDatacomLoading = false; hasEopts: !!this.eopts,
eoptsMapName: this.eopts && this.eopts.mapName,
hasGeo: !!(this.eopts && this.eopts.mapGeoJSON),
chartSeriesLen: this.chartData && this.chartData.series ? this.chartData.series.length : -1
});
if (typeof this.chartData === 'object' && this.chartData != null && this.chartData.series !== undefined && this.chartData.series.length > 0) {
//拷贝一下chartData为了opts变更后统一数据来源
this.drawData = deepCloneAssign({}, this.chartData);
this.mixinDatacomLoading = false;
this.showchart = true; this.showchart = true;
this.checkData(this.chartData); this.checkData(this.chartData);
}else if(this.localdata.length>0){ }else if(this.localdata.length>0){
@ -782,11 +790,19 @@ export default {
this.beforeInit(); this.beforeInit();
} }
}, },
checkData(anyData) { checkData(anyData) {
let cid = this.cid let cid = this.cid
//复位opts或eopts console.log('[map-debug] checkData', {
if(this.echarts === true){ cid,
cfe.option[cid] = deepCloneAssign({}, this.eopts); echarts: this.echarts,
type: this.type,
eoptsMapName: this.eopts && this.eopts.mapName,
hasGeo: !!(this.eopts && this.eopts.mapGeoJSON),
dataSeriesLen: anyData && anyData.series ? anyData.series.length : -1
});
//复位opts或eopts
if(this.echarts === true){
cfe.option[cid] = deepCloneAssign({}, this.eopts);
cfe.option[cid].id = cid; cfe.option[cid].id = cid;
cfe.option[cid].type = this.type; cfe.option[cid].type = this.type;
}else{ }else{
@ -908,16 +924,22 @@ export default {
cfu.option[cid].tapLegend = this.tapLegend; cfu.option[cid].tapLegend = this.tapLegend;
} }
//如果是H5或者App端采用renderjs渲染图表 //如果是H5或者App端采用renderjs渲染图表
if (this.inH5 || this.inApp) { if (this.inH5 || this.inApp) {
if (this.echarts == true) { if (this.echarts == true) {
cfe.option[cid].ontap = this.ontap; cfe.option[cid].ontap = this.ontap;
cfe.option[cid].onmouse = this.openmouse; cfe.option[cid].onmouse = this.openmouse;
cfe.option[cid].tooltipShow = this.tooltipShow; cfe.option[cid].tooltipShow = this.tooltipShow;
cfe.option[cid].tooltipFormat = this.tooltipFormat; cfe.option[cid].tooltipFormat = this.tooltipFormat;
cfe.option[cid].tooltipCustom = this.tooltipCustom; cfe.option[cid].tooltipCustom = this.tooltipCustom;
cfe.option[cid].lastDrawTime = this.lastDrawTime; cfe.option[cid].lastDrawTime = this.lastDrawTime;
this.echartsOpts = deepCloneAssign({}, cfe.option[cid]); console.log('[map-debug] set echartsOpts', {
} else { cid,
type: cfe.option[cid].type,
mapName: cfe.option[cid].mapName,
hasGeo: !!cfe.option[cid].mapGeoJSON
});
this.echartsOpts = deepCloneAssign({}, cfe.option[cid]);
} else {
cfu.option[cid].rotateLock = cfu.option[cid].rotate; cfu.option[cid].rotateLock = cfu.option[cid].rotate;
this.uchartsOpts = deepCloneAssign({}, cfu.option[cid]); this.uchartsOpts = deepCloneAssign({}, cfu.option[cid]);
} }
@ -1272,24 +1294,25 @@ export default {
}, },
methods: { methods: {
//==============以下是ECharts的方法==================== //==============以下是ECharts的方法====================
ecinit(newVal, oldVal, owner, instance){ ecinit(newVal, oldVal, owner, instance){
let cid = JSON.stringify(newVal.id) let cid = JSON.stringify(newVal.id || newVal.canvasId || (owner && owner.cid) || (instance && instance.cid))
this.rid = cid console.log('[map-debug] ecinit', { cid, type: newVal.type, hasMapName: !!newVal.mapName, hasGeo: !!newVal.mapGeoJSON });
that[cid] = this.$ownerInstance || instance this.rid = cid
let eopts = JSON.parse(JSON.stringify(newVal)) that[cid] = this.$ownerInstance || instance
let type = eopts.type; let eopts = JSON.parse(JSON.stringify(newVal))
let type = eopts.type;
//载入并覆盖默认配置 //载入并覆盖默认配置
if (type && cfe.type.includes(type)) { if (type && cfe.type.includes(type)) {
cfe.option[cid] = rddeepCloneAssign({}, cfe[type], eopts); cfe.option[cid] = rddeepCloneAssign({}, cfe[type], eopts);
}else{ }else{
cfe.option[cid] = rddeepCloneAssign({}, eopts); cfe.option[cid] = rddeepCloneAssign({}, eopts);
} }
let newData = eopts.chartData; let newData = eopts.chartData;
if(newData){ if(newData && !eopts.skipChartData){
//挂载categories和series //挂载categories和series
if(cfe.option[cid].xAxis && cfe.option[cid].xAxis.type && cfe.option[cid].xAxis.type === 'category'){ if(cfe.option[cid].xAxis && cfe.option[cid].xAxis.type && cfe.option[cid].xAxis.type === 'category'){
cfe.option[cid].xAxis.data = newData.categories cfe.option[cid].xAxis.data = newData.categories
} }
if(cfe.option[cid].yAxis && cfe.option[cid].yAxis.type && cfe.option[cid].yAxis.type === 'category'){ if(cfe.option[cid].yAxis && cfe.option[cid].yAxis.type && cfe.option[cid].yAxis.type === 'category'){
cfe.option[cid].yAxis.data = newData.categories cfe.option[cid].yAxis.data = newData.categories
} }
@ -1297,14 +1320,26 @@ export default {
for (var i = 0; i < newData.series.length; i++) { for (var i = 0; i < newData.series.length; i++) {
cfe.option[cid].seriesTemplate = cfe.option[cid].seriesTemplate ? cfe.option[cid].seriesTemplate : {} cfe.option[cid].seriesTemplate = cfe.option[cid].seriesTemplate ? cfe.option[cid].seriesTemplate : {}
let Template = rddeepCloneAssign({},cfe.option[cid].seriesTemplate,newData.series[i]) let Template = rddeepCloneAssign({},cfe.option[cid].seriesTemplate,newData.series[i])
cfe.option[cid].series.push(Template) cfe.option[cid].series.push(Template)
} }
} }
if (typeof window.echarts === 'object') { if (typeof window.echarts === 'object' && eopts.mapName && eopts.mapGeoJSON) {
this.newEChart() try {
}else{ if (!window.echarts.getMap(eopts.mapName)) {
const script = document.createElement('script') window.echarts.registerMap(eopts.mapName, eopts.mapGeoJSON);
}
} catch (e) {
console.log('[map-debug] registerMap error', e);
}
}
if (typeof window.echarts === 'object') {
console.log('[map-debug] echarts exists, init');
this.newEChart()
}else{
console.log('[map-debug] echarts not found, load script');
const script = document.createElement('script')
// #ifdef APP-VUE // #ifdef APP-VUE
script.src = './uni_modules/qiun-data-charts/static/app-plus/echarts.min.js' script.src = './uni_modules/qiun-data-charts/static/app-plus/echarts.min.js'
// #endif // #endif
@ -1322,10 +1357,21 @@ export default {
cfe.instance[this.rid].resize() cfe.instance[this.rid].resize()
} }
}, },
newEChart(){ newEChart(){
let cid = this.rid let cid = this.rid
if(cfe.instance[cid] === undefined){ console.log('[map-debug] newEChart', { cid });
cfe.instance[cid] = echarts.init(that[cid].$el.children[0]) if (cfe.option[cid] && cfe.option[cid].mapName && cfe.option[cid].mapGeoJSON) {
try {
if (!echarts.getMap(cfe.option[cid].mapName)) {
echarts.registerMap(cfe.option[cid].mapName, cfe.option[cid].mapGeoJSON);
}
} catch (e) {
console.log('[map-debug] registerMap error in newEChart', e);
}
}
if(cfe.instance[cid] === undefined){
cfe.instance[cid] = echarts.init(that[cid].$el.children[0])
console.log('[map-debug] echarts init instance created');
//ontap开启后才触发click事件 //ontap开启后才触发click事件
if(cfe.option[cid].ontap === true){ if(cfe.option[cid].ontap === true){
cfe.instance[cid].on('click', resdata => { cfe.instance[cid].on('click', resdata => {
@ -1339,14 +1385,15 @@ export default {
that[cid].callMethod('emitMsg',{name:"getHighlight", params:{type:"highlight", res:resdata, id:cid}}) that[cid].callMethod('emitMsg',{name:"getHighlight", params:{type:"highlight", res:resdata, id:cid}})
}) })
} }
this.updataEChart(cid,cfe.option[cid]) this.updataEChart(cid,cfe.option[cid])
}else{ }else{
this.updataEChart(cid,cfe.option[cid]) this.updataEChart(cid,cfe.option[cid])
} }
}, },
updataEChart(cid,option){ updataEChart(cid,option){
//替换option内format属性为formatter的预定义方法 console.log('[map-debug] updateEChart', { cid, hasSeries: !!option.series, seriesLen: option.series ? option.series.length : 0 });
option = rdformatterAssign(option,cfe.formatter) //替换option内format属性为formatter的预定义方法
option = rdformatterAssign(option,cfe.formatter)
if(option.tooltip){ if(option.tooltip){
option.tooltip.show = option.tooltipShow?true:false; option.tooltip.show = option.tooltipShow?true:false;
option.tooltip.position = this.tooltipPosition() option.tooltip.position = this.tooltipPosition()

View File

@ -1,421 +1,424 @@
class Calendar { class Calendar {
constructor({ constructor({
selected, selected,
startDate, startDate,
endDate, endDate,
range, range,
} = {}) { } = {}) {
// 当前日期 // 当前日期
this.date = this.getDateObj(new Date()) // 当前初入日期 this.date = this.getDateObj(new Date()) // 当前初入日期
// 打点信息 // 打点信息
this.selected = selected || []; this.selected = selected || [];
// 起始时间 // 起始时间
this.startDate = startDate this.startDate = startDate
// 终止时间 // 终止时间
this.endDate = endDate this.endDate = endDate
// 是否范围选择 // 是否范围选择
this.range = range this.range = range
// 多选状态 // 多选状态
this.cleanMultipleStatus() this.cleanMultipleStatus()
// 每周日期 // 每周日期
this.weeks = {} this.weeks = {}
this.lastHover = false this.lastHover = false
} }
/** /**
* 设置日期 * 设置日期
* @param {Object} date * @param {Object} date
*/ */
setDate(date) { setDate(date) {
const selectDate = this.getDateObj(date) const selectDate = this.getDateObj(date)
this.getWeeks(selectDate.fullDate) this.getWeeks(selectDate.fullDate)
} }
/** /**
* 清理多选状态 * 清理多选状态
*/ */
cleanMultipleStatus() { cleanMultipleStatus() {
this.multipleStatus = { this.multipleStatus = {
before: '', before: '',
after: '', after: '',
data: [] data: []
} }
} }
setStartDate(startDate) { setStartDate(startDate) {
this.startDate = startDate this.startDate = startDate
} }
setEndDate(endDate) { setEndDate(endDate) {
this.endDate = endDate this.endDate = endDate
} }
getPreMonthObj(date) { getPreMonthObj(date) {
date = fixIosDateFormat(date) date = fixIosDateFormat(date)
date = new Date(date) date = new Date(date)
const oldMonth = date.getMonth() const oldMonth = date.getMonth()
date.setMonth(oldMonth - 1) date.setMonth(oldMonth - 1)
const newMonth = date.getMonth() const newMonth = date.getMonth()
if (oldMonth !== 0 && newMonth - oldMonth === 0) { if (oldMonth !== 0 && newMonth - oldMonth === 0) {
date.setMonth(newMonth - 1) date.setMonth(newMonth - 1)
} }
return this.getDateObj(date) return this.getDateObj(date)
} }
getNextMonthObj(date) { getNextMonthObj(date) {
date = fixIosDateFormat(date) date = fixIosDateFormat(date)
date = new Date(date) date = new Date(date)
const oldMonth = date.getMonth() const oldMonth = date.getMonth()
date.setMonth(oldMonth + 1) date.setMonth(oldMonth + 1)
const newMonth = date.getMonth() const newMonth = date.getMonth()
if (newMonth - oldMonth > 1) { if (newMonth - oldMonth > 1) {
date.setMonth(newMonth - 1) date.setMonth(newMonth - 1)
} }
return this.getDateObj(date) return this.getDateObj(date)
} }
/** /**
* 获取指定格式Date对象 * 获取指定格式Date对象
*/ */
getDateObj(date) { getDateObj(date) {
date = fixIosDateFormat(date) date = fixIosDateFormat(date)
date = new Date(date) date = new Date(date)
return { return {
fullDate: getDate(date), fullDate: getDate(date),
year: date.getFullYear(), year: date.getFullYear(),
month: addZero(date.getMonth() + 1), month: addZero(date.getMonth() + 1),
date: addZero(date.getDate()), date: addZero(date.getDate()),
day: date.getDay() day: date.getDay()
} }
} }
/** /**
* 获取上一个月日期集合 * 获取上一个月日期集合
*/ */
getPreMonthDays(amount, dateObj) { getPreMonthDays(amount, dateObj) {
const result = [] const result = []
for (let i = amount - 1; i >= 0; i--) { for (let i = amount - 1; i >= 0; i--) {
const month = dateObj.month - 1 const month = dateObj.month - 1
result.push({ result.push({
date: new Date(dateObj.year, month, -i).getDate(), date: new Date(dateObj.year, month, -i).getDate(),
month, month,
disable: true disable: true
}) })
} }
return result return result
} }
/** /**
* 获取本月日期集合 * 获取本月日期集合
*/ */
getCurrentMonthDays(amount, dateObj) { getCurrentMonthDays(amount, dateObj) {
const result = [] const result = []
const fullDate = this.date.fullDate const fullDate = this.date.fullDate
for (let i = 1; i <= amount; i++) { for (let i = 1; i <= amount; i++) {
const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}` const currentDate = `${dateObj.year}-${dateObj.month}-${addZero(i)}`
const isToday = fullDate === currentDate const isToday = fullDate === currentDate
// 获取打点信息 // 获取打点信息
const info = this.selected && this.selected.find((item) => { const info = this.selected && this.selected.find((item) => {
if (this.dateEqual(currentDate, item.date)) { if (this.dateEqual(currentDate, item.date)) {
return item return item
} }
}) })
// 日期禁用 // 日期禁用
let disableBefore = true let disableBefore = true
let disableAfter = true let disableAfter = true
if (this.startDate) { if (this.startDate) {
disableBefore = dateCompare(this.startDate, currentDate) disableBefore = dateCompare(this.startDate, currentDate)
} }
if (this.endDate) { if (this.endDate) {
disableAfter = dateCompare(currentDate, this.endDate) disableAfter = dateCompare(currentDate, this.endDate)
} }
let multiples = this.multipleStatus.data let multiples = this.multipleStatus.data
let multiplesStatus = -1 let multiplesStatus = -1
if (this.range && multiples) { if (this.range && multiples) {
multiplesStatus = multiples.findIndex((item) => { multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, currentDate) return this.dateEqual(item, currentDate)
}) })
} }
const checked = multiplesStatus !== -1 const checked = multiplesStatus !== -1
result.push({ result.push({
fullDate: currentDate, fullDate: currentDate,
year: dateObj.year, year: dateObj.year,
date: i, date: i,
multiple: this.range ? checked : false, multiple: this.range ? checked : false,
beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this.multipleStatus.after), beforeMultiple: this.isLogicBefore(currentDate, this.multipleStatus.before, this
afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this.multipleStatus.after), .multipleStatus.after),
month: dateObj.month, afterMultiple: this.isLogicAfter(currentDate, this.multipleStatus.before, this
disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !dateCompare( .multipleStatus.after),
currentDate, this.endDate)), month: dateObj.month,
isToday, disable: (this.startDate && !dateCompare(this.startDate, currentDate)) || (this.endDate && !
userChecked: false, dateCompare(
extraInfo: info currentDate, this.endDate)),
}) isToday,
} userChecked: false,
return result extraInfo: info
} })
/** }
* 获取下一个月日期集合 return result
*/ }
_getNextMonthDays(amount, dateObj) { /**
const result = [] * 获取下一个月日期集合
const month = dateObj.month + 1 */
for (let i = 1; i <= amount; i++) { _getNextMonthDays(amount, dateObj) {
result.push({ const result = []
date: i, const month = dateObj.month + 1
month, for (let i = 1; i <= amount; i++) {
disable: true result.push({
}) date: i,
} month,
return result disable: true
} })
}
/** return result
* 获取当前日期详情 }
* @param {Object} date
*/ /**
getInfo(date) { * 获取当前日期详情
if (!date) { * @param {Object} date
date = new Date() */
} getInfo(date) {
const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate) if (!date) {
return res ? res : this.getDateObj(date) date = new Date()
} }
const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
/** return res ? res : this.getDateObj(date)
* 比较时间是否相等 }
*/
dateEqual(before, after) { /**
before = new Date(fixIosDateFormat(before)) * 比较时间是否相等
after = new Date(fixIosDateFormat(after)) */
return before.valueOf() === after.valueOf() dateEqual(before, after) {
} before = new Date(fixIosDateFormat(before))
after = new Date(fixIosDateFormat(after))
/** return before.valueOf() === after.valueOf()
* 比较真实起始日期 }
*/
/**
isLogicBefore(currentDate, before, after) { * 比较真实起始日期
let logicBefore = before */
if (before && after) {
logicBefore = dateCompare(before, after) ? before : after isLogicBefore(currentDate, before, after) {
} let logicBefore = before
return this.dateEqual(logicBefore, currentDate) if (before && after) {
} logicBefore = dateCompare(before, after) ? before : after
}
isLogicAfter(currentDate, before, after) { return this.dateEqual(logicBefore, currentDate)
let logicAfter = after }
if (before && after) {
logicAfter = dateCompare(before, after) ? after : before isLogicAfter(currentDate, before, after) {
} let logicAfter = after
return this.dateEqual(logicAfter, currentDate) if (before && after) {
} logicAfter = dateCompare(before, after) ? after : before
}
/** return this.dateEqual(logicAfter, currentDate)
* 获取日期范围内所有日期 }
* @param {Object} begin
* @param {Object} end /**
*/ * 获取日期范围内所有日期
geDateAll(begin, end) { * @param {Object} begin
var arr = [] * @param {Object} end
var ab = begin.split('-') */
var ae = end.split('-') geDateAll(begin, end) {
var db = new Date() var arr = []
db.setFullYear(ab[0], ab[1] - 1, ab[2]) var ab = begin.split('-')
var de = new Date() var ae = end.split('-')
de.setFullYear(ae[0], ae[1] - 1, ae[2]) var db = new Date()
var unixDb = db.getTime() - 24 * 60 * 60 * 1000 db.setFullYear(ab[0], ab[1] - 1, ab[2])
var unixDe = de.getTime() - 24 * 60 * 60 * 1000 var de = new Date()
for (var k = unixDb; k <= unixDe;) { de.setFullYear(ae[0], ae[1] - 1, ae[2])
k = k + 24 * 60 * 60 * 1000 var unixDb = db.getTime() - 24 * 60 * 60 * 1000
arr.push(this.getDateObj(new Date(parseInt(k))).fullDate) var unixDe = de.getTime() - 24 * 60 * 60 * 1000
} for (var k = unixDb; k <= unixDe;) {
return arr k = k + 24 * 60 * 60 * 1000
} arr.push(this.getDateObj(new Date(parseInt(k))).fullDate)
}
/** return arr
* 获取多选状态 }
*/
setMultiple(fullDate) { /**
if (!this.range) return * 获取多选状态
*/
let { setMultiple(fullDate) {
before, if (!this.range) return
after
} = this.multipleStatus let {
if (before && after) { before,
if (!this.lastHover) { after
this.lastHover = true } = this.multipleStatus
return if (before && after) {
} if (!this.lastHover) {
this.multipleStatus.before = fullDate this.lastHover = true
this.multipleStatus.after = '' return
this.multipleStatus.data = [] }
this.multipleStatus.fulldate = '' this.multipleStatus.before = fullDate
this.lastHover = false this.multipleStatus.after = ''
} else { this.multipleStatus.data = []
if (!before) { this.multipleStatus.fulldate = ''
this.multipleStatus.before = fullDate this.lastHover = false
this.multipleStatus.after = undefined; } else {
this.lastHover = false if (!before) {
} else { this.multipleStatus.before = fullDate
this.multipleStatus.after = fullDate this.multipleStatus.after = undefined;
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { this.lastHover = false
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus } else {
.after); this.multipleStatus.after = fullDate
} else { if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
.before); .after);
} } else {
this.lastHover = true this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
} .before);
} }
this.getWeeks(fullDate) this.lastHover = true
} }
}
/** this.getWeeks(fullDate)
* 鼠标 hover 更新多选状态 }
*/
setHoverMultiple(fullDate) { /**
//抖音小程序点击会触发hover事件需要避免一下 * 鼠标 hover 更新多选状态
// #ifndef MP-TOUTIAO */
if (!this.range || this.lastHover) return setHoverMultiple(fullDate) {
const { //抖音小程序点击会触发hover事件需要避免一下
before // #ifndef MP-TOUTIAO
} = this.multipleStatus if (!this.range || this.lastHover) return
const {
if (!before) { before
this.multipleStatus.before = fullDate } = this.multipleStatus
} else {
this.multipleStatus.after = fullDate if (!before) {
if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) { this.multipleStatus.before = fullDate
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after); } else {
} else { this.multipleStatus.after = fullDate
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before); if (dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
} this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
} } else {
this.getWeeks(fullDate) this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
// #endif }
}
} this.getWeeks(fullDate)
// #endif
/**
* 更新默认值多选状态 }
*/
setDefaultMultiple(before, after) { /**
this.multipleStatus.before = before * 更新默认值多选状态
this.multipleStatus.after = after */
if (before && after) { setDefaultMultiple(before, after) {
if (dateCompare(before, after)) { this.multipleStatus.before = before
this.multipleStatus.data = this.geDateAll(before, after); this.multipleStatus.after = after
this.getWeeks(after) if (before && after) {
} else { if (dateCompare(before, after)) {
this.multipleStatus.data = this.geDateAll(after, before); this.multipleStatus.data = this.geDateAll(before, after);
this.getWeeks(before) this.getWeeks(after)
} } else {
} this.multipleStatus.data = this.geDateAll(after, before);
} this.getWeeks(before)
}
/** }
* 获取每周数据 }
* @param {Object} dateData
*/ /**
getWeeks(dateData) { * 获取每周数据
const { * @param {Object} dateData
year, */
month, getWeeks(dateData) {
} = this.getDateObj(dateData) const {
year,
const preMonthDayAmount = new Date(year, month - 1, 1).getDay() month,
const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData)) } = this.getDateObj(dateData)
const currentMonthDayAmount = new Date(year, month, 0).getDate() const preMonthDayAmount = new Date(year, month - 1, 1).getDay()
const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData)) const preMonthDays = this.getPreMonthDays(preMonthDayAmount, this.getDateObj(dateData))
const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount const currentMonthDayAmount = new Date(year, month, 0).getDate()
const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData)) const currentMonthDays = this.getCurrentMonthDays(currentMonthDayAmount, this.getDateObj(dateData))
const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays] const nextMonthDayAmount = 42 - preMonthDayAmount - currentMonthDayAmount
const nextMonthDays = this._getNextMonthDays(nextMonthDayAmount, this.getDateObj(dateData))
const weeks = new Array(6)
for (let i = 0; i < calendarDays.length; i++) { const calendarDays = [...preMonthDays, ...currentMonthDays, ...nextMonthDays]
const index = Math.floor(i / 7)
if (!weeks[index]) { const weeks = new Array(6)
weeks[index] = new Array(7) for (let i = 0; i < calendarDays.length; i++) {
} const index = Math.floor(i / 7)
weeks[index][i % 7] = calendarDays[i] if (!weeks[index]) {
} weeks[index] = new Array(7)
}
this.calendar = calendarDays weeks[index][i % 7] = calendarDays[i]
this.weeks = weeks }
}
} this.calendar = calendarDays
this.weeks = weeks
function getDateTime(date, hideSecond) { }
return `${getDate(date)} ${getTime(date, hideSecond)}` }
}
function getDateTime(date, hideSecond) {
function getDate(date) { return `${getDate(date)} ${getTime(date, hideSecond)}`
date = fixIosDateFormat(date) }
date = new Date(date)
const year = date.getFullYear() function getDate(date) {
const month = date.getMonth() + 1 date = fixIosDateFormat(date)
const day = date.getDate() date = new Date(date)
return `${year}-${addZero(month)}-${addZero(day)}` const year = date.getFullYear()
} const month = date.getMonth() + 1
const day = date.getDate()
function getTime(date, hideSecond) { return `${year}-${addZero(month)}-${addZero(day)}`
date = fixIosDateFormat(date) }
date = new Date(date)
const hour = date.getHours() function getTime(date, hideSecond) {
const minute = date.getMinutes() date = fixIosDateFormat(date)
const second = date.getSeconds() date = new Date(date)
return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}` const hour = date.getHours()
} const minute = date.getMinutes()
const second = date.getSeconds()
function addZero(num) { return hideSecond ? `${addZero(hour)}:${addZero(minute)}` : `${addZero(hour)}:${addZero(minute)}:${addZero(second)}`
if (num < 10) { }
num = `0${num}`
} function addZero(num) {
return num if (num < 10) {
} num = `0${num}`
}
function getDefaultSecond(hideSecond) { return num
return hideSecond ? '00:00' : '00:00:00' }
}
function getDefaultSecond(hideSecond) {
function dateCompare(startDate, endDate) { return hideSecond ? '00:00' : '00:00:00'
startDate = new Date(fixIosDateFormat(startDate)) }
endDate = new Date(fixIosDateFormat(endDate))
return startDate <= endDate function dateCompare(startDate, endDate) {
} startDate = new Date(fixIosDateFormat(startDate && typeof startDate === 'string' ? startDate.trim() : startDate))
endDate = new Date(fixIosDateFormat(endDate && typeof endDate === 'string' ? endDate.trim() : endDate))
function checkDate(date) { return startDate <= endDate
const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g }
return date.match(dateReg)
} function checkDate(date) {
//ios低版本15及以下无法匹配 没有 ’秒‘ 时的情况,所以需要在末尾 秒 加上 问号 const dateReg = /((19|20)\d{2})(-|\/)\d{1,2}(-|\/)\d{1,2}/g
const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/; return date.match(dateReg)
}
function fixIosDateFormat(value) { //ios低版本15及以下无法匹配 没有 ’秒‘ 时的情况,所以需要在末尾 秒 加上 问号
if (typeof value === 'string' && dateTimeReg.test(value)) { const dateTimeReg = /^\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])( [0-5]?[0-9]:[0-5]?[0-9](:[0-5]?[0-9])?)?$/;
value = value.replace(/-/g, '/')
} function fixIosDateFormat(value) {
return value if (typeof value === 'string' && dateTimeReg.test(value)) {
} value = value.replace(/-/g, '/')
}
export { return value
Calendar, }
getDateTime,
getDate, export {
getTime, Calendar,
addZero, getDateTime,
getDefaultSecond, getDate,
dateCompare, getTime,
checkDate, addZero,
fixIosDateFormat getDefaultSecond,
} dateCompare,
checkDate,
fixIosDateFormat
}

View File

@ -3,7 +3,8 @@ const constant = {
id: 'user_id', id: 'user_id',
name: 'user_name', name: 'user_name',
roles: 'user_roles', roles: 'user_roles',
permissions: 'user_permissions' permissions: 'user_permissions',
currentSiteId: 'current_site_id'
} }
export default constant export default constant

View File

@ -21,16 +21,25 @@ const request = config => {
config.url = url config.url = url
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const requestUrl = config.baseUrl || baseUrl + config.url
const requestMethod = (config.method || 'get').toUpperCase()
uni.request({ uni.request({
method: config.method || 'get', method: config.method || 'get',
timeout: config.timeout || timeout, timeout: config.timeout || timeout,
url: config.baseUrl || baseUrl + config.url, url: requestUrl,
data: config.data, data: config.data,
header: config.header, header: config.header,
dataType: 'json' dataType: 'json'
}).then(response => { }).then(response => {
let [error, res] = response let [error, res] = response
if (error) { if (error) {
const errorType = error?.errMsg || error?.message || 'UNKNOWN_ERROR'
console.error('[request:error]', {
url: requestUrl,
method: requestMethod,
errorType,
rawError: error
})
toast('后端接口连接异常') toast('后端接口连接异常')
reject('后端接口连接异常') reject('后端接口连接异常')
return return
@ -57,6 +66,15 @@ const request = config => {
}) })
.catch(error => { .catch(error => {
let { message } = 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') { if (message === 'Network Error') {
message = '后端接口连接异常' message = '后端接口连接异常'
} else if (message.includes('timeout')) { } else if (message.includes('timeout')) {
@ -64,6 +82,13 @@ const request = config => {
} else if (message.includes('Request failed with status code')) { } else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常' message = '系统接口' + message.substr(message.length - 3) + '异常'
} }
console.error('[request:catch]', {
url: requestUrl,
method: requestMethod,
errorType,
message: rawMessage,
rawError: error
})
toast(message) toast(message)
reject(error) reject(error)
}) })