图表
This commit is contained in:
@ -102,6 +102,10 @@
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.container {
|
.container {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.no-data {
|
||||||
|
padding-top: 70px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uni-button:after {
|
uni-button:after {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<uni-popup ref="popup" type="center" @maskClick="show = false">
|
<uni-popup ref="popup" type="center" @maskClick="show = false" :animation="false">
|
||||||
<view class="chart-popup">
|
<view class="chart-popup">
|
||||||
<uni-datetime-picker v-model="range" type="daterange" :end="end" rangeSeparator="至" @change="changeTime"
|
<uni-datetime-picker v-model="range" type="daterange" :end="end" rangeSeparator="至" @change="changeTime"
|
||||||
style="margin-bottom: 10px;" />
|
style="margin-bottom: 10px;" />
|
||||||
@ -8,8 +8,10 @@
|
|||||||
<button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button>
|
<button type="primary" size="mini" @click="onSearch" style="margin-left: 20px;">搜索</button>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="chart-container">
|
<view class="chart-container">
|
||||||
<qiun-data-charts type="line" :reload="show" :chartData="chartsData" :optsWatch='false'
|
<!-- <qiun-data-charts type="line" :reload="show" :opts="options" :optsWatch='false'
|
||||||
:inScrollView="true" :pageScrollTop="pageScrollTop" :opts="options" :ontouch="true" />
|
:inScrollView="true" :pageScrollTop="pageScrollTop" :ontouch="true" :chartData="chartsData" /> -->
|
||||||
|
<qiun-data-charts type="line" :reshow="show" :optsWatch='false' :opts="options" :chartData="chartsData"
|
||||||
|
:ontouch="true" :inScrollView="true" :pageScrollTop="pageScrollTop" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
@ -28,18 +30,25 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
// {update:true,enableScroll:true,xAxis:{scrollShow:true,itemCount:4,disableGrid:true,scrollAlign:'current'}}
|
||||||
options: {
|
options: {
|
||||||
|
// xAxis: {
|
||||||
|
// scrollShow: true,
|
||||||
|
// itemCount: 3,
|
||||||
|
// disableGrid: true,
|
||||||
|
// scrollAlign: 'current'
|
||||||
|
// },
|
||||||
|
// enableScroll: true,
|
||||||
|
// update: true,
|
||||||
|
dataLabel: false,
|
||||||
enableScroll: true,
|
enableScroll: true,
|
||||||
xAxis: {
|
xAxis: {
|
||||||
scrollShow: true,
|
scrollShow: true,
|
||||||
itemCount: 3,
|
itemCount: 3,
|
||||||
disableGrid: true
|
disableGrid: true
|
||||||
},
|
},
|
||||||
update: true,
|
|
||||||
duration: 0,
|
duration: 0,
|
||||||
animation: false,
|
animation: false,
|
||||||
// enableScroll: true,
|
|
||||||
// padding: [10, 15, 10, 15]
|
|
||||||
},
|
},
|
||||||
show: false,
|
show: false,
|
||||||
range: [],
|
range: [],
|
||||||
@ -66,10 +75,13 @@
|
|||||||
this.deviceId = deviceId
|
this.deviceId = deviceId
|
||||||
this.dataType = dataType
|
this.dataType = dataType
|
||||||
this.range = []
|
this.range = []
|
||||||
setTimeout(() => {
|
this.$nextTick(() => {
|
||||||
this.show = true
|
this.show = true
|
||||||
this.getData()
|
this.getData()
|
||||||
}, 300)
|
// setTimeout(() => {
|
||||||
|
|
||||||
|
// }, 300)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
changeTime(val) {
|
changeTime(val) {
|
||||||
this.range = val || []
|
this.range = val || []
|
||||||
@ -91,7 +103,7 @@
|
|||||||
clusterDeviceId,
|
clusterDeviceId,
|
||||||
range: [startDate = '', endDate = '']
|
range: [startDate = '', endDate = '']
|
||||||
} = this;
|
} = this;
|
||||||
this.chartsData?.series && (this.chartsData.series = [])
|
this.chartsData = {}
|
||||||
return getSingleBatteryData({
|
return getSingleBatteryData({
|
||||||
siteId,
|
siteId,
|
||||||
deviceId,
|
deviceId,
|
||||||
|
|||||||
@ -63,7 +63,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">
|
||||||
|
<uni-datetime-picker v-model="range" type="daterange" :end="end" rangeSeparator="至" @change="changeTime"
|
||||||
|
style="margin-bottom: 10px;" />
|
||||||
|
<view class="chart-container">
|
||||||
|
<qiun-data-charts type="line" :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">
|
||||||
@ -89,18 +99,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Chart from './Chart.vue'
|
// import Chart from './Chart.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
|
// Chart
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
@ -125,6 +136,28 @@
|
|||||||
list: [],
|
list: [],
|
||||||
siteId: '',
|
siteId: '',
|
||||||
pageScrollTop: 0,
|
pageScrollTop: 0,
|
||||||
|
// ucharts数据
|
||||||
|
showChart: false,
|
||||||
|
chartSearchData: {
|
||||||
|
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
duration: 0,
|
||||||
|
animation: false,
|
||||||
|
dataLabel: false,
|
||||||
|
enableScroll: true,
|
||||||
|
xAxis: {
|
||||||
|
scrollShow: true,
|
||||||
|
itemCount: 3,
|
||||||
|
disableGrid: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
range: [],
|
||||||
|
end: Date.now(),
|
||||||
|
loading: false,
|
||||||
|
chartsData: {},
|
||||||
|
// ucharts数据结束
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPageScroll(e) {
|
onPageScroll(e) {
|
||||||
@ -138,6 +171,107 @@
|
|||||||
this.getTableData()
|
this.getTableData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
//ucharts方法
|
||||||
|
maskClick() {
|
||||||
|
this.showChart = false
|
||||||
|
this.$refs.popup.close()
|
||||||
|
},
|
||||||
|
chartOpen({
|
||||||
|
siteId,
|
||||||
|
clusterDeviceId,
|
||||||
|
deviceId
|
||||||
|
}, dataType) {
|
||||||
|
this.loading = false
|
||||||
|
this.range = []
|
||||||
|
this.chartSearchData = {
|
||||||
|
clusterDeviceId,
|
||||||
|
deviceId,
|
||||||
|
dataType
|
||||||
|
}
|
||||||
|
this.$refs.popup.open()
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showChart = true
|
||||||
|
this.getChartData()
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
|
changeTime(val) {
|
||||||
|
this.range = val || []
|
||||||
|
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()
|
||||||
},
|
},
|
||||||
@ -151,7 +285,8 @@
|
|||||||
} = item, {
|
} = item, {
|
||||||
siteId
|
siteId
|
||||||
} = this
|
} = this
|
||||||
this.$refs.chart.open({
|
// this.$refs.chart.open({
|
||||||
|
this.chartOpen({
|
||||||
siteId,
|
siteId,
|
||||||
clusterDeviceId,
|
clusterDeviceId,
|
||||||
deviceId
|
deviceId
|
||||||
@ -343,5 +478,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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>
|
</style>
|
||||||
@ -76,13 +76,14 @@
|
|||||||
activeChartData: {},
|
activeChartData: {},
|
||||||
pageScrollTop: 0,
|
pageScrollTop: 0,
|
||||||
options: {
|
options: {
|
||||||
|
dataLabel: false,
|
||||||
enableScroll: true,
|
enableScroll: true,
|
||||||
xAxis: {
|
xAxis: {
|
||||||
scrollShow: true,
|
scrollShow: true,
|
||||||
itemCount: 7,
|
itemCount: 7,
|
||||||
disableGrid: true
|
disableGrid: true
|
||||||
},
|
},
|
||||||
update: true,
|
// update: true,
|
||||||
// duration: 2,
|
// duration: 2,
|
||||||
// animation: false,
|
// animation: false,
|
||||||
// enableScroll: true,
|
// enableScroll: true,
|
||||||
|
|||||||
@ -97,6 +97,5 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 100px;
|
line-height: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
background-color: #fff;
|
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user