resume.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="chart-box">
  3. <div class="chart-item" v-for="(val, i) in list" :key="i">
  4. <Echarts :height="400" :option="val.option"></Echarts>
  5. </div>
  6. <!-- <div class="fullChart">
  7. <Echarts :height="400" :option="option"></Echarts>
  8. </div> -->
  9. </div>
  10. </template>
  11. <script setup>
  12. defineOptions({ name: 'resume-analysis'})
  13. import { ref, onMounted, watch, nextTick } from 'vue'
  14. import cloneDeep from 'lodash/cloneDeep'
  15. import { getJobCvAgeCount, getJobCvEduCount, getJobCvSexCount, getJobCvExpCount } from '@/api/recruit/enterprise/statistics'
  16. const props = defineProps({
  17. query: Object
  18. })
  19. // 柱状图公共option
  20. const barCommonOption = {
  21. title: {
  22. text: ''
  23. },
  24. xAxis: {
  25. type: 'category',
  26. name: '范围',
  27. axisLabel: {
  28. rotate: 30
  29. },
  30. data: []
  31. },
  32. yAxis: {
  33. type: 'value',
  34. name: '数量(人)'
  35. },
  36. grid: {
  37. left: '20',
  38. top: '70',
  39. right: '50',
  40. bottom: '10',
  41. containLabel: true
  42. },
  43. series: [
  44. {
  45. data: [],
  46. type: 'bar',
  47. barWidth: 40,
  48. label: {
  49. show: true
  50. }
  51. }
  52. ]
  53. }
  54. // 期望月薪柱状图
  55. // const option = {
  56. // title: {
  57. // text: '期望月薪'
  58. // },
  59. // xAxis: {
  60. // type: 'category',
  61. // name: '范围',
  62. // data: ['3-5k', '5-8k', '8-12k', '12-15k', '15-20k', '20-30k', '面议']
  63. // },
  64. // yAxis: {
  65. // type: 'value'
  66. // },
  67. // grid: {
  68. // left: '0',
  69. // top: '60',
  70. // right: '50',
  71. // bottom: '10',
  72. // containLabel: true
  73. // },
  74. // series: [
  75. // {
  76. // data: [120, 200, 150, 80, 70, 110, 130],
  77. // type: 'bar',
  78. // barWidth: 40,
  79. // label: {
  80. // show: true
  81. // }
  82. // }
  83. // ]
  84. // }
  85. const list = ref([
  86. {
  87. api: getJobCvSexCount,
  88. isPie: true,
  89. option: {
  90. title: {
  91. text: '性别分布'
  92. },
  93. tooltip: {
  94. trigger: 'item'
  95. },
  96. legend: {
  97. top: '5%',
  98. left: 'center'
  99. },
  100. series: [
  101. {
  102. name: '性别分布',
  103. type: 'pie',
  104. radius: ['40%', '70%'],
  105. avoidLabelOverlap: false,
  106. itemStyle: {
  107. borderRadius: 10,
  108. borderColor: '#fff',
  109. borderWidth: 2
  110. },
  111. label: {
  112. show: true,
  113. formatter: e => {
  114. return e.data.key + ': ' + e.value + '人'
  115. }
  116. },
  117. labelLine: {
  118. show: true
  119. },
  120. data: []
  121. }
  122. ]
  123. }
  124. },
  125. {
  126. api: getJobCvAgeCount,
  127. title: '年龄分布',
  128. option: cloneDeep(barCommonOption)
  129. },
  130. {
  131. api: getJobCvExpCount,
  132. title: '工作年限分布',
  133. option: cloneDeep(barCommonOption)
  134. },
  135. {
  136. api: getJobCvEduCount,
  137. title: '学历分布',
  138. option: cloneDeep(barCommonOption)
  139. }
  140. ])
  141. const getStatistics = () => {
  142. list.value.forEach(async (e) => {
  143. const data = await e.api(props.query)
  144. if (e.isPie) {
  145. e.option.series[0].data = data
  146. } else {
  147. e.option.title.text = e.title
  148. e.option.xAxis.data = data.x
  149. e.option.series[0].data = data.y
  150. }
  151. })
  152. }
  153. onMounted(() => {
  154. nextTick(() => {
  155. getStatistics()
  156. })
  157. })
  158. watch(
  159. () => props.query,
  160. (val) => {
  161. if (val) getStatistics()
  162. },
  163. { deep: true }
  164. )
  165. </script>
  166. <style scoped lang="scss">
  167. .chart-box {
  168. width: 100%;
  169. display: flex;
  170. flex-wrap: wrap;
  171. .chart-item {
  172. width: calc((100% - 24px) / 2);
  173. min-width: calc((100% - 24px) / 2);
  174. max-width: calc((100% - 24px) / 2);
  175. overflow: hidden;
  176. transition: all .2s linear;
  177. background-color: #f7f8fa;
  178. border-radius: 8px;
  179. margin: 0 12px 12px 0;
  180. padding: 12px;
  181. &:nth-child(2n) {
  182. margin-right: 0;
  183. }
  184. }
  185. }
  186. .fullChart {
  187. width: 100%;
  188. background-color: #f7f8fa;
  189. border-radius: 8px;
  190. padding: 12px;
  191. }
  192. </style>