revenueAnalysis.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!-- 营收分析 -->
  2. <template>
  3. <view class="revenue">
  4. <template v-if="type === 'line'">
  5. <view class="revenue-line">
  6. <LineChart v-if="chartData.series[0].data.length || chartData.series[1].data.length"
  7. :chartData="chartData" :title="title" :opts="opts" />
  8. <view class="empty" v-else>
  9. <u-empty></u-empty>
  10. </view>
  11. </view>
  12. </template>
  13. <template v-else>
  14. <view class="revenue-line">
  15. <ColumnChart v-if="chartData.series[0].data.length || chartData.series[1].data.length"
  16. :chartData="chartData" :title="title" :opts="opts" />
  17. <view class="empty" v-else>
  18. <u-empty></u-empty>
  19. </view>
  20. </view>
  21. </template>
  22. </view>
  23. </template>
  24. <script>
  25. import LineChart from '@/components/lineChart.vue'
  26. import ColumnChart from '@/components/columnChart.vue'
  27. export default {
  28. components: {
  29. LineChart,
  30. ColumnChart
  31. },
  32. props: {
  33. type: {
  34. type: String,
  35. default: 'line'
  36. },
  37. title: {
  38. type: String,
  39. default: ''
  40. },
  41. params: {
  42. type: Object,
  43. default: () => {}
  44. }
  45. },
  46. data() {
  47. return {
  48. chartData: {
  49. categories: [],
  50. series: [{
  51. name: '路段',
  52. data: []
  53. }, {
  54. name: '停车场',
  55. data: []
  56. }]
  57. },
  58. loading: false,
  59. opts: {
  60. enableScroll: true,
  61. xAxis: {
  62. rotateLabel: true,
  63. scrollShow: true,
  64. itemCount: 8
  65. },
  66. yAxis: {
  67. showTitle: true,
  68. splitNumber: 5,
  69. data: [{
  70. title: '收益(元)',
  71. titleOffsetY: -3
  72. }]
  73. },
  74. legend: {
  75. show: false
  76. },
  77. dataLabel: false,
  78. padding: [10, 0, 10, 0],
  79. extra: {
  80. column: {
  81. width: 20
  82. }
  83. }
  84. }
  85. }
  86. },
  87. methods: {
  88. /**
  89. * 获取数据
  90. */
  91. getData({
  92. reportType,
  93. queryDate
  94. }) {
  95. this.loading = true
  96. this.chartData.categories = []
  97. this.chartData.series[0].data = []
  98. this.chartData.series[1].data = []
  99. // 路段数据
  100. uni.$u.api.operationalAnalysisApi.getRevenueDataApi({
  101. reportType,
  102. queryDate
  103. }).then(res => {
  104. if (res.code === 200) {
  105. if (res.data.itemList && res.data.itemList.length) {
  106. this.chartData.categories = res.data.itemList.map(item => {
  107. return item.statisTime
  108. })
  109. this.chartData.series[0].data = res.data.itemList.map(item => {
  110. return item.amt
  111. })
  112. }
  113. }
  114. this.loading = false
  115. })
  116. // 停车场数据
  117. uni.$u.api.operationalAnalysisApi.getParkingRevenueDataApi({
  118. reportType,
  119. queryDate
  120. }).then(res => {
  121. if (res.code === 200) {
  122. if (res.data.itemList && res.data.itemList.length) {
  123. this.chartData.categories = res.data.itemList.map(item => {
  124. return item.statisTime
  125. })
  126. this.chartData.series[1].data = res.data.itemList.map(item => {
  127. return item.amt
  128. })
  129. }
  130. }
  131. this.loading = false
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss" scoped>
  138. .revenue {
  139. background-color: #fff;
  140. border-radius: 5px;
  141. .empty {
  142. padding: 15px;
  143. }
  144. }
  145. </style>