123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <div class="chart-box">
- <div class="chart-item" v-for="(val, i) in list" :key="i">
- <Echarts :height="400" :option="val.option"></Echarts>
- </div>
- <!-- <div class="fullChart">
- <Echarts :height="400" :option="option"></Echarts>
- </div> -->
- </div>
- </template>
- <script setup>
- defineOptions({ name: 'resume-analysis'})
- import { ref, onMounted, watch, nextTick } from 'vue'
- import cloneDeep from 'lodash/cloneDeep'
- import { getJobCvAgeCount, getJobCvEduCount, getJobCvSexCount, getJobCvExpCount } from '@/api/recruit/enterprise/statistics'
- const props = defineProps({
- query: Object
- })
- // 柱状图公共option
- const barCommonOption = {
- title: {
- text: ''
- },
- xAxis: {
- type: 'category',
- name: '范围',
- axisLabel: {
- rotate: 30
- },
- data: []
- },
- yAxis: {
- type: 'value',
- name: '数量(人)'
- },
- grid: {
- left: '20',
- top: '70',
- right: '50',
- bottom: '10',
- containLabel: true
- },
- series: [
- {
- data: [],
- type: 'bar',
- barWidth: 40,
- label: {
- show: true
- }
- }
- ]
- }
- // 期望月薪柱状图
- // const option = {
- // title: {
- // text: '期望月薪'
- // },
- // xAxis: {
- // type: 'category',
- // name: '范围',
- // data: ['3-5k', '5-8k', '8-12k', '12-15k', '15-20k', '20-30k', '面议']
- // },
- // yAxis: {
- // type: 'value'
- // },
- // grid: {
- // left: '0',
- // top: '60',
- // right: '50',
- // bottom: '10',
- // containLabel: true
- // },
- // series: [
- // {
- // data: [120, 200, 150, 80, 70, 110, 130],
- // type: 'bar',
- // barWidth: 40,
- // label: {
- // show: true
- // }
- // }
- // ]
- // }
- const list = ref([
- {
- api: getJobCvSexCount,
- isPie: true,
- option: {
- title: {
- text: '性别分布'
- },
- tooltip: {
- trigger: 'item'
- },
- legend: {
- top: '5%',
- left: 'center'
- },
- series: [
- {
- name: '性别分布',
- type: 'pie',
- radius: ['40%', '70%'],
- avoidLabelOverlap: false,
- itemStyle: {
- borderRadius: 10,
- borderColor: '#fff',
- borderWidth: 2
- },
- label: {
- show: true,
- formatter: e => {
- return e.data.key + ': ' + e.value + '人'
- }
- },
- labelLine: {
- show: true
- },
- data: []
- }
- ]
- }
- },
- {
- api: getJobCvAgeCount,
- title: '年龄分布',
- option: cloneDeep(barCommonOption)
- },
- {
- api: getJobCvExpCount,
- title: '工作年限分布',
- option: cloneDeep(barCommonOption)
- },
- {
- api: getJobCvEduCount,
- title: '学历分布',
- option: cloneDeep(barCommonOption)
- }
- ])
- const getStatistics = () => {
- list.value.forEach(async (e) => {
- const data = await e.api(props.query)
- if (e.isPie) {
- e.option.series[0].data = data
- } else {
- e.option.title.text = e.title
- e.option.xAxis.data = data.x
- e.option.series[0].data = data.y
- }
- })
- }
- onMounted(() => {
- nextTick(() => {
- getStatistics()
- })
- })
- watch(
- () => props.query,
- (val) => {
- if (val) getStatistics()
- },
- { deep: true }
- )
- </script>
- <style scoped lang="scss">
- .chart-box {
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- .chart-item {
- width: calc((100% - 24px) / 2);
- min-width: calc((100% - 24px) / 2);
- max-width: calc((100% - 24px) / 2);
- overflow: hidden;
- transition: all .2s linear;
- background-color: #f7f8fa;
- border-radius: 8px;
- margin: 0 12px 12px 0;
- padding: 12px;
- &:nth-child(2n) {
- margin-right: 0;
- }
- }
- }
- .fullChart {
- width: 100%;
- background-color: #f7f8fa;
- border-radius: 8px;
- padding: 12px;
- }
- </style>
|