123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <template>
- <div class="home">
- <div class="home-row">
- <el-card class="box-card">
- <div slot="header" class="box-header">
- <span>能耗汇总</span>
- <div class="header-right">
- <div :class="{ 'selected': activeDate === item.value }" v-for="item in dateList" :key="item.name"
- @click="dateChange(item)">{{ item.name }}</div>
- </div>
- </div>
- <div class="summary">
- <div class="summary-item">
- <div>
- <div class="summary-bg">
- <img class="energyImg" src="@/assets/images/energy.svg" alt="">
- </div>
- <div class="summary-title">
- <div>电消耗</div>
- <div class="summary-value">
- <span class="value">122</span>
- <span class="unit">kW·h</span>
- </div>
- <div class="summary-value">
- <span class="value">182</span>
- <span class="unit">元</span>
- </div>
- </div>
- </div>
- <div>
- <div class="summary-bg">
- <img src="@/assets/images/water.svg" alt="">
- </div>
- <div class="summary-title">
- <div>水消耗</div>
- <div class="summary-value">
- <span class="value">132</span>
- <span class="unit">吨</span>
- </div>
- <div class="summary-value">
- <span class="value">162</span>
- <span class="unit">元</span>
- </div>
- </div>
- </div>
- </div>
- <div class="summay-chart">
- <SubTitle title="费用【单位:元】" style="padding-left: 30px;"/>
- <div class="cost">
- <span>总费用</span>
- <span>344元</span>
- </div>
- <BaseChart width="100%" height="250px" :option="useOptions" />
- </div>
- </div>
- </el-card>
- </div>
- <el-card class="box-card">
- <div slot="header" class="box-header">
- <span>用能趋势分析</span>
- <div class="header-right">
- <div :class="{ 'selected': activeDimension === item.value }" v-for="item in dimensionList" :key="item.name"
- @click="dimensionChange(item)">{{ item.name }}</div>
- </div>
- </div>
- <BaseChart width="100%" height="250px" :option="energyOptions" />
- </el-card>
- </div>
- </template>
- <script>
- import BaseChart from '@/components/BaseChart'
- import SubTitle from '@/components/SubTitle/index.vue'
- export default {
- name: "Index",
- data () {
- return {
- activeDate: '1',
- dateList: [
- {name: '上月', value: '1'},
- {name: '本月', value: '2'},
- {name: '去年', value: '3'},
- {name: '本年', value: '4'},
- ],
- activeDimension: '1',
- dimensionList: [
- {name: '小时', value: '1'},
- {name: '天', value: '2'},
- {name: '月', value: '3'},
- {name: '年', value: '4'},
- ],
- consumList: [
- {
- name: '综合能耗',
- value: '',
- unit: '',
- cost: ''
- }
- ]
- };
- },
- components: {BaseChart,SubTitle},
- computed: {
- useOptions () {
- return {
- tooltip: {
- trigger: 'item',
- },
- legend: {
- show: false,
- orient: 'vertical',
- top: '5%',
- left: '5%'
- },
- series: [
- {
- name: '费用',
- type: 'pie',
- radius: ['35%', '55%'],
- data: [{
- name: '水费', value: '162',
- itemStyle: {
- normal: {
- color: '#1396DB'
- }
- }
- }, {
- name: '电费', value: '182',
- itemStyle: {
- normal: {
- color: '#F4EA29'
- }
- }
- }],
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)',
- }
- },
- label: {
- show: true,
- position: 'outside',
- formatter: '{b}\n{d}%',
- },
- labelLine: {
- show: true,
- length: 30, // 标签线长度
- lineStyle: {
- width: 1,
- type: 'dashed', // 设置虚线样式
- }
- }
- }
- ]
- }
- },
- energyOptions () {
- const dataArr = []
- let dataObj = {
- name: "用能趋势分析",
- type: "bar",
- year: ["2015", "2016", "2017", "2018", "2019", "2020"],
- val: [
- {
- name: '水',
- value: ["0", "0", "20", "11", "18", "5"]
- },
- {
- name: '电',
- value: ["4", "10", "2", "22", "12", "3"]
- }
- ]
- }
- dataObj.val.map(item => {
- const newArr = {
- name: item.name,
- type: 'bar',
- smooth: true,
- symbolSize: 8,
- data: item.value,
- barWidth: '17%',
- itemStyle: {
- normal: {
- color: item.name === '水' ? '#1396DB' : '#F4EA29'
- }
- }
- }
- dataArr.push(newArr)
- })
- return {
- toolbox: {
- itemGap: 10,
- itemSize: 16,
- right: 10,
- top: 0,
- show: true,
- feature: {
- magicType: {
- show: true,
- type: ['bar', 'line']
- },
- saveAsImage: {
- show: true
- }
- }
- },
- // color: ['#f0c725', '#16f892'],
- tooltip: {
- trigger: 'axis',
- axisPointer: { // 坐标轴指示器,坐标轴触发有效
- type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
- }
- },
- legend: {
- x: 'center',
- top: '0',
- textStyle: {
- // color: '#c1cadf',
- fontSize: 14
- }
- },
- grid: {
- left: '5%',
- right: '6%',
- top: '5%',
- bottom: '10%',
- containLabel: false
- },
- xAxis: [{
- type: 'category',
- boundaryGap: true,
- data: dataObj.year,
- axisLine: {
- lineStyle: {
- // color: 'rgba(240,199,37,1)'
- }
- },
- axisLabel: {
- interval: 0,
- // color: '#c1cadf',
- fontSize: '15'
- }
- }],
- yAxis: [{
- type: 'value',
- name: '(处)',
- nameTextStyle: {
- // color: '#c1cadf',
- align: 'right',
- lineHeight: 10
- },
- axisLine: {
- lineStyle: {
- // color: 'rgba(240,199,37,1)'
- }
- },
- axisLabel: {
- interval: 0,
- // color: '#c1cadf',
- fontSize: '15'
- },
- splitLine: {
- show: false
- }
- }],
- series: dataArr
- }
- }
- },
- methods: {
- dateChange (item) {
- this.activeDate = item.value
- },
- dimensionChange (item) {
- this.activeDimension = item.value
- }
- },
- };
- </script>
- <style scoped lang="scss">
- .home {
- padding: 0 10px;
- }
- .home-row {
- display: flex;
- justify-content: space-between;
- .box-card:last-of-type {
- margin-left: 10px;
- }
- }
- .box-card {
- margin-top: 10px;
- width: 100%;
- .box-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-weight: bold;
- .header-right {
- display: flex;
- color: #98999b;
- font-weight: normal;
- font-size: 14px;
- >div {
- display: flex;
- align-items: center;
- cursor: pointer;
- &:not(:last-of-type):after {
- content: '';
- height: 12px;
- width: 1px;
- background: #d5d8e0;
- margin: 0 3px;
- }
- }
- .selected {
- color: #409EFF;
- }
- }
- }
- }
- .summary {
- display: flex;
- justify-content: space-around;
- .summay-chart {
- flex: 1;
- position: relative;
- .cost{
- position: absolute;
- top: 53%;
- left: 50%;
- transform: translate(-50%,-50%);
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- }
- .summary-item {
- flex: 1;
- flex-shrink: 0;
- display: flex;
- justify-content: space-around;
- >div {
- display: flex;
- align-items: center;
- justify-content: center;
- .summary-bg {
- margin-top: 20px;
- width: 140px;
- height: 140px;
- border-radius: 50%;
- border: 3px solid #d5d8e0;
- box-shadow: 0px 4px 10px 0px rgba(69, 89, 120, 0.3);
- display: flex;
- justify-content: center;
- align-items: center;
- img {
- height: 60px;
- }
- .energyImg {
- height: 90px;
- }
- }
- .summary-title {
- margin-left: 10px;
- >div:first-child {
- font-weight: bold;
- color: #333;
- margin-bottom: 10px;
- }
- .summary-value {
- margin-top: 5px;
- }
- .value {
- font-size: 18px;
- font-weight: bold;
- }
- .unit {
- margin-left: 10px;
- font-size: 12px;
- color: #bbbcbf;
- }
- }
- }
- }
- }
- </style>
|