设备监控使用统一的时间选择组件、文案更新
This commit is contained in:
@ -1,31 +1,10 @@
|
||||
<template>
|
||||
<el-card shadow="always" class="common-card-container" style="margin-top:20px">
|
||||
<div slot="header">
|
||||
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px">
|
||||
<div slot="header" class="time-range-header">
|
||||
<span class="card-title">电量指标</span>
|
||||
<date-range-select ref="dateRangeSelect" @updateDate="updateDate"/>
|
||||
</div>
|
||||
<div class="card-main" v-loading="loading">
|
||||
<!-- 搜索栏-->
|
||||
<div class="select-container">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="时间选择">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
:picker-options="pickerOptions"
|
||||
:default-value="defaultDateRange"
|
||||
end-placeholder="结束时间">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getData" native-type="button">搜索</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="onReset" native-type="button">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="total-data">
|
||||
<div>总充电量:<span class="point">{{totalChargedCap | formatNumber}}kWh</span></div>
|
||||
<div>总放电量:<span class="point">{{totalDisChargedCap | formatNumber}}kWh</span></div>
|
||||
@ -42,7 +21,9 @@ import resize from "@/mixins/ems/resize";
|
||||
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
|
||||
import {getElectricData} from '@/api/ems/dzjk'
|
||||
import {formatDate} from '@/filters/ems'
|
||||
import DateRangeSelect from '@/components/Ems/DateRangeSelect/index.vue'
|
||||
export default {
|
||||
components: {DateRangeSelect},
|
||||
mixins: [resize,getQuerySiteId],
|
||||
data() {
|
||||
return {
|
||||
@ -51,7 +32,6 @@ export default {
|
||||
return time.getTime() > Date.now();
|
||||
},
|
||||
},
|
||||
defaultDateRange:[],//默认展示的时间
|
||||
dateRange:[],
|
||||
loading:false,
|
||||
chart: null,
|
||||
@ -61,9 +41,9 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 重置
|
||||
onReset(){
|
||||
this.dateRange=[]
|
||||
// 更新时间范围 重置图表
|
||||
updateDate(data){
|
||||
this.dateRange=data || []
|
||||
this.getData()
|
||||
},
|
||||
setOption(data,unit){
|
||||
@ -80,7 +60,12 @@ export default {
|
||||
top:40,
|
||||
containLabel: true
|
||||
},
|
||||
tooltip: {},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
||||
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
||||
}
|
||||
},
|
||||
xAxis: [{
|
||||
type: 'category',
|
||||
name:`单位:${unit}`,
|
||||
@ -145,15 +130,13 @@ export default {
|
||||
})
|
||||
},
|
||||
init(){
|
||||
this.chart = echarts.init(document.querySelector('#dlzbChart'));
|
||||
this.onReset()
|
||||
this.$nextTick(()=>{
|
||||
this.chart = echarts.init(document.querySelector('#dlzbChart'));
|
||||
this.$refs.dateRangeSelect.init()
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
const now = new Date();
|
||||
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
||||
this.defaultDateRange = [lastMonth, now];
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (!this.chart) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user