index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="pa-3 white fullscreen border-box">
  3. <StatisticsList ref="first" :apis="firstApis" :search-items="firstSearchConfig"></StatisticsList>
  4. </div>
  5. </template>
  6. <script>
  7. import StatisticsList from '@/components/StatisticsList'
  8. import {
  9. getPayrollStatistics
  10. } from '@/api/salary'
  11. import {
  12. dateFormat
  13. } from '@/utils/date'
  14. export default {
  15. name: 'welfareAnalysis',
  16. components: {
  17. StatisticsList
  18. },
  19. data () {
  20. return {
  21. firstSearchConfig: [
  22. {
  23. label: '月份',
  24. prop: 'month',
  25. type: 'datePicker',
  26. options: {
  27. clearable: false,
  28. type: 'month',
  29. format: 'yyyy-MM',
  30. valueFormat: 'yyyy-MM',
  31. placeholder: '选择月份'
  32. }
  33. },
  34. {
  35. label: '维度',
  36. prop: 'type',
  37. type: 'select',
  38. options: {
  39. clearable: false,
  40. items: [
  41. { label: '通讯补贴', value: 2 },
  42. { label: '午餐费补贴', value: 3 }
  43. ]
  44. }
  45. },
  46. {
  47. label: '类型',
  48. prop: 'avge',
  49. type: 'select',
  50. options: {
  51. clearable: false,
  52. items: [
  53. { label: '总计', value: false },
  54. { label: '平均值', value: true }
  55. ]
  56. }
  57. }
  58. ],
  59. firstApis: [
  60. (query) => {
  61. return new Promise((resolve, reject) => {
  62. getPayrollStatistics(query).then(resolve).catch(reject)
  63. })
  64. }
  65. ]
  66. }
  67. },
  68. mounted () {
  69. this.$refs.first.onSetValue({
  70. month: dateFormat('YYYY-mm', new Date()),
  71. type: 2,
  72. avge: false
  73. })
  74. this.$refs.first.onInit(items => {
  75. return new Promise((resolve, reject) => {
  76. items.forEach(ele => {
  77. ele.option.series.forEach((item) => {
  78. Object.assign(item, {
  79. label: {
  80. show: true,
  81. formatter: (v) => {
  82. return ` ${v.name}:${v.value} 元`
  83. }
  84. },
  85. breadcrumb: {
  86. show: true,
  87. left: 'left',
  88. top: 'top'
  89. }
  90. })
  91. })
  92. })
  93. this.$nextTick(() => {
  94. const clientHeight = this.$refs.first.$refs.main.clientHeight
  95. items.forEach(ele => {
  96. ele.height = clientHeight - 61 - 40 - 2
  97. })
  98. resolve()
  99. })
  100. })
  101. })
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. </style>