|
@@ -2,7 +2,7 @@
|
|
|
<template>
|
|
|
<view class="revenue">
|
|
|
<view class="revenue-line">
|
|
|
- <LineChart v-if="chartData.series[0].data.length || chartData.series[1].data.length" :chartData="chartData" :title="title" :opts="opts"/>
|
|
|
+ <LineChart v-if="hasData" :chartData="chartData" :title="title" :opts="opts" />
|
|
|
<view class="empty" v-else>
|
|
|
<u-empty></u-empty>
|
|
|
</view>
|
|
@@ -40,10 +40,10 @@
|
|
|
}]
|
|
|
},
|
|
|
legend: {
|
|
|
- show: false
|
|
|
+ show: true
|
|
|
},
|
|
|
dataLabel: false,
|
|
|
- padding: [10, 0, 10, 0],
|
|
|
+ padding: [10, 10, 10, 10],
|
|
|
extra: {
|
|
|
column: {
|
|
|
width: 20
|
|
@@ -57,24 +57,36 @@
|
|
|
return {
|
|
|
chartData: {
|
|
|
categories: [],
|
|
|
- series: [{
|
|
|
- name: '路段',
|
|
|
- data: []
|
|
|
- }, {
|
|
|
- name: '停车场',
|
|
|
- data: []
|
|
|
- }]
|
|
|
- }
|
|
|
+ series: []
|
|
|
+ },
|
|
|
+ reportType: '',
|
|
|
+ queryDate: '',
|
|
|
+ hasData: false
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- getData({ reportType, queryDate }) {
|
|
|
+ getData({
|
|
|
+ reportType,
|
|
|
+ queryDate
|
|
|
+ }) {
|
|
|
this.chartData.categories = []
|
|
|
- this.chartData.series[0].data = []
|
|
|
- this.chartData.series[1].data = []
|
|
|
- uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({ reportType, queryDate }).then(res => {
|
|
|
+ this.chartData.series = []
|
|
|
+ this.reportType = reportType
|
|
|
+ this.queryDate = queryDate
|
|
|
+ this.hasData = false;
|
|
|
+ this.getRoadData({ reportType, queryDate });
|
|
|
+ },
|
|
|
+ getRoadData({ reportType, queryDate }) {
|
|
|
+ uni.$u.api.operationalAnalysisApi.getTrafficFlowDataApi({
|
|
|
+ reportType,
|
|
|
+ queryDate
|
|
|
+ }).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
if (res.data.itemList && res.data.itemList.length) {
|
|
|
+ this.chartData.series[0] = {
|
|
|
+ name: '路段',
|
|
|
+ data: []
|
|
|
+ }
|
|
|
this.chartData.categories = res.data.itemList.map(item => {
|
|
|
return item.statisTime
|
|
|
})
|
|
@@ -83,16 +95,43 @@
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+ this.getParkingData({ reportType, queryDate });
|
|
|
})
|
|
|
- uni.$u.api.operationalAnalysisApi.getParkingTrafficFlowDataApi({ reportType, queryDate }).then(res => {
|
|
|
+ },
|
|
|
+ getParkingData({ reportType, queryDate }) {
|
|
|
+ uni.$u.api.operationalAnalysisApi.getParkingTrafficFlowDataApi({
|
|
|
+ reportType,
|
|
|
+ queryDate
|
|
|
+ }).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
if (res.data.itemList && res.data.itemList.length) {
|
|
|
- this.chartData.categories = res.data.itemList.map(item => {
|
|
|
- return item.statisTime
|
|
|
- })
|
|
|
- this.chartData.series[1].data = res.data.itemList.map(item => {
|
|
|
- return item.vehicleCount
|
|
|
- })
|
|
|
+ if (this.chartData.series.length) {
|
|
|
+ this.chartData.series[1] = {
|
|
|
+ name: '停车场',
|
|
|
+ data: []
|
|
|
+ }
|
|
|
+ this.chartData.series[1].data = res.data.itemList.map(item => {
|
|
|
+ return item.vehicleCount
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.chartData.series[0] = {
|
|
|
+ name: '停车场',
|
|
|
+ data: []
|
|
|
+ }
|
|
|
+ this.chartData.series[0].data = res.data.itemList.map(item => {
|
|
|
+ return item.vehicleCount
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (!this.chartData.categories.length) {
|
|
|
+ this.chartData.categories = res.data.itemList.map(item => {
|
|
|
+ return item.statisTime
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.hasData = true
|
|
|
+ } else if (this.chartData.series.length === 1) {
|
|
|
+ this.hasData = true
|
|
|
+ } else if (!this.chartData.series.length) {
|
|
|
+ this.hasData = false
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -105,6 +144,7 @@
|
|
|
.revenue {
|
|
|
background-color: #fff;
|
|
|
border-radius: 5px;
|
|
|
+
|
|
|
.empty {
|
|
|
padding: 15px;
|
|
|
}
|