123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- <template>
- <view>
- <u-navbar :title="title" title-color="#101010">
- </u-navbar>
- <u-picker-select :noselect="false" @confirm="selector2confirm" @reset="selector2reset" :defaultTime="queryDate"
- title="日期选择" v-model="show" mode="time" :params="params"></u-picker-select>
-
- <view class="main">
-
- <view class="title">
- <view class="text">
- <view class="icon">
- </view>
- <span>
- 同比分析-每月用电量(kW·h)
- </span>
- </view>
- </view>
- <view class="chat">
- <view id="barEcharts1" style="min-height:440rpx;">
- </view>
- </view>
- <view v-html="description">
-
- </view>
- </view>
- <view class="main">
- <view class="title">
- <view class="text">
- <view class="icon">
- </view>
- <span>
- 同比分析-每小时用电量(kW·h)
- </span>
- </view>
- <view class="text1" @click="show=true">
- {{queryDate==nowDate?'今日':queryDateStr}}<u-icon name="arrow-down"></u-icon>
- </view>
- </view>
- <view class="chat">
- <view id="barEcharts2" style="min-height:440rpx;">
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/electricityMeter.js'
- import * as echarts from 'echarts';
- import {
- currentTimeStamp,
- parseUnixTime,
- beforeTimeStamp
- } from '@/apis/utils'
- export default {
- data() {
- return {
- params: {
- year: true,
- month: true,
- day: true,
- hour: false,
- minute: false,
- second: false
- },
- show: false,
- meterNo: '',
- type: '',
- typeName: '',
- nowDate: "",
- queryDate: "",
- queryDateStr: "",
- showlist1: [],
- graphMap: {},
- graphMap2: {},
- description: "",
- timeList1: [],
- timeList2: [],
- nowYear: '',
- title:"",
- }
- },
- onLoad(op) {
- this.meterNo = op.id
- //this.type=op.type
- //this.typeName=op.typeName
- this.title=op.title
- this.nowDate = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
- this.queryDate = parseUnixTime(beforeTimeStamp(0), '{y}-{m}-{d}');
- this.queryDateStr = parseUnixTime(new Date(this.queryDate), '{y}年{m}月{d}日');
-
- this.nowYear = new Date().getFullYear()
- this.showlist1 = [this.nowYear, this.nowYear - 1];
- this.electricityMonthTB()
- this.electricityHourByYear()
- },
- methods: {
- selector2reset(e){
- this.queryDate = parseUnixTime(beforeTimeStamp(0), '{y}-{m}-{d}');
- this.queryDateStr = parseUnixTime(new Date(this.queryDate), '{y}年{m}月{d}日');
- this.electricityHourByYear()
- },
- selector2confirm(e){
- this.queryDate=e.year+"-"+e.month+'-'+e.day
- this.queryDateStr = parseUnixTime(new Date(this.queryDate), '{y}年{m}月{d}日');
-
- this.electricityHourByYear()
- },
-
- electricityMonthTB() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.electricityMonthTB({
- queryDate: this.queryDate,
- meterId: this.meterNo,
- }).then(response => {
- uni.hideLoading();
- this.description = response.data.description;
- this.graphMap = response.data.graphMap
- this.setMap1();
-
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- electricityHourByYear() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.electricityHourByYear({
- queryDate: this.queryDate,
- meterId: this.meterNo,
- }).then(response => {
- uni.hideLoading();
- this.graphMap2 = response.data.graphMap
- this.setMap2();
- }).catch(error => {
- uni.hideLoading();
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- setMap2() {
- this.timeList2 = [];
- for (var i in this.graphMap2) {
- this.timeList2.push(parseInt(i) + '时')
- }
- var list1 = [];
- var list2 = [];
- // var list= this.setSz2(this.graphMap2,'bar')
- // this.echarts2('kwPicture2',list);
- var list = this.setSz(this.graphMap2, 'line')
- this.echarts1('barEcharts2', list, this.timeList2);
- },
- setMap1() {
- for (var i in this.graphMap) {
- this.timeList1.push(parseInt(i) + 1 + '月')
- }
- var list1 = [];
- var list2 = [];
- var list = this.setSz(this.graphMap, 'line')
- console.log(list)
- this.echarts1('barEcharts1', list, this.timeList1);
- },
- setSz(energyCenterMapObj, type) {
- var ap = {
- name: this.nowYear,
- type: type,
- symbol: 'circle',
- // sampling: 'lttb',
- data: []
- }
- var ap2 = {
- name: this.nowYear - 1,
- type: type,
- symbol: 'circle',
- // sampling: 'lttb',
- data: []
- }
- for (var i in energyCenterMapObj) {
- var sz = energyCenterMapObj[i];
- ap.data.push((sz[0]))
- ap2.data.push((sz[1]))
- }
- return [ap, ap2]
- },
- setSz2(energyCenterMapObj, type) {
- var returnsz = [];
- for (var i in energyCenterMapObj) {
- var sz = energyCenterMapObj[i];
- //var obj=[i+'时',sz[0].toFixed(0),sz[1].toFixed(0)]
- var obj = [i + '时', parseInt(sz[0]), parseInt(sz[1]), parseInt(sz[2])]
- returnsz.push(obj)
- }
- return returnsz;
- },
- echarts1(className, seriesdata, timeList) {
- var colorName = "#333"
- var myChart = echarts.init(document.getElementById(className), 'light');
- myChart.clear()
- var option = {
- tooltip: {
- trigger: 'axis',
- borderColor: "#F0F0F0",
- borderWidth: 1,
- backgroundColor: "#ffffff",
- textStyle: {
- color: "#333"
- }
- },
- legend: {
- data: [this.nowYear + '', this.nowYear - 1 + '', ],
- textStyle: {
- color: colorName
- }
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '5%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: timeList,
- axisLabel: {
- textStyle: {
- color: colorName
- }
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: colorName
- }
- },
- },
- yAxis: {
- type: 'value',
- axisLabel: {
- textStyle: {
- color: colorName
- }
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: colorName
- }
- },
- },
- // dataZoom: [{
- // type: 'inside',
- // start: 0,
- // end: 100
- // },
- // {
- // start: 0,
- // end: 100
- // }
- // ],
- series: seriesdata
- };
- myChart.setOption(option);
- },
- echarts2(className, seriesdata) {
- var colorName = "#333"
- var myChart = echarts.init(document.getElementById(className), 'light');
- myChart.clear()
- var option = {
- dataset: {
- source: [
- ['product', this.nowYear + '', this.nowYear - 1 + '', ],
- ...seriesdata
- ]
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '15%',
- containLabel: true
- },
- legend: {
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- xAxis: {
- type: 'category',
- },
- yAxis: {
- },
- // dataZoom: [{
- // type: 'inside',
- // start: 0,
- // end: 100
- // },
- // {
- // start: 0,
- // end: 100
- // }
- // ],
- series: [{
- type: 'bar'
- }, {
- type: 'bar'
- }]
- };
- myChart.setOption(option);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- // page {
- // background-color: #fff;
- // }
- .slot {
- display: flex;
- align-items: center;
- .img {
- width: 48rpx;
- height: 48rpx;
- margin-right: 4rpx;
- }
- }
- .main {
- background-color: #fff;
- padding: 32rpx;
- margin-bottom: 30rpx;
- .title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .icon {
- width: 8rpx;
- height: 32rpx;
- margin-right: 8rpx;
- background-color: rgba(22, 119, 255, 1);
- }
-
- .text {
- display: flex;
- align-items: center;
- color: rgb(16, 16, 16);
- font-size: 36rpx;
- margin-left: 12rpx;
- font-weight: bold;
- }
- }
- .chat {
- width: 100%;
- //height: 480rpx;
- margin-top: 32rpx;
- .img {
- width: 100%;
- height: 100%;
- }
- }
- // 表格
- .table {
- margin-top: 60rpx;
- border-radius: 8px;
- z-index: 999;
- table {
- background-color: #f1f2f5;
- color: #101010;
- padding: 20rpx 10rpx;
- width: 100%;
- td {
- text-align: right;
- }
- }
- }
- }
- </style>
|