12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <!-- 营收分析 -->
- <template>
- <view class="revenue">
- <template v-if="type === 'line'">
- <view class="revenue-line">
- <LineChart :chartData="chartData" :title="title"/>
- </view>
- </template>
- <template v-else>
- <view class="revenue-line">
- <ColumnChart :chartData="chartData" :title="title"/>
- </view>
- </template>
- </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: [{
- name: '',
- data: []
- }]
- }
- }
- },
- methods: {
- /**
- * 获取数据
- */
- getData({ reportType, queryDate }) {
- uni.$u.api.operationalAnalysisApi.getRevenueDataApi({ 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[0].data = res.data.itemList.map(item => {
- return item.amt
- })
- } else {
- this.chartData.categories = []
- this.chartData.series[0].data = []
- }
- }
- })
- }
- }
- }
- </script>
|