revenueAnalysis.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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="chartData" :title="title"/>
  7. <view class="empty" v-else>
  8. <u-empty></u-empty>
  9. </view>
  10. </view>
  11. </template>
  12. <template v-else>
  13. <view class="revenue-line">
  14. <ColumnChart v-if="chartData.series[0].data.length" :chartData="chartData" :title="title"/>
  15. <view class="empty" v-else>
  16. <u-empty></u-empty>
  17. </view>
  18. </view>
  19. </template>
  20. </view>
  21. </template>
  22. <script>
  23. import LineChart from '@/components/lineChart.vue'
  24. import ColumnChart from '@/components/columnChart.vue'
  25. export default {
  26. components: {
  27. LineChart,
  28. ColumnChart
  29. },
  30. props: {
  31. type: {
  32. type: String,
  33. default: 'line'
  34. },
  35. title: {
  36. type: String,
  37. default: ''
  38. },
  39. params: {
  40. type: Object,
  41. default: () => {}
  42. }
  43. },
  44. data() {
  45. return {
  46. chartData: {
  47. categories: [],
  48. series: [{
  49. name: '',
  50. data: []
  51. }]
  52. },
  53. loading: false
  54. }
  55. },
  56. methods: {
  57. /**
  58. * 获取数据
  59. */
  60. getData({ reportType, queryDate }) {
  61. this.loading = true
  62. uni.$u.api.operationalAnalysisApi.getRevenueDataApi({ reportType, queryDate }).then(res => {
  63. if (res.code === 200) {
  64. if (res.data.itemList && res.data.itemList.length) {
  65. this.chartData.categories = res.data.itemList.map(item => {
  66. return item.statisTime
  67. })
  68. this.chartData.series[0].data = res.data.itemList.map(item => {
  69. return item.amt
  70. })
  71. } else {
  72. this.chartData.categories = []
  73. this.chartData.series[0].data = []
  74. }
  75. }
  76. this.loading = false
  77. })
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. .revenue {
  84. background-color: #fff;
  85. border-radius: 5px;
  86. .empty {
  87. padding: 15px;
  88. }
  89. }
  90. </style>