revenueAnalysis.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. }
  54. },
  55. methods: {
  56. /**
  57. * 获取数据
  58. */
  59. getData({ reportType, queryDate }) {
  60. uni.$u.api.operationalAnalysisApi.getRevenueDataApi({ reportType, queryDate }).then(res => {
  61. if (res.code === 200) {
  62. if (res.data.itemList && res.data.itemList.length) {
  63. this.chartData.categories = res.data.itemList.map(item => {
  64. return item.statisTime
  65. })
  66. this.chartData.series[0].data = res.data.itemList.map(item => {
  67. return item.amt
  68. })
  69. } else {
  70. this.chartData.categories = []
  71. this.chartData.series[0].data = []
  72. }
  73. }
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .revenue {
  81. background-color: #fff;
  82. border-radius: 5px;
  83. .empty {
  84. padding: 15px;
  85. }
  86. }
  87. </style>