tollCollectorPerformance.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!-- 收费员业绩 -->
  2. <template>
  3. <view class="performance">
  4. <template v-if="type === 'table'">
  5. <TableRanking :loading="loading" :title="title" :tableTh="tableTh" :tableData="tableData" @pageChange="pageChange"/>
  6. </template>
  7. <template v-else>
  8. <LineChart v-if="chartData.series[0].data.length" :chartData="chartData" :title="title" :opts="opts"/>
  9. <view class="empty" v-else>
  10. <u-empty></u-empty>
  11. </view>
  12. </template>
  13. </view>
  14. </template>
  15. <script>
  16. import TableRanking from '@/components/tableRanking.vue'
  17. import LineChart from '@/components/lineChart.vue'
  18. export default {
  19. components: {
  20. TableRanking,
  21. LineChart
  22. },
  23. props: {
  24. type: {
  25. type: String,
  26. default: 'table'
  27. },
  28. title: {
  29. type: String,
  30. default: ''
  31. },
  32. tableTh: {
  33. type: Array,
  34. default: () => [
  35. { width: 100, field: '工号', key: 'payeeNo' },
  36. { width: 100, field: '姓名', key: 'payeeName' },
  37. { width: 100, field: '收益(元)', key: 'amt' }
  38. ]
  39. },
  40. },
  41. data() {
  42. return {
  43. chartData: {
  44. categories: [],
  45. series: [{
  46. name: '',
  47. data: []
  48. }]
  49. },
  50. tableData: {
  51. current: 1,
  52. total: 0,
  53. list: []
  54. },
  55. reportType: '',
  56. queryDate: '',
  57. loading: false,
  58. opts: {
  59. enableScroll: true,
  60. xAxis: {
  61. rotateLabel: true,
  62. scrollShow: true,
  63. itemCount: 8
  64. },
  65. yAxis: {
  66. showTitle: true,
  67. splitNumber: 5,
  68. data: [{
  69. title: '元',
  70. titleOffsetY: -3
  71. }]
  72. },
  73. legend: {
  74. show: false
  75. },
  76. dataLabel: false,
  77. padding: [10, 0, 10, 0],
  78. extra: {
  79. column: {
  80. width: 20
  81. }
  82. }
  83. }
  84. }
  85. },
  86. methods: {
  87. getData({ reportType, queryDate }) {
  88. this.reportType = reportType
  89. this.queryDate = queryDate
  90. if (this.type === 'table') {
  91. this.tableData.current = 1
  92. this.getTableData()
  93. } else {
  94. this.getChartData()
  95. }
  96. },
  97. getTableData() {
  98. this.loading = true
  99. uni.$u.api.operationalAnalysisApi.getTollCollectorPerformanceApi({
  100. pageNum: this.tableData.current,
  101. pageSize: 10,
  102. reportType: this.reportType,
  103. queryDate: this.queryDate
  104. }).then(res => {
  105. if (res.code === 200) {
  106. this.tableData.list = res.rows
  107. this.tableData.total = res.total
  108. }
  109. this.loading = false
  110. }).catch(() => {
  111. this.loading = false
  112. })
  113. },
  114. getChartData() {
  115. uni.$u.api.operationalAnalysisApi.getTollCollectorPerformanceApi({
  116. reportType: this.reportType,
  117. queryDate: this.queryDate
  118. }).then(res => {
  119. if (res.code === 200) {
  120. if (res.rows && res.rows.length) {
  121. this.chartData.categories = res.rows.map(item => {
  122. return item.payeeName
  123. })
  124. this.chartData.series[0].data = res.rows.map(item => {
  125. return item.amt
  126. })
  127. } else {
  128. this.chartData.categories = []
  129. this.chartData.series[0].data = []
  130. }
  131. }
  132. })
  133. },
  134. pageChange(current) {
  135. this.tableData.current = current
  136. this.getTableData()
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .performance {
  143. background-color: #fff;
  144. border-radius: 5px;
  145. .empty {
  146. padding: 15px;
  147. }
  148. }
  149. </style>