123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <template>
- <div>
- <CusModule title="能耗统计">
- <div class="soc-stats-container">
- <div v-for="i in socList" :key="i.name" class="soc-stats-item" :style="{ backgroundImage: `url(${i.image})` }">
- <div class="soc-stats-info">
- <div class="mb-1">
- <span class="soc-stats-value">{{ i.value }}</span>
- <span class="unit">{{ i.unit }}</span>
- </div>
- <div class="soc-stats-label">
- {{ i.name }}
- </div>
- </div>
- </div>
- </div>
- </CusModule>
- <CusModule class="module-top" title="用能排名">
- <div class="soc-lst">
- <div v-for="(item, index) in ranking" :key="item.name" class="soc-itm">
- <div class="soc-num">
- {{ index + 1 }}
- </div>
- <div class="soc-dtl">
- <div class="txt-sm">
- {{ item.name }}
- </div>
- <CusProgress :value="item.value" :total="ranking.reduce((a, b) => a + b.value, 0)" :color="item.color"
- :labelWidth="95" unit="kW·h" showLabel></CusProgress>
- </div>
- </div>
- </div>
- </CusModule>
- <CusModule class="module-top" title="用能趋势预测">
- <BaseChart height="350px" width="100%" :option="lineOptions"/>
- </CusModule>
- </div>
- </template>
- <script>
- import CusModule from '../components/CusModule.vue';
- import CusProgress from '../components/CusProgress.vue';
- import BaseChart from '@/components/BaseChart/index.vue'
- import * as echarts from 'echarts'
- import {array2Map, numToStr} from '@/utils'
- import {mapState} from 'vuex';
- import {listByFacs, qryElecMeterByDate, qryWaterMeterByDate} from "@/api/device/elecMeterH";
- import {DateTool} from "@/utils/DateTool";
- import _ from 'lodash'
- import {listForecastConsumeDateRange} from "@/api/prediction/forecastConsume";
- export default {
- name: 'SocRight',
- data() {
- return {
- socList: [
- {
- name: "电",
- image: require("@/assets/images/soc/item1.png"),
- unit: "kW·h",
- },
- // {
- // name: "燃气",
- // image: require("@/assets/images/soc/item2.png"),
- // value: 7945,
- // unit: "kg",
- // },
- {
- name: "水",
- image: require("@/assets/images/soc/item3.png"),
- unit: "吨",
- },
- ],
- ranking: [],
- lineData: []
- }
- },
- components: {
- CusModule,
- CusProgress,
- BaseChart,
- },
- computed: {
- ...mapState('userState', ['areaType']),
- lineOptions() {
- return {
- grid: {
- top: "10%",
- bottom: "10%",//也可设置left和right设置距离来控制图表的大小
- contain: true
- },
- tooltip: {
- trigger: "axis",
- axisPointer: {
- type: "shadow",
- label: {
- show: true
- }
- }
- },
- xAxis: {
- data: this.lineData.map(item => item.xData),
- axisLine: {
- show: true, //隐藏X轴轴线
- },
- axisTick: {
- show: true //隐藏X轴刻度
- },
- axisLabel: {
- show: true,
- },
- },
- yAxis: [{
- type: "value",
- name: "kW·h",
- splitLine: {
- show: true,
- lineStyle: {
- color: '#334E5E'
- }
- },
- }],
- series: [
- {
- name: "用电量",
- type: "bar",
- barWidth: 15,
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
- offset: 0,
- color: "#21C3E8"
- },
- {
- offset: 0.7,
- color: "#1484A1"
- },
- {
- offset: 1,
- color: "#0B2B38"
- }
- ])
- }
- },
- data: this.lineData.map(item => item.yData1)
- },
- ]
- }
- }
- },
- watch: {
- areaType() {
- this.getSocData()
- }
- },
- mounted() {
- this.getSocData()
- },
- methods: {
- async getDeviceElecMeter() {
- const params = {
- startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
- endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
- meterCls: 45,
- areaCode: this.areaType || -1,
- facsCategory: 'Z',
- };
- listByFacs(params).then(response => {
- const energyUse = response.data.map(item => ({
- name: item.objName,
- color: "#14c5f2",
- value: item.quantity || 0,
- }));
- this.ranking = _.slice(_.orderBy(energyUse, ['value'], ['desc']), 0, 5);
- })
- },
- async getDatesOfLastTenDays() {
- const next5Day = DateTool.addDays(DateTool.now(), 4);
- const {data} = await listForecastConsumeDateRange({
- areaCode: this.areaType,
- startRecTime: DateTool.now(),
- endRecTime: next5Day,
- })
- const dates = DateTool.getDayOfRange(DateTool.now(), next5Day);
- const mapIndex = array2Map(data, "date");
- this.lineData = dates.map(item => ({
- xData: item,
- yData1: mapIndex[item] ? mapIndex[item].elecUseQuantity : 0
- }));
- },
- getSocData() {
- this.lineData = this.getDatesOfLastTenDays()
- this.getMeterElecWater()
- this.getDeviceElecMeter()
- },
- async getMeterElecWater() {
- const {data: elecMeter} = await qryElecMeterByDate(DateTool.now(), this.areaType)
- const {data: waterMeter} = await qryWaterMeterByDate(DateTool.now(), this.areaType)
- const [elec, water] = this.socList
- elec.value = numToStr(elecMeter.quantity)
- water.value = numToStr(waterMeter.quantity)
- this.socList = [elec, water]
- },
- }
- }
- </script>
- <style lang='scss' scoped>
- @import url("../index.scss");
- .soc-stats-container {
- display: flex;
- justify-content: space-between;
- margin-top: 20px;
- padding: 0 40px;
- .soc-stats-item {
- position: relative;
- width: 120px;
- height: 138px;
- background-size: cover;
- .soc-stats-info {
- position: absolute;
- bottom: -2px;
- width: 100%;
- text-align: center;
- .soc-stats-value {
- font-size: 18px;
- font-weight: bold;
- color: #06E3F9;
- }
- .soc-stats-label {
- color: #B3E3E8;
- font-size: 14px;
- margin-top: 2px;
- }
- }
- }
- }
- .soc-lst {
- height: 100%;
- padding-top: 6px;
- padding-bottom: 6px;
- display: flex;
- flex-direction: column;
- align-items: center;
- overflow-y: auto;
- .soc-itm {
- width: 332px;
- height: 45px;
- background-image: url('~@/assets/images/soc/r2-list.png');
- background-repeat: no-repeat;
- display: flex;
- align-items: center;
- .soc-num {
- width: 53px;
- margin-right: 16px;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .soc-dtl {
- padding-right: 2px;
- width: 100%;
- .txt-sm {
- color: #B3E3E8;
- font-size: 12px;
- margin-bottom: 5px;
- }
- }
- }
- }
- .seamless-header {
- margin-top: 20px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 5px 10px;
- color: #7DBAFF;
- background: #1B4A64;
- font-size: 16px;
- > div:first-of-type,
- > div:last-of-type {
- flex-basis: 35%;
- }
- > div {
- text-align: center;
- }
- }
- .seamless-warp {
- overflow: hidden;
- height: 200px;
- .seamless-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 5px 0;
- &:nth-child(odd) {
- background: #000;
- }
- > div:first-of-type,
- > div:last-of-type {
- flex-basis: 38%;
- }
- > div {
- text-align: center;
- font-size: 13px;
- }
- }
- }
- </style>
|