sourceOfPayment.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!-- 支付来源分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart v-if="chartData.series[0].data.length || chartData.series[1].data.length" :chartData="chartData" :title="title" :opts="opts"/>
  6. <view class="empty" v-else>
  7. <u-empty></u-empty>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import LineChart from '@/components/lineChart.vue'
  14. export default {
  15. components: {
  16. LineChart
  17. },
  18. props: {
  19. title: {
  20. type: String,
  21. default: ''
  22. },
  23. opts: {
  24. type: Object,
  25. default: () => {
  26. return {
  27. xAxis: {
  28. rotateLabel: true
  29. },
  30. yAxis: {
  31. showTitle: true,
  32. splitNumber: 5,
  33. data: [{
  34. title: '元',
  35. titleOffsetY: -5
  36. }]
  37. },
  38. legend: {
  39. show: true
  40. },
  41. dataLabel: false,
  42. extra: {
  43. column: {
  44. width: 20
  45. }
  46. }
  47. }
  48. }
  49. }
  50. },
  51. data() {
  52. return {
  53. paySourceList: [],
  54. chartData: {
  55. categories: [],
  56. series: [{
  57. name: '路段',
  58. data: []
  59. }, {
  60. name: '停车场',
  61. data: []
  62. }]
  63. },
  64. reportType: '',
  65. queryDate: ''
  66. }
  67. },
  68. created() {
  69. this.getDict()
  70. },
  71. methods: {
  72. getData({ reportType, queryDate }) {
  73. this.reportType = reportType
  74. this.queryDate = queryDate
  75. this.getPaySourceData()
  76. },
  77. getDict() {
  78. uni.$u.api.getDictApi({ type: 'pay_platform' }).then(res => {
  79. if (res.code === 200) {
  80. this.paySourceList = res.data
  81. }
  82. })
  83. },
  84. getPaySourceData() {
  85. this.chartData.categories = []
  86. this.chartData.series[0].data = []
  87. this.chartData.series[1].data = []
  88. uni.$u.api.operationalAnalysisApi.getPaySourceDataApi({
  89. reportType: this.reportType,
  90. queryDate: this.queryDate
  91. }).then(res => {
  92. if (res.code === 200) {
  93. if (res.data.itemList && res.data.itemList.length) {
  94. let cateList = []
  95. res.data.itemList.forEach(item => {
  96. cateList.push(this.getDictLabel(item.payPlatform))
  97. })
  98. this.chartData.categories = cateList
  99. this.chartData.series[0].data = res.data.itemList.map(item => {
  100. return item.amt
  101. })
  102. }
  103. }
  104. })
  105. uni.$u.api.operationalAnalysisApi.getParkingPaySourceDataApi({
  106. reportType: this.reportType,
  107. queryDate: this.queryDate
  108. }).then(res => {
  109. if (res.code === 200) {
  110. if (res.data.itemList && res.data.itemList.length) {
  111. let cateList = []
  112. res.data.itemList.forEach(item => {
  113. cateList.push(this.getDictLabel(item.payPlatform))
  114. })
  115. this.chartData.categories = cateList
  116. this.chartData.series[1].data = res.data.itemList.map(item => {
  117. return item.amt
  118. })
  119. }
  120. }
  121. })
  122. },
  123. getDictLabel(value) {
  124. let name
  125. this.paySourceList.forEach(item => {
  126. if (item.dictValue == value) {
  127. name = item.dictLabel
  128. }
  129. })
  130. if (!name) name = '其他'
  131. return name
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .revenue {
  138. background-color: #fff;
  139. border-radius: 5px;
  140. .empty {
  141. padding: 15px;
  142. }
  143. }
  144. </style>