|
@@ -0,0 +1,292 @@
|
|
|
+<template>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :md="24" :lg="12" style="margin-bottom: 20px;">
|
|
|
+ <el-card class="card-area" v-loading="props.overviewLoading">
|
|
|
+ <div class="card-area-header" style="margin-bottom: 20px;">
|
|
|
+ <img class="image" src="@/assets/images/energyManage/overall.png" alt="整体图片">
|
|
|
+ <div class="title"> 总能耗 </div>
|
|
|
+ <div class="subTitle">单位:吨标准煤</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.today, props.overviewList.yesterday, props.overviewList.todayRingRatio]"
|
|
|
+ :title="['当日', '昨日', '同期环比']" :isDivider="true" />
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.month, props.overviewList.lastMonth, props.overviewList.monthRingRatio]"
|
|
|
+ :title="['当月', '上月', '同期环比']" :isDivider="true" />
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.year, props.overviewList.lastYear, props.overviewList.yearRingRatio]"
|
|
|
+ :title="['当年', '上一年', '同期环比']" :isDivider="false" />
|
|
|
+
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="24" :lg="12" style="margin-bottom: 20px;">
|
|
|
+ <el-card class="card-area" v-loading="props.overviewLoading">
|
|
|
+ <div class="card-area-header" style="margin-bottom: 20px;">
|
|
|
+ <img class="image" src="@/assets/images/energyManage/electricity.png" alt="整体图片">
|
|
|
+ <div class="title">电</div>
|
|
|
+ <div class="subTitle">单位:kwh</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.todayElectricity, props.overviewList.yesterdayElectricity, props.overviewList.todayRingRatio]"
|
|
|
+ :title="['当日', '昨日', '同期环比']" :isDivider="true" />
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.monthElectricity, props.overviewList.lastMonthElectricity, props.overviewList.monthRingRatio]"
|
|
|
+ :title="['当月', '上月', '同期环比']" :isDivider="true" />
|
|
|
+ <StatPanelItem
|
|
|
+ :value="[props.overviewList.yearElectricity, props.overviewList.lastYearElectricity, props.overviewList.yearRingRatio]"
|
|
|
+ :title="['当年', '上一年', '同期环比']" :isDivider="false" />
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="24" :lg="24" style="margin-bottom: 20px;">
|
|
|
+ <el-card class="card-area">
|
|
|
+ <div class="card-area-header" style="margin-bottom: 20px;">
|
|
|
+ <img class="image" src="@/assets/images/energyManage/onThatDay.png" alt="整体图片">
|
|
|
+ <div class="title">
|
|
|
+ {{ radio1.value == 'energy' ? '当日总能耗趋势' : '当日电趋势' }}
|
|
|
+ </div>
|
|
|
+ <div class="subTitle">
|
|
|
+ <el-radio-group v-model="radio1.value" size="small" @change="(val) => handlechange(val, 1)">
|
|
|
+ <el-radio-button label="energy" value="energy">总能耗</el-radio-button>
|
|
|
+ <el-radio-button label="electric " value="electric">电</el-radio-button>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="card-area-center" style="flex-wrap: wrap;" v-loading="oneChartLoading">
|
|
|
+ <div class="mr-20" style="width: calc(20% - 20px);">
|
|
|
+ <StatSideItem :title="radio1.value == 'energy' ? '当日总能耗' : '当日电'"
|
|
|
+ :subTitle="radio1.value == 'energy' ? '吨标准煤' : 'kwh'" :value="[oneChartData.current]" />
|
|
|
+ <StatSideItem :title="radio1.value == 'energy' ? '昨日同期总能耗' : '昨日同期电'"
|
|
|
+ :subTitle="radio1.value == 'energy' ? '吨标准煤' : 'kwh'"
|
|
|
+ :value="[oneChartData.previous, oneChartData.ratio]" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <countChart ref="oneChartRef" class="chart" style="width: 80%;" height="280px"
|
|
|
+ :chartData="oneChartData" />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ <el-col :md="24" :lg="24">
|
|
|
+ <el-card class="card-area">
|
|
|
+ <div class="card-area-header" style="margin-bottom: 20px;">
|
|
|
+ <img class="image" src="@/assets/images/energyManage/theSameMonth.png" alt="整体图片">
|
|
|
+ <div class="title">
|
|
|
+ {{ radio2.value == 'energy' ? '当月总能耗趋势' : '当月电趋势' }}
|
|
|
+ </div>
|
|
|
+ <div class="subTitle">
|
|
|
+ <el-radio-group v-model="radio2.value" size="small" @change="(val) => handlechange(val, 2)">
|
|
|
+ <el-radio-button label="energy" value="energy">总能耗</el-radio-button>
|
|
|
+ <el-radio-button label="electric" value="electric">电</el-radio-button>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="card-area-center" style="flex-wrap: wrap;" v-loading="twoChartLoading">
|
|
|
+ <div class="mr-20" style="width: calc(20% - 20px);">
|
|
|
+
|
|
|
+ <StatSideItem :title="radio2.value == 'energy' ? '当月总能耗' : '当月电'"
|
|
|
+ :subTitle="radio2.value == 'energy' ? '吨标准煤' : 'kwh'" :value="[twoChartData.current]" />
|
|
|
+ <StatSideItem :title="radio2.value == 'energy' ? '上月同期总能耗' : '上月同期电'"
|
|
|
+ :subTitle="radio2.value == 'energy' ? '吨标准煤' : 'kwh'"
|
|
|
+ :value="[twoChartData.previous, twoChartData.ratio]" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <countChart ref="twoChartRef" class="chart" style="width: 80%;" height="280px"
|
|
|
+ :chartData="twoChartData" />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+/*----------------------------------依赖引入-----------------------------------*/
|
|
|
+import { useStore } from 'vuex'
|
|
|
+import { ElMessage, ElNotification } from 'element-plus'
|
|
|
+import { ref, onMounted, watch, getCurrentInstance, reactive, toRefs } from 'vue'
|
|
|
+/*----------------------------------接口引入-----------------------------------*/
|
|
|
+import { energyApi } from '@/api/energyManage/index.js'
|
|
|
+/*----------------------------------组件引入-----------------------------------*/
|
|
|
+import StatPanelItem from './components/StatPanelItem.vue'
|
|
|
+import StatSideItem from './components/StatSideItem.vue'
|
|
|
+import countChart from './components/countChart.vue'
|
|
|
+/*----------------------------------store引入-----------------------------------*/
|
|
|
+/*----------------------------------公共方法引入-----------------------------------*/
|
|
|
+import dayjs from 'dayjs';
|
|
|
+import { GetTimeIntervals } from '@/utils/timeProcessing.utils.js'
|
|
|
+/*----------------------------------公共变量-----------------------------------*/
|
|
|
+const store = useStore()
|
|
|
+const props = defineProps({
|
|
|
+ overviewLoading: Boolean,
|
|
|
+ overviewList: Object,
|
|
|
+}) //数据双向绑定
|
|
|
+const emit = defineEmits([]);
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
+/*----------------------------------变量声明-----------------------------------*/
|
|
|
+const state = reactive({
|
|
|
+ oneChartLoading: true,
|
|
|
+ oneChartData: {
|
|
|
+ subtext: '吨标准煤',
|
|
|
+ current: 0,
|
|
|
+ previous: 0,
|
|
|
+ ratio: 0,
|
|
|
+ legendData: ['当日', '昨日'],
|
|
|
+ xAxisData: [],
|
|
|
+ seriesData: [
|
|
|
+ { name: '当日', type: 'bar', data: [], },
|
|
|
+ { name: '昨日', type: 'bar', data: [], }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ twoChartLoading: true,
|
|
|
+ twoChartData: {
|
|
|
+ subtext: '吨标准煤',
|
|
|
+ current: 0,
|
|
|
+ previous: 0,
|
|
|
+ ratio: 0,
|
|
|
+ legendData: ['当月', '上月'],
|
|
|
+ xAxisData: [],
|
|
|
+ seriesData: [
|
|
|
+ { name: '当月', type: 'bar', data: [], },
|
|
|
+ { name: '上月', type: 'bar', data: [], }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ radio1: {
|
|
|
+ value: "energy"
|
|
|
+ },
|
|
|
+ radio2: {
|
|
|
+ value: "energy"
|
|
|
+ }
|
|
|
+})
|
|
|
+const { oneChartLoading, oneChartData, twoChartLoading, twoChartData, radio1, radio2 } = toRefs(state)
|
|
|
+
|
|
|
+
|
|
|
+// 取日图表数据
|
|
|
+function getDayChartData() {
|
|
|
+ state.oneChartLoading = true
|
|
|
+
|
|
|
+ let param = {
|
|
|
+ siteId: 395,
|
|
|
+ queryPeriod: "day",
|
|
|
+ queryTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ queryType: state.radio1.value
|
|
|
+ }
|
|
|
+ energyApi()
|
|
|
+ .EchartsData(param)
|
|
|
+ .then((item1) => {
|
|
|
+ param.queryTime = dayjs().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
|
|
+
|
|
|
+ energyApi()
|
|
|
+ .EchartsData(param)
|
|
|
+ .then((item2) => {
|
|
|
+ state.oneChartData.current = item1.data.current
|
|
|
+ state.oneChartData.previous = item1.data.previous
|
|
|
+ state.oneChartData.ratio = item1.data.ratio
|
|
|
+ state.oneChartData.subtext = item1.data.unit;
|
|
|
+ state.oneChartData.seriesData[0].data = item1.data.amountList;
|
|
|
+ state.oneChartData.seriesData[1].data = item2.data.amountList;
|
|
|
+ proxy.$refs["oneChartRef"].initEcharts()
|
|
|
+ state.oneChartLoading = false;
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ state.oneChartLoading = false;
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ state.oneChartLoading = false;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 取月图表数据
|
|
|
+function getMonthChartData() {
|
|
|
+ state.twoChartLoading = true
|
|
|
+
|
|
|
+ let param = {
|
|
|
+ siteId: 395,
|
|
|
+ queryPeriod: "month",
|
|
|
+ queryTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ queryType: state.radio2.value
|
|
|
+ }
|
|
|
+ energyApi()
|
|
|
+ .EchartsData(param)
|
|
|
+ .then((item1) => {
|
|
|
+ param.queryTime = dayjs().subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss')
|
|
|
+
|
|
|
+ energyApi()
|
|
|
+ .EchartsData(param)
|
|
|
+ .then((item2) => {
|
|
|
+ state.twoChartData.current = item1.data.current
|
|
|
+ state.twoChartData.previous = item1.data.previous
|
|
|
+ state.twoChartData.ratio = item1.data.ratio
|
|
|
+ state.twoChartData.subtext = item1.data.unit;
|
|
|
+ state.twoChartData.seriesData[0].data = item1.data.amountList;
|
|
|
+ state.twoChartData.seriesData[1].data = item2.data.amountList;
|
|
|
+ proxy.$refs["twoChartRef"].initEcharts()
|
|
|
+ state.twoChartLoading = false;
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ state.twoChartLoading = false;
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ state.twoChartLoading = false;
|
|
|
+ });
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function initChartData() {
|
|
|
+ state.radio1.value = 'energy'
|
|
|
+ state.radio2.value = 'energy'
|
|
|
+
|
|
|
+ state.oneChartData.subtext = "吨标准煤"
|
|
|
+ state.oneChartData.xAxisData = []
|
|
|
+ state.oneChartData.seriesData[0].data = []
|
|
|
+ state.oneChartData.seriesData[1].data = []
|
|
|
+ state.oneChartData.xAxisData = GetTimeIntervals('day', 60)
|
|
|
+ state.oneChartData.xAxisData.forEach(() => {
|
|
|
+ state.oneChartData.seriesData[0].data.push(0)
|
|
|
+ state.oneChartData.seriesData[1].data.push(0)
|
|
|
+ })
|
|
|
+ proxy.$refs["oneChartRef"].initEcharts()
|
|
|
+ state.oneChartLoading = false
|
|
|
+
|
|
|
+
|
|
|
+ state.twoChartData.subtext = "吨标准煤"
|
|
|
+ state.twoChartData.xAxisData = []
|
|
|
+ state.twoChartData.seriesData[0].data = []
|
|
|
+ state.twoChartData.seriesData[1].data = []
|
|
|
+ state.twoChartData.xAxisData = GetTimeIntervals('month', 1)
|
|
|
+ state.twoChartData.xAxisData.forEach(() => {
|
|
|
+ state.twoChartData.seriesData[0].data.push(0)
|
|
|
+ state.twoChartData.seriesData[1].data.push(0)
|
|
|
+ })
|
|
|
+ proxy.$refs["twoChartRef"].initEcharts()
|
|
|
+ state.twoChartLoading = false
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function handlechange(val, type) {
|
|
|
+ if (type == 1) {
|
|
|
+ state.oneChartData.subtext = val == 'energy' ? '吨标准煤' : 'kwh'
|
|
|
+ getDayChartData();
|
|
|
+ } else if (type == 2) {
|
|
|
+ state.twoChartData.subtext = val == 'energy' ? '吨标准煤' : 'kwh'
|
|
|
+ getMonthChartData()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => { })
|
|
|
+
|
|
|
+// 暴露变量
|
|
|
+defineExpose({
|
|
|
+ oneChartData,
|
|
|
+ twoChartData,
|
|
|
+ getDayChartData,
|
|
|
+ getMonthChartData,
|
|
|
+ initChartData,
|
|
|
+ handlechange
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped></style>
|