feature/1.0版本院领导页面开发 #2

Merged
Xubx merged 7 commits from feature/1.0版本院领导页面开发 into feature/1.0版本页面优化 2025-02-03 15:41:06 +08:00
2 changed files with 664 additions and 375 deletions
Showing only changes of commit 2b83ad54a3 - Show all commits

View File

@ -334,7 +334,7 @@
},
},
title: {
text: '该批次每一年级的通过率图',
text: '该批次每一年级的通过率环形图',
left: 'top',
top: '0%',
textStyle: {
@ -352,7 +352,7 @@
series: [
{
name: '学院/专业该批次通过人数图',
name: '学院/专业该批次通过人数环形图',
type: 'pie',
radius: ['50%', '100%'],
center: ['50%', '50%'],

View File

@ -1,80 +1,88 @@
<template>
<div style="background: #ececec; padding: 15px">
<a-card title="四级总通过率查询" :loading="loading" :bordered="false">
<template #extra>
<a-cascader v-model:value="collegeMajor" :options="collegeMajorOptions" change-on-select />
<a-select v-model:value="entrydate" style="margin-left: 10px; width: 100px" :options="entrydateOptions" />
<a-button style="margin-left: 10px" type="primary" @click="query">查询</a-button>
<!-- <a-button @click=test()>test</a-button> -->
</template>
<a-row :gutter="12">
<a-col :xl="13">
<div style="padding-left: 10px; min-height: 400px">
<div v-if="topCollege != null" style="margin-bottom: 5px">
<span style="font-size: 15px">当前数据为 </span>
<span style="color: red; font-size: 18px">{{ topCollege }}</span>
<span v-if="topMajor != null && topMajor != ''" style="color: red; font-size: 18px"> / {{ topMajor
}}</span>
<span style="font-size: 15px"> </span>
<span style="color: red; font-size: 20px">{{ topEntrydate }}</span>
<span style="font-size: 15px"> 级数据</span>
</div>
<a-table :dataSource="dataSourceCet4" :columns="columns" :pagination="false" bordered>
<template #passRateSlot>
累计总通过率
<a-tooltip :title="'累计通过人数 / ' + totalName + '总人数'" placement="top">
<a-icon type="question-circle" />
</a-tooltip>
</template>
</a-table>
<div style="display: flex; justify-content: space-between; font-size: 15px; margin-top: 10px"
v-if="total && total > 0">
<span>{{ totalName }}总人数{{ total }}</span>
<span>累计通过人数: {{ passNumberBottom }}</span>
<span>累计总通过率: {{ passRateBottom }}</span>
</div>
</div>
</a-col>
<a-col :xl="11">
<a-card style="margin-top: 33px; margin-bottom: 12px">
<div style="width: 100%; height: 215px" class="piechart" id="piechart"> </div>
</a-card>
<a-card>
<div style="width: 100%; height: 180px" id="map2"> </div>
</a-card>
</a-col>
</a-row>
<!-- <div style="height: 300px;">
<a-empty style="margin-top: 100px" />
</div> -->
</a-card>
<!--<a-row :gutter="1">
<a-card-grid class="card-title">/
<span>学院总人数{{ collegeStudentCount }}</span>
</a-card-grid>
<a-card-grid class="card-title">
<span>积累通过人数{{ collegeStudentPassCount }}</span>
</a-card-grid>
<a-card-grid class="card-title">
<span>学院通过率{{ collegeStudentPassRate }}</span>
</a-card-grid>
<a-card-grid class="card-title">
<span> 全校通过率{{ schoolStudentPassRate }}</span>
</a-card-grid>
<a-card-grid style="margin-left: 24%; width: 10%; height: 10%; margin-bottom: 10px; border-radius: 10%; text-align: center">
<a-select v-model:value="entrydate" style="border-radius: 10%; width: 100px; margin-left: -20px" :options="entrydateOptions" />
</a-card-grid>
</a-row>-->
<a-row :gutter="1">
<a-card-grid class="card-center">
<div>
<a-table
:dataSource="dataSourceCet4"
:columns="columns"
:pagination="false"
bordered
class="custom-table"
:style="{ fontSize: '10px', color: '#333', marginTop: '-11px' }"
/>
</div>
</a-card-grid>
<a-card-grid class="card-center">
<div style="width: 100%; height: 210px; padding: 10px" class="map2" id="map2"></div>
</a-card-grid>
<a-card-grid class="card-center">
<a-select
v-model:value="entrydate"
style="border-radius: 10%; width: 100px; margin-left: -20px"
:options="entrydateOptions"
@change="handleSelectChange"
/>
<div id="map3" style="width: 100%; height: 230px"></div>
</a-card-grid>
</a-row>
<a-row :gutter="1">
<a-card-grid class="card-bottom" style="width: 32%">
<div id="map4" style="width: 100%; height: 100%"></div>
</a-card-grid>
<a-card-grid style="width: 65%" class="card-bottom">
<div id="map5" style="width: 100%; height: 100%"></div>
</a-card-grid>
</a-row>
</a-card>
</template>
<script>
import { defHttp } from '/@/utils/http/axios';
import * as echarts from 'echarts';
import { defHttp } from '/@/utils/http/axios';
import * as echarts from 'echarts';
export default {
export default {
data() {
return {
collegeStudentCount: '11',
collegeStudentPassCount: '11',
collegeStudentPassRate: '11',
schoolStudentPassRate: '11',
loading: false,
dataSourceCet4: [],
batch: '',
college: '',
majors: [],
majorentrydate: [],
entrydate: '2017',
entrydateOptions: [],
columns: [
{
title: '学年',
title: '',
dataIndex: 'grade',
key: 'grade',
align: 'center',
customCell: (_, index) => ({
rowSpan: index % 2 === 0 ? 2 : 0, //graderowSpan
}),
},
{
title: '考试批次',
dataIndex: 'batch',
key: 'batch',
align: 'center',
},
{
title: '参加人数',
@ -89,284 +97,188 @@ export default {
align: 'center',
},
{
title: '本批次通过率',
dataIndex: 'batchpassrate',
key: 'batchpassrate',
title: '通过率',
dataIndex: 'passrate',
key: 'passrate',
align: 'center',
},
{
slots: { title: 'passRateSlot' },
dataIndex: 'gradepassrate',
key: 'gradepassrate',
align: 'center',
customCell: (_, index) => ({
rowSpan: index % 2 === 0 ? 2 : 0,
}),
},
],
Url: {
getDataForHead: '/cet/getDataForHLeadersHome',
getData: '/cet/getRateByBatch',
getRateByMajor: '/cet/getRateByMajor',
getCollegeRate: '/cet/getRateByCollege',
getEntrydate: '/cet/getEntrydate',
getCollege: '/cet/getCollege',
getData: '/cet/getData',
getCollegeMajor: '/cet/getCollegeMajor',
},
total: 0,
totalName: '',
passNumberBottom: 0,
passRateBottom: 0,
passRatePie: [],
lineXData: [],
lineYData: [],
collegeOptions: [],
collegeMajorOptions: [],
entrydateOptions: [],
college: null,
entrydate: 2017, //
//
collegeMajor: ['全校'], //
topCollege: null, //
topMajor: null, //
topEntrydate: null, //
};
},
mounted() {
this.getEntrydateAndCollegeData();
this.getCollegeMajorData();
this.query();
//this.map2Chart();
this.majorPassRate();
this.gradePassRate();
this.queryMajorByCollege();
},
methods: {
//
async getEntrydateAndCollegeData() {
const getEntrydate = await defHttp.get({ url: this.Url.getEntrydate });
const getCollege = await defHttp.get({ url: this.Url.getCollege });
this.collegeOptions = getCollege.colleges;
//
this.collegeOptions.unshift({ value: '全校', label: '全校' });
this.college = this.collegeOptions[0].value;
this.entrydateOptions = getEntrydate.entrydates;
// this.entrydate = this.entrydateOptions[0].value;
//
async queryTopData() {
let result = await defHttp.get({ url: this.Url.getDataForHead });
console.log('0000', result.data);
},
//
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.collegeMajorOptions.unshift({ value: '全校', label: '全校' });
// this.collegeMajor = [''];
console.log(this.collegeMajorOptions);
},
//
async query() {
let resultData = null;
try {
//this.collegeMajor[1]null
let major = this.collegeMajor.length > 1 ? this.collegeMajor[1] : '';
this.topCollege = this.collegeMajor[0];
this.topMajor = major;
this.topEntrydate = this.entrydate;
if (this.college) this.loading = true;
//this.batchnull
if (!this.batch) {
this.batch = '2024-06-01';
}
if (!this.college) {
this.college = '计算机科学与信息工程学院';
}
this.loading = true;
let params = {
college: this.collegeMajor[0],
major: major,
entrydate: this.entrydate,
batch: this.batch,
college: this.college,
level: 'cet4',
};
console.log('params', params);
const result = await defHttp.get({ url: this.Url.getData, params });
let tableData = [];
let piedata = [];
let passrate = 0;
let index = 0;
const passRate = {};
if (result.cet4['大一学年'] != undefined) {
passRate['大一学年'] = result.cet4['大一学年'];
}
if (result.cet4['大二学年'] != undefined) {
passRate['大二学年'] = result.cet4['大二学年'];
}
if (result.cet4['大三学年'] != undefined) {
passRate['大三学年'] = result.cet4['大三学年'];
}
if (result.cet4['大四学年'] != undefined) {
passRate['大四学年'] = result.cet4['大四学年'];
}
result.cet4 = passRate;
this.lineXData = [];
this.lineYData = [];
for (let grade in result.cet4) {
result.cet4[grade].forEach((item) => {
this.lineXData.push(item.batch);
this.lineYData.push((item.batchpassrate * 100).toFixed(1));
if (index % 2 == 0) {
piedata.push({ value: parseFloat(item.gradepassrate - passrate).toFixed(3), name: grade + '时通过' });
passrate = parseFloat(item.gradepassrate).toFixed(3);
}
index++;
tableData.push({
grade: grade,
attendNumber: item.attendNumber,
batch: item.batch,
gradepassrate: (item.gradepassrate * 100).toFixed(1) + '%',
passNumber: item.passNumber,
batchpassrate: (item.batchpassrate * 100).toFixed(1) + '%',
});
});
}
resultData = await defHttp.get({ url: this.Url.getData, params });
console.log('tableData', tableData);
console.log('result', resultData);
//
let tableData = [];
for (let grade in resultData.gradeData) {
tableData.push({
grade: grade + '级',
attendNumber: resultData.gradeData[grade].allStudent,
passNumber: resultData.gradeData[grade].passed,
passrate: resultData.gradeData[grade].passRate,
});
}
this.dataSourceCet4 = tableData; //
this.total = result.total; //
this.totalName = result.totalName; //
this.passNumberBottom = result.passNumber; //
this.passRateBottom = (result.passRate * 100).toFixed(1) + '%'; //
//
this.passRatePie = []; //
this.passRatePie.push({ value: result.passRate, name: '已通过' });
this.passRatePie.push({ value: 1 - result.passRate, name: '未通过' });
piedata.push({ value: (1 - passrate).toFixed(3), name: '未通过' }); //
setTimeout(() => {
this.drawPieChart(piedata);
this.map2Chart();
}, 100);
// this.drawPieChart();
console.log(this.dataSourceCet4, 'dataSourceCet4');
} finally {
this.loading = false;
this.$nextTick(() => {
//this.dataChart(resultData.data);
console.log('cet4:', resultData.data);
this.card_Table();
});
}
},
test() {
defHttp.get({ url: '/cet/getTest' });
},
map2Chart() {
var myChart = echarts.init(document.getElementById('map2'));
var option = {
title: {
text: '各批次通过率分析',
left: 'left',
top: '0%',
textStyle: {
fontSize: 16,
},
},
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;">' +
'&nbsp;&nbsp;&nbsp;&nbsp;' +
params[0].value +
'%' +
'</td></tr>' +
'<tr>' +
'</table>'
);
},
},
grid: {
top: '50px',
left: '50px',
right: '50px',
bottom: '30px',
},
xAxis: {
type: 'category',
data: this.lineXData,
},
yAxis: {
type: 'value',
},
series: [
{
data: this.lineYData,
type: 'line',
itemStyle: {
normal: {
label: {
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 12,
},
formatter: '{c}%',
},
},
},
},
],
async queryMajorByCollege() {
if (!this.college) {
this.college = '计算机科学与信息工程学院';
}
let resultData = await defHttp.get({ url: this.Url.getCollegeMajor });
let collegeAndMajor = resultData.collegeMajor;
console.log('11111111111', collegeAndMajor);
// collegeAndMajor
let majors = collegeAndMajor.find((item) => item.college === this.college);
console.log('3333', majors);
majors = majors.major;
this.majors = majors;
console.log('444', this.majors);
let collegeAndMajors = this.majors.map((major) => [this.college, major]);
console.log('777', collegeAndMajors);
//this.major = resultData.
const getEntrydate = await defHttp.get({ url: this.Url.getEntrydate });
this.entrydateOptions = getEntrydate.entrydates;
let entrydate = this.entrydateOptions.map((item) => item.value).splice(-5);
this.majorentrydate = entrydate;
let params = {
college: collegeAndMajors,
entrydate: entrydate,
};
option && myChart.setOption(option);
console.log('666');
let res = await defHttp.post({ url: this.Url.getRateByMajor, params });
console.log('55555', res.data);
this.$nextTick(() => {
this.drawChart(res.data);
});
},
drawPieChart(piedata) {
console.log(this.passRatePie);
console.log('piedata', piedata);
let myChart = echarts.init(document.getElementById('piechart'));
//--
async card_Table() {
//console.log(this.passRatePie);
//console.log('piedata', piedata);
//this.batchnull
if (!this.batch) {
this.batch = '2024-06-01';
}
if (!this.college) {
this.college = '计算机科学与信息工程学院';
}
let queryParams = {
batch: this.batch,
college: this.college,
level: 'cet4',
};
console.log(queryParams, 'queryParams');
let result = await defHttp.get({ url: this.Url.getData, params: queryParams });
console.log(result, 'result');
let chartsData = [];
for (let key in result.gradeData) {
chartsData.push({
name: key + '级',
value: result.gradeData[key].passRate,
});
}
let option = {
tooltip: {
trigger: 'item',
confine: false,
avoidLabelOverlap: true,
conginee: false,
//
itemStyle: {
itemStytle: {
//
shadowBlur: 10, //
shadowColor: 'rgba(0, 0, 0, 0.3)', //
shadowOffsetX: 5, //
shadowOffsetY: 5, //
fontSize: 100,
},
},
title: {
text: '四级通过率分析',
left: 'left',
text: '最新批次每一年级的通过率环形图',
left: 'top',
top: '0%',
textStyle: {
fontSize: 16,
fontSize: 12,
},
},
legend: {
top: 'center',
right: '0%',
orient: 'vertical',
top: '10%',
left: 'center',
itemGap: 3,
selectedMode: true,
},
color: ['#b3cde0', '#6497b1', '#005b96', '#03396c', '#e5e5e5'],
color: ['#ec2e30', '#c75af1', '#2b9eef', '#eee03f', '#2aed91', '#c5ed3c'],
series: [
//
{
name: '四级通过率',
name: '学院/专业该批次通过人数环形图',
type: 'pie',
center: ['30%', '50%'],
radius: ['35%', '70%'],
radius: ['50%', '100%'],
center: ['50%', '50%'],
startAngle: 130,
top: 80,
//
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
// borderRadius: 5,
// borderColor: '#fff',
borderWidth: 2,
},
label: {
show: true,
fontSize: 14,
// position: 'inside',
fontSize: 12,
overflow: 'truncate',
minMargin: -1,
},
labelLine: {
show: true,
smooth: true,
length: 10,
},
emphasis: {
itemStyle: {
@ -380,29 +292,406 @@ export default {
fontWeight: 'bold',
},
},
data: piedata,
data: chartsData,
},
{
type: 'pie',
startAngle: 130,
top: 80,
radius: ['40%', '51%'],
center: ['50%', '50%'],
//
itemStyle: {
// borderRadius: 3,
// borderColor: '#fff',
borderWidth: 2,
},
label: {
show: false,
},
hoverAnimation: false,
legendHoverLink: false,
// animationnfalse,
tooltip: {
show: false,
},
data: chartsData,
},
],
animationDurationUpate: 500,
};
this.$nextTick(() => {
var myChart = echarts.init(document.getElementById('map2'));
myChart.setOption(option);
});
},
handleSelectChange() {
this.majorPassRate();
},
// -map3---------------------------------------------
async majorPassRate() {
console.log('55555555', this.entrydate);
if (!this.batch) {
this.batch = '2024-06-01';
}
if (!this.college) {
this.college = ['计算机科学与信息工程学院'];
}
this.map3loading = true;
//entrydate
let entrydateArray = [];
entrydateArray.push(this.entrydate);
let queryParams = {
college: [[this.college]],
entrydate: entrydateArray,
level: 'cet4',
};
let url = this.Url.getRateByMajor;
console.log(queryParams, 'queryParams');
let result = await defHttp.post({ url: url, data: queryParams });
console.log('88888', result.data);
if (!result) {
return;
}
//result = result.data[name];
// result.data
const majors = Object.keys(result.data); //
const passRates = majors.map((major) => {
const entries = result.data[major];
return entries.length > 0 ? parseFloat(entries[0].passRate) : 0; //
});
let xData = majors.map((label) => label.split('').join('\n')); //x
var majorOption = {
tooltip: {
trigger: 'item',
conginee: false,
//
itemStytle: {
fontSize: 100,
},
formatter: function (params) {
// %
return `${params.marker}${params.name} ${params.value}%`;
},
},
};
title: {
text: this.college + '各专业四级通过率',
textStyle: {
fontSize: 14,
},
},
xAxis: {
type: 'category',
data: xData,
axisLabel: {
interval: 0, //x
//rotate: -10, //30
},
//data: result.map((item) => item.major),
//data: ['', '', '', '', '西'],
},
yAxis: {
type: 'value',
},
series: [
{
label: {
show: true,
fontSize: 14,
overflow: 'truncate',
position: 'top',
formatter: function (params) {
//
return params.value + '%';
},
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
//
label: {
show: false,
fontSize: 14,
fontWeight: 'bold',
},
},
data: passRates,
//data: result.map((item) => item.passRate),
//data: [200, 150, 80, 70, 110, 130],
type: 'bar',
},
],
animationDurationUpdate: 500,
};
this.map3loading = false;
this.$nextTick(() => {
var myChart = echarts.init(document.getElementById('map3'));
myChart.setOption(majorOption);
});
},
//
async gradePassRate() {
this.map2loading = true;
const getEntrydate = await defHttp.get({ url: this.Url.getEntrydate });
this.entrydateOptions = getEntrydate.entrydates;
let entrydate = this.entrydateOptions.map((item) => item.value);
const college = ['计算机科学与信息工程学院'];
let queryParams = {
college: college,
entrydate: entrydate,
level: 'cet4',
};
let url = this.Url.getCollegeRate;
let result = await defHttp.post({ url: url, data: queryParams });
if (!result) {
return;
}
result = result.data[college];
let collegeOption = {
title: {
text: college + '四级通过率',
textStyle: {
fontSize: 14,
},
},
xAxis: {
data: result.map((item) => item.entrydate),
},
//
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
formatter: function (params) {
//tooltip,
let result = params[0].name + '<br>';
for (let i = 0; i < params.length; i++) {
result += params[i].marker + name + ' : ' + params[i].value + '%' + '<br>';
}
return result;
},
},
series: {
type: 'line',
data: result.map((item) => item.passRate),
label: {
show: true, //
position: 'top', //
formatter: function (params) {
//
return params.value + '%';
},
//
},
universalTransition: {
// enabled: true,
// divideShape: 'clone',
},
},
yAxis: {},
animationDurationUpdate: 500,
};
this.map2loading = false;
this.$nextTick(() => {
var myChart = echarts.init(document.getElementById('map4'));
myChart.setOption(collegeOption);
});
},
//
drawChart(data) {
let seriesData = [];
let xData = this.majorentrydate.sort((a, b) => a - b);
let k = 0;
let legendData = [];
let colors = [
'#5370c5',
'#91CC75',
'#fac858',
'#ee6666',
'#73c0de',
'#FF6A6A',
'#FFA500',
'#EE2C2C',
'#90EE90',
'#008B8B',
'#FFC0CB',
'#FFDAB9',
'#FFDEAD',
'#FFE4B5',
'#FFE4C4',
'#FFE4E1',
'#FFEBCD',
'#FFEFD5',
'#FFFAF0',
'#FFFAFA',
'#FFFFE0',
'#FFFFF0',
'#FFFFFF',
'#F0F8FF',
'#FAEBD7',
'#FAF0E6',
'#FAFAD2',
'#F5FFFA',
'#F8F8FF',
'#F0FFF0',
'#F0FFFF',
'#F0E68C',
'#F0F8FF',
'#F0FFF0',
'#F0FFFF',
'#F4A460',
'#F5DEB3',
'#F5F5DC',
'#F5F5F5',
'#F5FFFA',
'#F8F8FF',
'#F9EBEA',
'#FAD7A0',
'#FAF0E6',
'#FAFAD2',
'#FAF0E6 ',
];
for (let i in data) {
console.log(i, 'i');
legendData.push(i);
let yData = [];
// legendData=[];
console.log(data[i], 'data[i]');
for (let j in data[i]) {
console.log(data[i][j].college, 'data[i][j].college111');
// if(data[i][j].college == ''){
yData.push(data[i][j].passRate);
// legendData.push(data[i][j].college);
}
console.log(yData, 'yData');
seriesData.push({
name: i,
type: 'bar',
//
barWidth: 16,
data: yData,
//
barGap: '30%',
//
itemStyle: {
normal: {
label: {
show: true, //
position: 'top', //
formatter: '{c}%',
textStyle: {
//
color: 'black',
fontSize: 13,
},
},
color: colors[k++],
},
},
});
}
// debugger
let myChart = null;
myChart = document.getElementById('map5');
if (myChart) {
myChart = echarts.getInstanceByDom(myChart);
if (myChart) {
myChart.dispose();
}
}
myChart = echarts.init(document.getElementById('map5'));
//
let option = {
legend: {},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
formatter: function (params) {
//tooltip,
let result = params[0].name + '级通过率<br>';
for (let i = 0; i < params.length; i++) {
result += params[i].marker + legendData[i] + ' : ' + params[i].value + '%' + '<br>';
}
return result;
},
},
toolbox: {
show: true,
//feature: {
// magicType: { show: true, type: ['line', 'bar'] },
// restore: { show: true },
// saveAsImage: { show: true },
//},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: [
{
type: 'category',
data: xData,
axisLabel: {
interval: 0, //x
rotate: 0, //0
},
},
],
yAxis: [
{
type: 'value',
name: '通过率',
axisLabel: {
formatter: '{value} %',
},
},
],
series: seriesData,
};
// 使
console.log(option, 'option');
console.log(myChart, 'myChart');
setTimeout(() => {
myChart.setOption(option);
}, 1);
},
},
};
</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: 34px;
color: rgb(8, 8, 8);
font-weight: bold;
}
.card-title {
width: 15%;
height: 10%;
//text-align: top center;
margin-right: 10px;
margin-bottom: 10px;
border-radius: 10%;
}
.card-center {
width: 31%;
margin-right: 25px;
margin-bottom: 10px;
border-radius: 2%;
}
.card-bottom {
margin-right: 10px;
height: 300px;
}
</style>