244 lines
7.2 KiB
Vue
244 lines
7.2 KiB
Vue
<template>
|
||
<div style="background: #ececec; padding: 15px">
|
||
<a-card title="按批次对比分析" :loading="loading" :bordered="false">
|
||
<template #extra>
|
||
<a-select v-model:value="collegeMajor" style="width: 300px" :options="collegeMajorOptions"></a-select>
|
||
<a-select v-model:value="batch" :options="batchOptions" change-on-select
|
||
style="margin-left: 10px;width: 120px" />
|
||
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button>
|
||
</template>
|
||
<div>
|
||
<a-row :gutter="24">
|
||
<a-col :xl="24" :style="{ marginBottom: '24px' }">
|
||
<div class="container">
|
||
<div style="display: flex;">
|
||
<span class="title">学院 / 专业通过率变化</span>
|
||
<div v-if="topCollege != null">
|
||
<span style="color: red; font-size: 18px; padding-left: 100px;"> {{ topCollege }}</span>
|
||
<span style="font-size: 15px;"> 在 </span>
|
||
<span style="color: red; font-size: 18px;"> {{ topBath }} </span>
|
||
<span style="font-size: 15px;"> 批次的通过率为:</span>
|
||
<span style="color: red; font-size: 18px;"> {{ sumRate }}%</span>
|
||
</div>
|
||
</div>
|
||
<div id="map1" style="width: 100%; height: 450px;"></div>
|
||
</div>
|
||
</a-col>
|
||
</a-row>
|
||
</div>
|
||
</a-card>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import { result } from 'lodash-es';
|
||
import { defHttp } from '/@/utils/http/axios';
|
||
import * as echarts from 'echarts';
|
||
|
||
export default {
|
||
name: "Analysis",
|
||
|
||
data() {
|
||
return {
|
||
Url: {
|
||
getBatch: '/cet/getBatch',
|
||
getCollege: '/cet/getCollege',
|
||
getRate: '/cet/getRateByBatch',
|
||
getCollegeMajor: '/cet/getCollegeMajor'
|
||
},
|
||
loading: false,
|
||
collegeOptions: [],
|
||
collegeMajorOptions: [],
|
||
batchOptions: [],
|
||
levelOptions: [
|
||
{ value: 'cet4', label: '英语四级' },
|
||
{ value: 'cet6', label: '英语六级' }
|
||
],
|
||
level: null,
|
||
college: null,
|
||
batch: null,
|
||
collegeMajor: null,
|
||
sumRate: null,//总通过率
|
||
topCollege: null,//顶部选择器选择的学院
|
||
topBath: null,//顶部选择器选择的批次
|
||
};
|
||
},
|
||
methods: {
|
||
dataChart(data) {
|
||
let xData = [];
|
||
let yData = [];
|
||
for (let key in data) {
|
||
xData.push(key);
|
||
// 将数据转换为百分比(加上%)
|
||
yData.push((data[key]).toFixed(1));
|
||
}
|
||
xData = xData.map(label => label.split("").join("\n"));//将x轴竖着展示
|
||
let myChart = echarts.init(document.getElementById("map1"));
|
||
// 指定图表的配置项和数据
|
||
let option = {
|
||
title: {
|
||
// text: "学院 / 专业通过率变化",
|
||
},
|
||
xAxis: {
|
||
type: 'category',
|
||
data: xData,
|
||
axisLabel: {
|
||
interval: 0,//代表显示所有x轴标签显示
|
||
rotate: 0,//代表倾斜30度显示
|
||
}
|
||
},
|
||
//提示框
|
||
tooltip: {
|
||
trigger: 'axis',
|
||
axisPointer: {
|
||
type: 'shadow'
|
||
},
|
||
formatter: function (params) {
|
||
return params[0].name + '<br/>' +
|
||
'<table>' +
|
||
'<tr><td>' + params[0].marker + '</td><td style="font-weight: bold;">' + ' ' + params[0].value + '%' + '</td></tr>' +
|
||
'<tr>'
|
||
+ '</table>';
|
||
}
|
||
},
|
||
toolbox: {
|
||
// show: true,
|
||
// feature: {
|
||
// magicType: { show: true, type: ['line', 'bar'] },
|
||
// restore: { show: true },
|
||
// saveAsImage: { show: true },
|
||
// },
|
||
},
|
||
//网格
|
||
grid: {
|
||
left: '3%',
|
||
right: '4%',
|
||
bottom: '1%',//网格距离容器底部的距离是容器高度的3%
|
||
containLabel: true
|
||
},
|
||
yAxis: {
|
||
type: 'value',
|
||
name: '通过率',
|
||
axisLabel: {
|
||
formatter: '{value} %'
|
||
}
|
||
},
|
||
series: [
|
||
{
|
||
data: yData,
|
||
type: 'bar',
|
||
itemStyle: {
|
||
normal: {
|
||
label: {
|
||
show: true, //开启显示
|
||
position: 'top', //在上方显示
|
||
textStyle: { //数值样式
|
||
color: 'black',
|
||
fontSize: 12
|
||
},
|
||
formatter: '{c}%',
|
||
}
|
||
}
|
||
}
|
||
}
|
||
]
|
||
};
|
||
// 使用刚指定的配置项和数据显示图表。
|
||
myChart.setOption(option);
|
||
},
|
||
// 获取批次数据
|
||
async getBatch() {
|
||
const getBatch = await defHttp.get({ url: this.Url.getBatch });
|
||
this.batchOptions = getBatch.batches.map(item => {
|
||
return {
|
||
value: item.value,
|
||
label: item.label
|
||
}
|
||
});
|
||
// const getCollege = await defHttp.get({ url: this.Url.getCollege });
|
||
|
||
// this.collegeOptions = getCollege.colleges;
|
||
// this.college = this.collegeOptions[0].value;
|
||
|
||
this.level = this.levelOptions[0].value;
|
||
|
||
// this.query();
|
||
},
|
||
//获取学院专业级联数据
|
||
async getCollegeMajorData() {
|
||
const res = await defHttp.get({ url: this.Url.getCollegeMajor });
|
||
|
||
//通过map方法将数据转换为级联选择器需要的数据格式
|
||
this.collegeMajorOptions = res.collegeMajor.map(item => {
|
||
return {
|
||
value: item.college,
|
||
label: item.college,
|
||
children: item.major.map(major => {
|
||
return {
|
||
value: major,
|
||
label: major
|
||
}
|
||
})
|
||
}
|
||
});
|
||
this.collegeMajorOptions.unshift({ value: '全校', label: '全校' });
|
||
this.collegeMajor = this.collegeMajorOptions[0].value;
|
||
console.log(this.collegeMajor)
|
||
console.log(this.collegeMajorOptions);
|
||
},
|
||
// 查询数据
|
||
async query() {
|
||
let resultData = null;
|
||
try {
|
||
//如果this.batch为null则先赋个值
|
||
if (!this.batch) {
|
||
this.batch = '2017-12-01';
|
||
}
|
||
if (!this.collegeMajor) {
|
||
this.collegeMajor = '全校';
|
||
}
|
||
//如果this.batch[1]不存在则设为null
|
||
let major = this.batch.length > 1 ? this.batch[1] : "";
|
||
this.topCollege = this.collegeMajor;
|
||
this.topBath = this.batch;
|
||
this.loading = true;
|
||
let params = {
|
||
batch: this.batch,
|
||
college: this.collegeMajor,
|
||
level: 'cet4',
|
||
}
|
||
resultData = await defHttp.get({ url: this.Url.getRate, params });
|
||
this.sumRate = resultData.sumRate;
|
||
console.log("result", resultData)
|
||
} finally {
|
||
this.loading = false;
|
||
this.$nextTick(() => {
|
||
this.dataChart(resultData.data);
|
||
})
|
||
}
|
||
}
|
||
},
|
||
mounted() {
|
||
this.getCollegeMajorData();
|
||
this.getBatch();
|
||
this.query();
|
||
}
|
||
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.container {
|
||
// display: flex;
|
||
background-color: #fff;
|
||
padding: 15px;
|
||
border-radius: 4px;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
|
||
}
|
||
|
||
.title {
|
||
font-size: 20px;
|
||
color: rgb(8, 8, 8);
|
||
font-weight: bold;
|
||
}
|
||
</style> |