revenueAnalysis.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <!-- 营收分析 -->
  2. <template>
  3. <view class="revenue">
  4. <template v-if="type === 'line'">
  5. <view class="revenue-line">
  6. <LineChart :chartData="chartData" :title="title"/>
  7. </view>
  8. </template>
  9. <template v-else>
  10. <view class="revenue-line">
  11. <ColumnChart :chartData="chartData" :title="title"/>
  12. </view>
  13. </template>
  14. </view>
  15. </template>
  16. <script>
  17. import LineChart from '@/components/lineChart.vue'
  18. import ColumnChart from '@/components/columnChart.vue'
  19. export default {
  20. components: {
  21. LineChart,
  22. ColumnChart
  23. },
  24. props: {
  25. type: {
  26. type: String,
  27. default: 'line'
  28. },
  29. title: {
  30. type: String,
  31. default: ''
  32. },
  33. params: {
  34. type: Object,
  35. default: () => {}
  36. }
  37. },
  38. data() {
  39. return {
  40. chartData: {
  41. categories: [],
  42. series: [{
  43. name: '',
  44. data: []
  45. }]
  46. }
  47. }
  48. },
  49. methods: {
  50. /**
  51. * 获取数据
  52. */
  53. getData({ reportType, queryDate }) {
  54. uni.$u.api.operationalAnalysisApi.getRevenueDataApi({ reportType, queryDate }).then(res => {
  55. if (res.code === 200) {
  56. if (res.data.itemList && res.data.itemList.length) {
  57. this.chartData.categories = res.data.itemList.map(item => {
  58. return item.statisTime
  59. })
  60. this.chartData.series[0].data = res.data.itemList.map(item => {
  61. return item.amt
  62. })
  63. } else {
  64. this.chartData.categories = []
  65. this.chartData.series[0].data = []
  66. }
  67. }
  68. })
  69. }
  70. }
  71. }
  72. </script>