index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!--
  2. * @Author: WangQiBiao
  3. * @Date: 2019-09-26 10:57:30
  4. * @LastEditors: mozhuangru
  5. * @LastEditTime: 2019-10-13 16:02:12
  6. * @Description: 收入统计
  7. -->
  8. <template>
  9. <div class="income">
  10. <div class="panel b1">
  11. <div class="panel-icon"></div>
  12. <div class="panel-txt">应收</div>
  13. <div class="panel-desc">¥{{billSum.billReceivable | moneyFormat}}</div>
  14. </div>
  15. <div class="panel b2">
  16. <div class="panel-icon"></div>
  17. <div class="panel-txt">实收</div>
  18. <div class="panel-desc">¥{{billSum.billReceived | moneyFormat}}</div>
  19. </div>
  20. <div class="map" id="mapId"></div>
  21. <div class="progress">
  22. <div class="desc">
  23. <div class="desc-lf">收费率</div>
  24. <div class="desc-lr">{{billSum.billRate}}%</div>
  25. </div>
  26. <el-progress
  27. :percentage="percentage"
  28. :show-text="false"
  29. color="#2FCD76"
  30. :stroke-width="8"
  31. ></el-progress>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import echarts from 'echarts'
  37. import { api } from '@/api'
  38. export default {
  39. data () {
  40. return {
  41. billSum: {
  42. billReceivable: '',
  43. billReceived: '',
  44. billOnline: '',
  45. billUnderline: '',
  46. billRate: ''
  47. },
  48. percentage: 98.4
  49. }
  50. },
  51. mounted () {
  52. api.getBillSum().then(res => {
  53. res.data.data.forEach(item => {
  54. this.billSum[item.type] = item.total
  55. if (item.type === 'billRate') {
  56. this.percentage = JSON.parse(item.total)
  57. }
  58. })
  59. this.createIncomeMap()
  60. })
  61. },
  62. methods: {
  63. /**
  64. * 占比
  65. */
  66. createIncomeMap () {
  67. var myChart = echarts.init(document.getElementById('mapId'))
  68. var option = {
  69. // backgroundColor: '#2c343c',
  70. series: [
  71. {
  72. radius: ['40%', '60%'],
  73. hoverAnimation: false,
  74. type: 'pie',
  75. center: ['50%', '50%'],
  76. label: {
  77. normal: {
  78. // formatter: '{b|{b}}\n{c}',
  79. formatter: '{b|{b}}\n{per|{d}%}',
  80. fontSize: 10,
  81. lineHeight: 14,
  82. rich: {
  83. b: {
  84. color: '#fff',
  85. fontSize: 10
  86. }
  87. }
  88. }
  89. },
  90. data: [
  91. {
  92. value: this.billSum.billOnline,
  93. name: '线上',
  94. label: {
  95. show: true,
  96. color: '#FF9933'
  97. },
  98. itemStyle: {
  99. color: new echarts.graphic.LinearGradient(
  100. 0, 0, 0, 1,
  101. [
  102. { offset: 0, color: '#FCC204' },
  103. { offset: 1, color: '#EF6E18' }
  104. ]
  105. )
  106. }
  107. },
  108. {
  109. value: this.billSum.billUnderline,
  110. name: '线下',
  111. label: {
  112. show: true,
  113. color: '#00CCFF'
  114. },
  115. itemStyle: {
  116. color: new echarts.graphic.LinearGradient(
  117. 0, 0, 0, 1,
  118. [
  119. { offset: 0, color: '#01B4FF' },
  120. { offset: 1, color: '#0336FF' }
  121. ]
  122. )
  123. }
  124. }
  125. ]
  126. }
  127. ]
  128. }
  129. myChart.setOption(option)
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. @import './index.scss';
  136. </style>