|
|
@@ -7,6 +7,7 @@
|
|
|
:points="points"
|
|
|
@point-change="onPointChange"
|
|
|
@standard-change="standards = $event"
|
|
|
+ :fetching-point="dataLoading.base"
|
|
|
/>
|
|
|
</template>
|
|
|
<div class="content">
|
|
|
@@ -17,9 +18,9 @@
|
|
|
<span>监测天数:{{ baseData.days || '-' }}天</span>
|
|
|
<span>数据事件:{{ getIntervalValue(baseData.beginDate, baseData.endDate, '-') }} </span>
|
|
|
</el-row>
|
|
|
- <el-row>
|
|
|
+ <el-row :gutter="15">
|
|
|
<el-col :span="12">
|
|
|
- <QuerySummary :info="baseData" :siteId="query.siteId" @refresh="fetchBaseData" />
|
|
|
+ <QuerySummary :info="baseData" :siteId="query.siteId" @refresh="fetchBaseData" v-loading="dataLoading.base" />
|
|
|
</el-col>
|
|
|
<el-col :span="12" style="margin-top: 1em">
|
|
|
<el-row :gutter="15">
|
|
|
@@ -62,7 +63,7 @@
|
|
|
<tf-title slot="title">
|
|
|
<el-row type="flex" align="middle">
|
|
|
<span style="margin-right: 3em">按天统计</span>
|
|
|
- <el-radio-group v-model="day.type" size="small">
|
|
|
+ <el-radio-group v-model="day.type" size="small" @change="onDayTypeChange">
|
|
|
<el-radio label="day">近30天</el-radio>
|
|
|
<el-radio label="custom">自定义时间</el-radio>
|
|
|
</el-radio-group>
|
|
|
@@ -77,6 +78,8 @@
|
|
|
size="small"
|
|
|
value-format="yyyy-MM-dd"
|
|
|
style="margin-left: 2em; width: 250px"
|
|
|
+ :disabled="day.type === 'day'"
|
|
|
+ @change="onDayChange"
|
|
|
/>
|
|
|
</el-row>
|
|
|
</tf-title>
|
|
|
@@ -85,7 +88,7 @@
|
|
|
<tf-title slot="title">
|
|
|
<el-row type="flex" align="middle">
|
|
|
<span style="margin-right: 3em">按小时统计</span>
|
|
|
- <el-radio-group v-model="hour.type" size="small">
|
|
|
+ <el-radio-group v-model="hour.type" size="small" @change="onHourTypeChange">
|
|
|
<el-radio label="hour">近24小时</el-radio>
|
|
|
<el-radio label="custom">自定义时间</el-radio>
|
|
|
</el-radio-group>
|
|
|
@@ -100,6 +103,8 @@
|
|
|
size="small"
|
|
|
value-format="yyyy-MM-dd"
|
|
|
style="margin-left: 2em; width: 250px"
|
|
|
+ :disabled="hour.type === 'hour'"
|
|
|
+ @change="onHourChange"
|
|
|
/>
|
|
|
</el-row>
|
|
|
</tf-title>
|
|
|
@@ -121,6 +126,11 @@
|
|
|
import { pointPage } from '../../configuration/api/point'
|
|
|
import { fetchData, fetchDayData, fetchBaseData, fetchHourData, IQueryParam } from '../api/statistics'
|
|
|
import { IStatisticsBase, IStatisticsData, IStatisticsDayNHour } from '../api/common'
|
|
|
+ import moment from 'moment'
|
|
|
+
|
|
|
+ const format = 'YYYY-MM-DD'
|
|
|
+ const get30Days = () => [moment().add(-1, 'month').format(format), moment().format(format)]
|
|
|
+ const get24Hours = () => [moment().add(-1, 'day').format(format), moment().format(format)]
|
|
|
|
|
|
@Component({ name: 'Statistics', components: { QueryForm, ChartItem, QuerySummary, DayAndHourChart } })
|
|
|
export default class Statistics extends Vue {
|
|
|
@@ -142,14 +152,18 @@
|
|
|
point: Partial<IPoint> = {}
|
|
|
|
|
|
query: Partial<IQueryParam> = {}
|
|
|
- day = { type: 'day', datetime: [this.$moment().toDate(), this.$moment().add(-1, 'month').toDate()] }
|
|
|
- hour = { type: 'hour', datetime: [this.$moment().toDate(), this.$moment().add(-24, 'hour').toDate()] }
|
|
|
+ day = { type: 'day', datetime: get30Days() }
|
|
|
+ hour = { type: 'hour', datetime: get24Hours() }
|
|
|
|
|
|
- data: Partial<IStatisticsData> = {}
|
|
|
+ data: Partial<IStatisticsData>[] = []
|
|
|
baseData: Partial<IStatisticsBase> = {}
|
|
|
dayData: Partial<IStatisticsDayNHour> = {}
|
|
|
hourData: Partial<IStatisticsDayNHour> = {}
|
|
|
|
|
|
+ get isReady() {
|
|
|
+ return !!this.query.siteId && !!this.query.checkCode && this.query.checkCode.length > 0
|
|
|
+ }
|
|
|
+
|
|
|
onQuery(query: Partial<IQueryParam>) {
|
|
|
this.query = { ...query }
|
|
|
this.baseData = {}
|
|
|
@@ -181,7 +195,8 @@
|
|
|
async fetchDayData() {
|
|
|
this.dataLoading.day = true
|
|
|
try {
|
|
|
- const { result: dayData } = await fetchDayData(this.query)
|
|
|
+ const [beginDate, endDate] = this.day.datetime || []
|
|
|
+ const { result: dayData } = await fetchDayData({ ...this.query, beginDate, endDate })
|
|
|
this.dayData = dayData
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
@@ -191,7 +206,8 @@
|
|
|
async fetchHourData() {
|
|
|
this.dataLoading.hour = true
|
|
|
try {
|
|
|
- const { result: hourData } = await fetchHourData(this.query)
|
|
|
+ const [beginDate, endDate] = this.hour.datetime || []
|
|
|
+ const { result: hourData } = await fetchHourData({ ...this.query, beginDate, endDate })
|
|
|
this.hourData = hourData
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
@@ -225,6 +241,21 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ onDayTypeChange(type) {
|
|
|
+ if (type === 'day') this.day.datetime = get30Days()
|
|
|
+ if (this.isReady) this.fetchDayData()
|
|
|
+ }
|
|
|
+ onDayChange() {
|
|
|
+ if (this.isReady) this.fetchDayData()
|
|
|
+ }
|
|
|
+ onHourTypeChange(type) {
|
|
|
+ if (type === 'hour') this.hour.datetime = get24Hours()
|
|
|
+ if (this.isReady) this.fetchHourData()
|
|
|
+ }
|
|
|
+ onHourChange() {
|
|
|
+ if (this.isReady) this.fetchHourData()
|
|
|
+ }
|
|
|
+
|
|
|
preparing() {
|
|
|
this.getAllPoints()
|
|
|
}
|