| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 | 
<template>	<view class="revenue">		<template v-if="type === 'line'">			<view class="revenue-line">				<LineChart v-if="hasData"					:chartData="chartData" :title="title" :opts="opts" />				<view class="empty" v-else>					<u-empty></u-empty>				</view>			</view>		</template>		<template v-else>			<view class="revenue-line">				<ColumnChart v-if="hasData"					:chartData="chartData" :title="title" :opts="opts" />				<view class="empty" v-else>					<u-empty></u-empty>				</view>			</view>		</template>		<u-loading-page :loading="loading" loading-text="loading..."></u-loading-page>	</view></template><script>	import LineChart from '@/components/lineChart.vue'	import ColumnChart from '@/components/columnChart.vue'	export default {		components: {			LineChart,			ColumnChart		},		props: {			type: {				type: String,				default: 'line'			},			title: {				type: String,				default: ''			},			params: {				type: Object,				default: () => {}			}		},		data() {			return {				chartData: {					categories: [],					series: []				},				hasData: false,				loading: false,				opts: {					enableScroll: true,					tooltip: {						trigger: 'axis'					},					xAxis: {						rotateLabel: true,						scrollShow: true,						itemCount: 8					},					yAxis: {						showTitle: true,						splitNumber: 5,						data: [{							title: '收益(元)',							titleOffsetY: -3						}]					},					legend: {						show: true					},					dataLabel: false,					padding: [20, 10, 10, 10],					extra: {						column: {							width: 20						}					}				}			}		},		methods: {						getData({				reportType,				queryDate			}) {				this.hasData = false				this.chartData.categories = []				this.chartData.series = []				this.getRoadData({ reportType, queryDate })			},						getRoadData({ reportType, queryDate }) {				this.loading = true				uni.$u.api.operationalAnalysisApi.getRevenueDataApi({					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							})							this.chartData.series[0].data = res.data.itemList.map(item => {								return item.amt							})						}						if (this.chartData.series.length && this.chartData.series[0].data.length) {							this.hasData = true						} else {							this.hasData = false						}						this.loading = false					}				})			}		}	}</script><style lang="scss" scoped>	.revenue {		background-color: #fff;		border-radius: 5px;		.empty {			padding: 15px;		}	}</style>
 |