hr.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <el-card header="人事数据">
  3. <statistic class="statistic" :cols="0">
  4. <statistic-item v-for="(item, key) in items" :key="key" :class="{active: active === key}" @click="active = key">
  5. <span>
  6. {{item.title}}
  7. <el-tooltip v-if="item.desc" :content="item.desc" :open-delay=".3" placement="top">
  8. <i style="margin-left: 5px;cursor: pointer;" class="el-icon-warning-outline"/>
  9. </el-tooltip>
  10. </span>
  11. <span>
  12. <count-to :endVal="item.percent"/>
  13. </span>
  14. </statistic-item>
  15. </statistic>
  16. <ve-histogram
  17. style="width: 100%;"
  18. height="350px"
  19. :data="chartData"
  20. :data-empty="dataEmpty"
  21. :data-zoom="dataZoom"
  22. ></ve-histogram>
  23. </el-card>
  24. </template>
  25. <script>
  26. import 'echarts/lib/component/dataZoom'
  27. import countTo from 'vue-count-to'
  28. import veHistogram from 'v-charts/lib/histogram.common'
  29. export default {
  30. props: ['data'],
  31. components: {
  32. 've-histogram': veHistogram,
  33. 'count-to': countTo
  34. },
  35. computed: {
  36. items() {
  37. return {
  38. TEACHER_NUM: this.data['TEACHER_NUM'] || {},
  39. FULL_TIME_NUM: this.data['FULL_TIME_NUM'] || {},
  40. PART_TIME_NUM: this.data['PART_TIME_NUM'] || {},
  41. DIMISSION_NUM: this.data['DIMISSION_NUM'] || {},
  42. }
  43. },
  44. dataZoom() {
  45. return [
  46. {
  47. type: 'slider',
  48. start: 60,
  49. end: 100
  50. }
  51. ]
  52. },
  53. chartData() {
  54. const values = Object.values(this.items)
  55. const months = {}
  56. for (const item of values) {
  57. for (const row of (item.indexMonthData || [])) {
  58. const key = this.$helpers.dayjs(row.month).format('YYYY-MM-DD')
  59. if (!months[key]) {
  60. months[key] = {
  61. '日期': key,
  62. }
  63. }
  64. months[key][item.title] = row.percent
  65. }
  66. }
  67. return {
  68. columns: ['日期', ...values.map(item => item.title)],
  69. rows: Object.values(months)
  70. }
  71. },
  72. dataEmpty() {
  73. return !this.chartData.rows.length
  74. },
  75. },
  76. data () {
  77. return {
  78. active: 'TEACHER_NUM',
  79. }
  80. },
  81. }
  82. </script>
  83. <style lang="less" scoped>
  84. // .statistic{
  85. // /deep/ .statistic-content{
  86. // cursor: pointer;
  87. // &.active > span{
  88. // color: #14928a !important;
  89. // }
  90. // }
  91. // }
  92. </style>