yudao-dev/src/views/energy/analysis/trendAnalysis/index.vue

94 lines
2.4 KiB
Vue
Raw Normal View History

2023-09-05 15:45:59 +08:00
<template>
2023-09-27 09:33:28 +08:00
<div class="app-container trendAnalysisBox" id="trendAnalysisBox">
2023-09-05 15:45:59 +08:00
<!-- 搜索工作栏 -->
2023-09-19 15:45:16 +08:00
<search-area :isFold="isFold" @submit="getList"/>
2023-09-27 09:33:28 +08:00
<el-tabs v-model="activeName" @tab-click="switchChart" v-show='chartData.length'>
2023-09-05 15:45:59 +08:00
<el-tab-pane label="柱状图" name="bar">
2023-09-27 09:33:28 +08:00
<bar-chart ref="analysisBarChart" :chartData="chartData" :timeDim="timeDim"/>
2023-09-05 15:45:59 +08:00
</el-tab-pane>
<el-tab-pane label="折线图" name="line">
2023-09-27 09:33:28 +08:00
<line-chart ref="analysisLineChart" :chartData="chartData" :timeDim="timeDim"/>
2023-09-05 15:45:59 +08:00
</el-tab-pane>
</el-tabs>
2023-09-27 09:33:28 +08:00
<!-- 没有数据 -->
<div class="no-data-bg" v-show='!chartData.length'></div>
2023-09-05 15:45:59 +08:00
</div>
</template>
<script>
import { getEnergyTrend } from "@/api/analysis/energyAnalysis"
import SearchArea from "./components/searchArea"
import BarChart from "./components/barChart"
import LineChart from "./components/lineChart"
// import moment from 'moment'
export default {
name: 'TrendAnalysis',
components: { SearchArea, BarChart, LineChart },
data() {
return {
2023-09-19 15:45:16 +08:00
isFold: false,
2023-09-05 15:45:59 +08:00
activeName: 'bar',
2023-09-27 09:33:28 +08:00
chartData: [],
timeDim: ''
2023-09-05 15:45:59 +08:00
}
},
2023-09-19 15:45:16 +08:00
mounted() {
window.addEventListener('resize', () => {
this.tableH = this.tableHeight(260)
this.isFold = this.searchBarWidth('trendAnalysisBox', 1146)
})
this.isFold = this.searchBarWidth('trendAnalysisBox', 1146)
},
2023-09-05 15:45:59 +08:00
methods: {
getList(params) {
2023-09-27 09:33:28 +08:00
this.timeDim = params.timeDim
2023-09-05 15:45:59 +08:00
getEnergyTrend({ ...params }).then((res) => {
if (res.code === 0) {
this.chartData = res.data
} else {
this.chartData = []
}
})
},
switchChart() {
if (this.activeName === 'bar') {
this.$nextTick((res) => {
this.$refs.analysisBarChart.getChart()
})
} else {
this.$nextTick((res) => {
this.$refs.analysisLineChart.getChart()
})
}
}
}
}
2023-09-27 09:33:28 +08:00
</script>
<style lang='scss'>
.trendAnalysisBox {
.el-tabs__nav::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 2px;
background-color: #e4e7ed;
/* z-index: 1; */
}
.el-tabs__nav-wrap::after {
width: 0;
}
.el-tabs__item {
padding: 0 10px;
}
.el-tabs__item:hover {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item.is-active {
color: rgba(0, 0, 0, 0.85);
}
.el-tabs__item {
color: rgba(0, 0, 0, 0.45);
}
}
</style>