sourceOfPayment.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!-- 支付来源分析 -->
  2. <template>
  3. <view class="revenue">
  4. <view class="revenue-line">
  5. <LineChart v-if="hasData" :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. },
  58. hasData: false
  59. }
  60. },
  61. created() {
  62. this.getDict()
  63. },
  64. methods: {
  65. getData({
  66. reportType,
  67. queryDate
  68. }) {
  69. this.hasData = false
  70. this.chartData.categories = []
  71. this.chartData.series = []
  72. this.getPaySourceData({
  73. reportType,
  74. queryDate
  75. })
  76. },
  77. getDict() {
  78. uni.$u.api.getDictApi({
  79. type: 'pay_platform'
  80. }).then(res => {
  81. if (res.code === 200) {
  82. this.paySourceList = res.data
  83. }
  84. })
  85. },
  86. getPaySourceData({
  87. reportType,
  88. queryDate
  89. }) {
  90. uni.$u.api.operationalAnalysisApi.getPaySourceDataApi({
  91. reportType,
  92. queryDate
  93. }).then(res => {
  94. if (res.code === 200) {
  95. if (res.data.itemList && res.data.itemList.length) {
  96. this.chartData.series[0] = {
  97. name: '路段',
  98. data: []
  99. }
  100. let cateList = []
  101. res.data.itemList.forEach(item => {
  102. cateList.push(this.getDictLabel(item.payPlatform))
  103. })
  104. this.chartData.categories = cateList
  105. this.chartData.series[0].data = res.data.itemList.map(item => {
  106. return item.amt
  107. })
  108. }
  109. this.getParkingData({ reportType, queryDate })
  110. }
  111. })
  112. },
  113. getParkingData({
  114. reportType,
  115. queryDate
  116. }) {
  117. uni.$u.api.operationalAnalysisApi.getParkingPaySourceDataApi({
  118. reportType,
  119. queryDate
  120. }).then(res => {
  121. if (res.code === 200) {
  122. if (res.data.itemList && res.data.itemList.length) {
  123. if (this.chartData.series.length) {
  124. this.chartData.series[1] = {
  125. name: '停车场',
  126. data: []
  127. }
  128. this.chartData.series[1].data = res.data.itemList.map(item => {
  129. return item.amt
  130. })
  131. } else {
  132. this.chartData.series[0] = {
  133. name: '停车场',
  134. data: []
  135. }
  136. this.chartData.series[0].data = res.data.itemList.map(item => {
  137. return item.amt
  138. })
  139. }
  140. if (!this.chartData.categories.length) {
  141. let cateList = []
  142. res.data.itemList.forEach(item => {
  143. cateList.push(this.getDictLabel(item.payPlatform))
  144. })
  145. this.chartData.categories = cateList
  146. }
  147. this.hasData = true
  148. } else if (this.chartData.series.length === 1) {
  149. this.hasData = true
  150. } else if (!this.chartData.series.length) {
  151. this.hasData = false
  152. }
  153. }
  154. })
  155. },
  156. getDictLabel(value) {
  157. let name
  158. this.paySourceList.forEach(item => {
  159. if (item.dictValue == value) {
  160. name = item.dictLabel
  161. }
  162. })
  163. if (!name) name = '其他'
  164. return name
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .revenue {
  171. background-color: #fff;
  172. border-radius: 5px;
  173. .empty {
  174. padding: 15px;
  175. }
  176. }
  177. </style>