index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="pa-3 white fullscreen border-box">
  3. <el-tabs v-model="activeName" class="fullscreen">
  4. <el-tab-pane label="分布图" name="first" class="fullscreen">
  5. <StatisticsList ref="first" :apis="firstApis" :search-items="firstSearchConfig"></StatisticsList>
  6. </el-tab-pane>
  7. <el-tab-pane label="趋势图" name="second" class="fullscreen">
  8. <StatisticsList ref="second" :apis="apis" :search-items="searchConfig" :value-fn="valueFn"></StatisticsList>
  9. </el-tab-pane>
  10. </el-tabs>
  11. </div>
  12. </template>
  13. <script>
  14. import StatisticsList from '@/components/StatisticsList'
  15. import { getCustomerClaimStatistics, getSalaryProductStatistics } from '@/api/salary'
  16. import { dateFormat } from '@/utils/date'
  17. export default {
  18. name: 'claimStatistics',
  19. components: {
  20. StatisticsList
  21. },
  22. data () {
  23. return {
  24. firstApis: [
  25. (query) => {
  26. return new Promise((resolve, reject) => {
  27. getCustomerClaimStatistics(query).then(resolve).catch(reject)
  28. })
  29. }
  30. ],
  31. firstSearchConfig: [
  32. {
  33. label: '月份',
  34. prop: 'month',
  35. type: 'datePicker',
  36. options: {
  37. placeholder: '请选择月份',
  38. clearable: false,
  39. type: 'month',
  40. valueFormat: 'yyyy-MM',
  41. format: 'yyyy 年 MM 月'
  42. }
  43. }
  44. ],
  45. apis: [
  46. (query) => {
  47. return new Promise((resolve, reject) => {
  48. const { month } = query
  49. const param = {}
  50. if (month && month.length) {
  51. Object.assign(param, {
  52. startDate: month[0],
  53. endDate: month[1]
  54. })
  55. }
  56. getSalaryProductStatistics(param).then(resolve).catch(reject)
  57. })
  58. }
  59. ],
  60. searchConfig: [{
  61. label: '时间范围',
  62. type: 'datePicker',
  63. prop: 'month',
  64. options: {
  65. rangeSeparator: '至',
  66. startPlaceholder: '开始时间',
  67. endPlaceholder: '结束时间',
  68. valueFormat: 'yyyy-MM-dd',
  69. type: 'daterange'
  70. }
  71. }],
  72. activeName: 'first'
  73. }
  74. },
  75. mounted () {
  76. this.$refs.first.onSetValue({
  77. month: dateFormat('YYYY-mm', new Date())
  78. })
  79. this.$refs.first.onInit(items => {
  80. return new Promise((resolve, reject) => {
  81. items.forEach(ele => {
  82. ele.option.series.forEach((item) => {
  83. Object.assign(item, {
  84. label: {
  85. show: true,
  86. formatter: (v) => {
  87. return ` ${v.name}:${v.value} 元`
  88. }
  89. },
  90. breadcrumb: {
  91. show: true,
  92. left: 'left',
  93. top: 'top'
  94. }
  95. })
  96. })
  97. })
  98. this.$nextTick(() => {
  99. const clientHeight = this.$refs.first.$refs.main.clientHeight
  100. items.forEach(ele => {
  101. ele.height = clientHeight - 61 - 40 - 2
  102. })
  103. resolve()
  104. })
  105. })
  106. })
  107. this.$refs.second.onInit()
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. ::v-deep .el-tabs__content {
  113. height: calc(100% - 55px);
  114. overflow: visible;
  115. }
  116. </style>