|
|
@@ -11,7 +11,7 @@
|
|
|
<div class="device-info">
|
|
|
<img src="@/assets/images/dblxzhb.png" class="title-icon" />
|
|
|
<div>
|
|
|
- <div class="device-count">8921</div>
|
|
|
+ <div class="device-count">{{ electricState.deviceCount }}</div>
|
|
|
<div class="device-name">智能电表</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -19,28 +19,28 @@
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">年度用电</div>
|
|
|
<div>
|
|
|
- <div class="data-value">428921</div>
|
|
|
+ <div class="data-value">{{ electricState.annualUsage }}</div>
|
|
|
<div class="data-unit">kW·h</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">月均用电</div>
|
|
|
<div>
|
|
|
- <div class="data-value">18921</div>
|
|
|
+ <div class="data-value">{{ electricState.monthlyAvgUsage }}</div>
|
|
|
<div class="data-unit">kW·h</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">日均用电</div>
|
|
|
<div>
|
|
|
- <div class="data-value">8921</div>
|
|
|
+ <div class="data-value">{{ electricState.dailyAvgUsage }}</div>
|
|
|
<div class="data-unit">kW·h</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">开关次数</div>
|
|
|
<div>
|
|
|
- <div class="data-value">887</div>
|
|
|
+ <div class="data-value">{{ electricState.switchCount }}</div>
|
|
|
<div class="data-unit">近12个月</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -57,7 +57,7 @@
|
|
|
<div class="device-info">
|
|
|
<img src="@/assets/images/zhnmj.png" class="title-icon" />
|
|
|
<div>
|
|
|
- <div class="device-count">8921</div>
|
|
|
+ <div class="device-count">{{ waterState.deviceCount }}</div>
|
|
|
<div class="water-device-name">智能水表</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -65,28 +65,28 @@
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">年度用水</div>
|
|
|
<div>
|
|
|
- <div class="data-value">89321</div>
|
|
|
+ <div class="data-value">{{ waterState.annualUsage }}</div>
|
|
|
<div class="water-data-unit">m³</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">月均用水</div>
|
|
|
<div>
|
|
|
- <div class="data-value">9212</div>
|
|
|
+ <div class="data-value">{{ waterState.monthlyAvgUsage }}</div>
|
|
|
<div class="water-data-unit">m³</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">日均用水</div>
|
|
|
<div>
|
|
|
- <div class="data-value">921</div>
|
|
|
+ <div class="data-value">{{ waterState.dailyAvgUsage }}</div>
|
|
|
<div class="water-data-unit">m³</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="data-card">
|
|
|
<div class="data-label">开关次数</div>
|
|
|
<div>
|
|
|
- <div class="data-value">887</div>
|
|
|
+ <div class="data-value">{{ waterState.switchCount }}</div>
|
|
|
<div class="water-data-unit">近12个月</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -96,268 +96,105 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import * as echarts from 'echarts'
|
|
|
-export default {
|
|
|
- name: 'HardwareData',
|
|
|
- data () {
|
|
|
- return {
|
|
|
- powerChartInstance: null,
|
|
|
- waterChartInstance: null,
|
|
|
- // 模拟月度数据
|
|
|
- monthlyData: [
|
|
|
- { month: '十二月', power: 220000, water: 180000 },
|
|
|
- { month: '一月', power: 210000, water: 170000 },
|
|
|
- { month: '二月', power: 230000, water: 190000 },
|
|
|
- { month: '三月', power: 225000, water: 185000 },
|
|
|
- { month: '四月', power: 215000, water: 175000 },
|
|
|
- { month: '五月', power: 200000, water: 160000 },
|
|
|
- { month: '六月', power: 205000, water: 165000 },
|
|
|
- { month: '七月', power: 210000, water: 170000 },
|
|
|
- { month: '八月', power: 215000, water: 175000 },
|
|
|
- { month: '九月', power: 220000, water: 180000 },
|
|
|
- { month: '十月', power: 225000, water: 185000 },
|
|
|
- { month: '十一月', power: 230000, water: 190000 }
|
|
|
- ]
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- this.initPowerChart()
|
|
|
- this.initWaterChart()
|
|
|
- window.addEventListener('resize', this.handleResize)
|
|
|
- },
|
|
|
- beforeDestroy () {
|
|
|
- window.removeEventListener('resize', this.handleResize)
|
|
|
- if (this.powerChartInstance) {
|
|
|
- this.powerChartInstance.dispose()
|
|
|
- }
|
|
|
- if (this.waterChartInstance) {
|
|
|
- this.waterChartInstance.dispose()
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 初始化用电量柱状图
|
|
|
- initPowerChart () {
|
|
|
- this.powerChartInstance = echarts.init(this.$refs.powerChart)
|
|
|
+ import { huiJiaApi } from "@/api"
|
|
|
+ import * as echarts from "echarts"
|
|
|
|
|
|
- const option = {
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
|
- borderColor: 'rgba(64, 158, 255, 0.3)',
|
|
|
- textStyle: {
|
|
|
- color: '#fff'
|
|
|
- },
|
|
|
- formatter: (params) => {
|
|
|
- let result = ``
|
|
|
- params.forEach((param) => {
|
|
|
- result += `${param.name}<br/>${
|
|
|
- param.seriesName
|
|
|
- }: ${param.value.toLocaleString()}<br/>`
|
|
|
- })
|
|
|
- return result
|
|
|
- }
|
|
|
- },
|
|
|
- grid: {
|
|
|
- left: '1%',
|
|
|
- right: '1%',
|
|
|
- top: '5%',
|
|
|
- bottom: '2%',
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- data: this.monthlyData.map((item) => item.month),
|
|
|
- axisLine: {
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.3)',
|
|
|
- type: 'dashed'
|
|
|
- }
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- color: 'rgba(160, 179, 214, 0.7)',
|
|
|
- fontSize: 11,
|
|
|
- interval: 0
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- splitLine: {
|
|
|
- show: true,
|
|
|
- // 将坐标轴内的线设置为虚线
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.3)',
|
|
|
- type: 'dashed'
|
|
|
- }
|
|
|
- }
|
|
|
+ export default {
|
|
|
+ name: "HardwareData",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ electricState: {
|
|
|
+ deviceCount: 8921, // 设备数量
|
|
|
+ annualUsage: 428921, // 年度用量 近12月的用量之和
|
|
|
+ monthlyAvgUsage: 18921, // 月均用量 近12月用量月平均数
|
|
|
+ dailyAvgUsage: 8921, // 日均用量 近12月用量日平均数
|
|
|
+ switchCount: 887, // 开关次数 近12月成功开启、关闭次数
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ statData: "2024-01", // 时间段
|
|
|
+ count: 8921, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-02", // 时间段
|
|
|
+ count: 7891, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-03", // 时间段
|
|
|
+ count: 8931, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-04", // 时间段
|
|
|
+ count: 6131, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-05", // 时间段
|
|
|
+ count: 1891, // 总数
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- yAxis: {
|
|
|
- type: 'value',
|
|
|
- axisLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- color: 'rgba(160, 179, 214, 0.7)',
|
|
|
- fontSize: 11
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- splitLine: {
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.1)',
|
|
|
- type: 'dashed',
|
|
|
- width: 1
|
|
|
- }
|
|
|
- }
|
|
|
+ waterState: {
|
|
|
+ deviceCount: 8921, // 设备数量
|
|
|
+ annualUsage: 428921, // 年度用量 近12月的用量之和
|
|
|
+ monthlyAvgUsage: 18921, // 月均用量 近12月用量月平均数
|
|
|
+ dailyAvgUsage: 8921, // 日均用量 近12月用量日平均数
|
|
|
+ switchCount: 887, // 开关次数 近12月成功开启、关闭次数
|
|
|
+ list: [
|
|
|
+ {
|
|
|
+ statData: "2024-01", // 时间段
|
|
|
+ count: 8921, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-02", // 时间段
|
|
|
+ count: 7891, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-03", // 时间段
|
|
|
+ count: 8931, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-04", // 时间段
|
|
|
+ count: 6131, // 总数
|
|
|
+ },
|
|
|
+ {
|
|
|
+ statData: "2024-05", // 时间段
|
|
|
+ count: 1891, // 总数
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '用电量',
|
|
|
- type: 'bar',
|
|
|
- data: this.monthlyData.map((item) => item.power),
|
|
|
- barWidth: '30%',
|
|
|
- itemStyle: {
|
|
|
- color: new echarts.graphic.LinearGradient(1, 1, 0, 0, [
|
|
|
- { offset: 0, color: '#FCE2B4' },
|
|
|
- { offset: 1, color: '#F66757' }
|
|
|
- ]),
|
|
|
- borderRadius: [20, 20, 0, 0]
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- position: 'top',
|
|
|
- color: '#fff',
|
|
|
- fontSize: 10,
|
|
|
- formatter: (params) =>
|
|
|
- params.value >= 10000
|
|
|
- ? (params.value / 10000).toFixed(1) + '万'
|
|
|
- : params.value
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
+ powerChartInstance: null,
|
|
|
+ waterChartInstance: null,
|
|
|
}
|
|
|
-
|
|
|
- this.powerChartInstance.setOption(option)
|
|
|
},
|
|
|
-
|
|
|
- // 初始化用水量柱状图
|
|
|
- initWaterChart () {
|
|
|
- this.waterChartInstance = echarts.init(this.$refs.waterChart)
|
|
|
-
|
|
|
- const option = {
|
|
|
- tooltip: {
|
|
|
- trigger: 'axis',
|
|
|
- backgroundColor: 'rgba(0, 0, 0, 0.8)',
|
|
|
- borderColor: 'rgba(64, 158, 255, 0.3)',
|
|
|
- textStyle: {
|
|
|
- color: '#fff'
|
|
|
- },
|
|
|
- formatter: (params) => {
|
|
|
- let result = ``
|
|
|
- params.forEach((param) => {
|
|
|
- result += `${param.name}<br/>${
|
|
|
- param.seriesName
|
|
|
- }: ${param.value.toLocaleString()}<br/>`
|
|
|
- })
|
|
|
- return result
|
|
|
- }
|
|
|
- },
|
|
|
- grid: {
|
|
|
- left: '1%',
|
|
|
- right: '1%',
|
|
|
- top: '2%',
|
|
|
- bottom: '5%',
|
|
|
- containLabel: true
|
|
|
- },
|
|
|
- xAxis: {
|
|
|
- type: 'category',
|
|
|
- data: this.monthlyData.map((item) => item.month),
|
|
|
- axisLine: {
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.3)',
|
|
|
- type: 'dashed'
|
|
|
- }
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- color: 'rgba(160, 179, 214, 0.7)',
|
|
|
- fontSize: 11,
|
|
|
- interval: 0,
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- splitLine: {
|
|
|
- show: true,
|
|
|
- // 将坐标轴内的线设置为虚线
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.3)',
|
|
|
- type: 'dashed'
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- yAxis: {
|
|
|
- type: 'value',
|
|
|
- // 反转 y 轴的 min 和 max,实现“倒立”
|
|
|
- min: 400000,
|
|
|
- max: 0,
|
|
|
- axisLine: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- color: 'rgba(160, 179, 214, 0.7)',
|
|
|
- fontSize: 11
|
|
|
- },
|
|
|
- axisTick: {
|
|
|
- show: false
|
|
|
- },
|
|
|
- splitLine: {
|
|
|
- lineStyle: {
|
|
|
- color: 'rgba(160, 179, 214, 0.1)',
|
|
|
- type: 'dashed',
|
|
|
- width: 1
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: '用水量',
|
|
|
- type: 'bar',
|
|
|
- data: this.monthlyData.map((item) => item.water),
|
|
|
- barWidth: '30%',
|
|
|
- itemStyle: {
|
|
|
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
- { offset: 0, color: '#3AB3E3' },
|
|
|
- { offset: 1, color: '#1620D4' }
|
|
|
- ]),
|
|
|
- borderRadius: [0, 0, 20, 20]
|
|
|
- },
|
|
|
- label: {
|
|
|
- show: true,
|
|
|
- position: 'bottom',
|
|
|
- color: '#fff',
|
|
|
- fontSize: 10,
|
|
|
- formatter: (params) =>
|
|
|
- params.value >= 10000
|
|
|
- ? (params.value / 10000).toFixed(1) + '万'
|
|
|
- : params.value
|
|
|
- }
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-
|
|
|
- this.waterChartInstance.setOption(option)
|
|
|
+ mounted() {
|
|
|
+ this.initPowerChart()
|
|
|
+ this.initWaterChart()
|
|
|
+ window.addEventListener("resize", this.handleResize)
|
|
|
+ this.getData()
|
|
|
},
|
|
|
-
|
|
|
- handleResize () {
|
|
|
+ beforeDestroy() {
|
|
|
+ window.removeEventListener("resize", this.handleResize)
|
|
|
if (this.powerChartInstance) {
|
|
|
- this.powerChartInstance.resize()
|
|
|
+ this.powerChartInstance.dispose()
|
|
|
}
|
|
|
if (this.waterChartInstance) {
|
|
|
- this.waterChartInstance.resize()
|
|
|
+ this.waterChartInstance.dispose()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getData() {
|
|
|
+ huiJiaApi.getElectricData().then((res) => {
|
|
|
+ if (res && res.data) {
|
|
|
+ this.state = res.data.data
|
|
|
+ }
|
|
|
+ console.log("业务数据----", res.data.data)
|
|
|
+ })
|
|
|
+ huiJiaApi.getWaterData().then((res) => {
|
|
|
+ if (res && res.data) {
|
|
|
+ this.state = res.data.data
|
|
|
+ }
|
|
|
+ console.log("业务数据----", res.data.data)
|
|
|
+ })
|
|
|
+ },
|
|
|
// 初始化用电量柱状图
|
|
|
initPowerChart() {
|
|
|
this.powerChartInstance = echarts.init(this.$refs.powerChart)
|
|
|
@@ -389,7 +226,7 @@ export default {
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: "category",
|
|
|
- data: this.monthlyData.map((item) => item.month),
|
|
|
+ data: this.electricState.list.map((item) => item.statData),
|
|
|
axisLine: {
|
|
|
lineStyle: {
|
|
|
color: "rgba(160, 179, 214, 0.3)",
|
|
|
@@ -415,6 +252,8 @@ export default {
|
|
|
},
|
|
|
yAxis: {
|
|
|
type: "value",
|
|
|
+ min: 0,
|
|
|
+ max: 40000,
|
|
|
axisLine: {
|
|
|
show: false,
|
|
|
},
|
|
|
@@ -437,7 +276,7 @@ export default {
|
|
|
{
|
|
|
name: "用电量",
|
|
|
type: "bar",
|
|
|
- data: this.monthlyData.map((item) => item.power),
|
|
|
+ data: this.electricState.list.map((item) => item.count),
|
|
|
barWidth: "30%",
|
|
|
itemStyle: {
|
|
|
color: new echarts.graphic.LinearGradient(1, 1, 0, 0, [
|
|
|
@@ -495,7 +334,7 @@ export default {
|
|
|
},
|
|
|
xAxis: {
|
|
|
type: "category",
|
|
|
- data: this.monthlyData.map((item) => item.month),
|
|
|
+ data: this.waterState.list.map((item) => item.statData),
|
|
|
axisLine: {
|
|
|
lineStyle: {
|
|
|
color: "rgba(160, 179, 214, 0.3)",
|
|
|
@@ -523,7 +362,7 @@ export default {
|
|
|
yAxis: {
|
|
|
type: "value",
|
|
|
// 反转 y 轴的 min 和 max,实现“倒立”
|
|
|
- min: 400000,
|
|
|
+ min: 40000,
|
|
|
max: 0,
|
|
|
axisLine: {
|
|
|
show: false,
|
|
|
@@ -547,7 +386,7 @@ export default {
|
|
|
{
|
|
|
name: "用水量",
|
|
|
type: "bar",
|
|
|
- data: this.monthlyData.map((item) => item.water),
|
|
|
+ data: this.waterState.list.map((item) => item.count),
|
|
|
barWidth: "30%",
|
|
|
itemStyle: {
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
|
|
@@ -584,7 +423,6 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
}
|
|
|
-}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|