revenueAnalysis.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. xAxis: {
  61. rotateLabel: false,
  62. labelCount: 6
  63. },
  64. yAxis: {
  65. showTitle: true,
  66. splitNumber: 5,
  67. data: [{
  68. title: '收益(元)',
  69. titleOffsetY: -5
  70. }]
  71. },
  72. legend: {
  73. show: true
  74. },
  75. dataLabel: false,
  76. extra: {
  77. column: {
  78. width: 20
  79. }
  80. }
  81. }
  82. }
  83. },
  84. methods: {
  85. /**
  86. * 获取数据
  87. */
  88. getData({
  89. reportType,
  90. queryDate
  91. }) {
  92. this.loading = true
  93. this.chartData.categories = []
  94. this.chartData.series[0].data = []
  95. this.chartData.series[1].data = []
  96. // 路段数据
  97. uni.$u.api.operationalAnalysisApi.getRevenueDataApi({
  98. reportType,
  99. queryDate
  100. }).then(res => {
  101. if (res.code === 200) {
  102. if (res.data.itemList && res.data.itemList.length) {
  103. this.chartData.categories = res.data.itemList.map(item => {
  104. return item.statisTime
  105. })
  106. this.chartData.series[0].data = res.data.itemList.map(item => {
  107. return item.amt
  108. })
  109. }
  110. }
  111. this.loading = false
  112. })
  113. // 停车场数据
  114. uni.$u.api.operationalAnalysisApi.getParkingRevenueDataApi({
  115. reportType,
  116. queryDate
  117. }).then(res => {
  118. if (res.code === 200) {
  119. if (res.data.itemList && res.data.itemList.length) {
  120. this.chartData.categories = res.data.itemList.map(item => {
  121. return item.statisTime
  122. })
  123. this.chartData.series[1].data = res.data.itemList.map(item => {
  124. return item.amt
  125. })
  126. }
  127. }
  128. this.loading = false
  129. })
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .revenue {
  136. background-color: #fff;
  137. border-radius: 5px;
  138. .empty {
  139. padding: 15px;
  140. }
  141. }
  142. </style>