CET-vue-3.0/src/views/dashboard/Analysis/index.vue

324 lines
9.7 KiB
Vue
Raw Normal View History

2022-03-17 14:58:49 +08:00
<template>
2024-04-10 21:34:49 +08:00
<div style="background: #ececec; padding: 15px">
2024-03-27 18:46:10 +08:00
<a-card title="四级总通过率查询" :loading="loading" :bordered="false">
2024-03-26 17:33:19 +08:00
<template #extra>
2024-04-02 18:00:44 +08:00
<a-cascader v-model:value="collegeMajor" :options="collegeMajorOptions" change-on-select />
2024-03-27 16:10:08 +08:00
<a-select v-model:value="entrydate" style="margin-left: 10px;width: 100px"
2024-03-26 17:33:19 +08:00
:options="entrydateOptions"></a-select>
2024-03-27 15:49:00 +08:00
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button>
2024-04-08 16:41:42 +08:00
<!-- <a-button @click=test()>test</a-button> -->
2024-03-26 17:33:19 +08:00
</template>
<a-row :gutter="24">
2024-04-10 21:34:49 +08:00
<a-col :xl="13">
2024-03-27 18:26:50 +08:00
<div style="padding-left: 10px;min-height: 400px;">
2024-04-08 16:41:42 +08:00
<a-table :dataSource="dataSourceCet4" :columns="columns" :pagination='false' bordered>
<template v-slot:passRateSlot>
累计总通过率
2024-04-20 20:57:10 +08:00
<a-tooltip :title="'累计通过人数 / ' + this.totalName + '总人数'" placement="top">
2024-04-08 16:41:42 +08:00
<a-icon type="question-circle" />
</a-tooltip>
</template>
2024-03-27 18:26:50 +08:00
</a-table>
2024-04-15 21:55:27 +08:00
<div style="display: flex; justify-content: space-between; font-size: 15px; margin-top: 10px;"
v-if="total && total > 0">
2024-04-20 20:57:10 +08:00
<span>{{ this.totalName }}总人数{{ total }}</span>
2024-04-15 21:55:27 +08:00
<span>累计通过人数: {{ passNumberBottom }}</span>
<span>累计总通过率: {{ passRateBottom }}</span>
</div>
2024-04-10 21:34:49 +08:00
</div>
</a-col>
<a-col :xl="11">
<div style="width: 100%;height: 500px;padding: 10px;" class="piechart" id="piechart">
2024-03-27 18:26:50 +08:00
</div>
2024-03-26 17:33:19 +08:00
</a-col>
</a-row>
2024-04-10 21:34:49 +08:00
<!-- <div style="height: 300px;">
<a-empty style="margin-top: 100px" />
</div> -->
2024-03-26 17:33:19 +08:00
</a-card>
2024-03-26 13:30:08 +08:00
</div>
2022-03-17 14:58:49 +08:00
</template>
2024-03-26 13:30:08 +08:00
<script>
2024-03-26 17:33:19 +08:00
import { defHttp } from '/@/utils/http/axios';
2024-03-26 13:30:08 +08:00
import * as echarts from 'echarts';
export default {
2024-03-26 17:33:19 +08:00
name: "Analysis",
data() {
return {
2024-03-27 18:46:10 +08:00
loading: false,
2024-03-27 15:49:00 +08:00
dataSourceCet4: [],
columns: [
{
2024-04-20 20:57:10 +08:00
title: '学年',
2024-03-27 15:49:00 +08:00
dataIndex: 'grade',
key: 'grade',
2024-04-08 16:41:42 +08:00
align: 'center',
2024-04-10 21:34:49 +08:00
customCell: (_, index) => ({
2024-04-17 21:44:36 +08:00
rowSpan: index % 2 === 0 ? 2 : 0,//每两行合并一次grade列的单元格rowSpan为跨度
2024-04-10 21:34:49 +08:00
}),
2024-03-27 15:49:00 +08:00
},
{
2024-04-08 16:41:42 +08:00
title: '考试批次',
dataIndex: 'batch',
key: 'batch',
align: 'center',
},
{
2024-04-10 21:34:49 +08:00
title: '参加人数',
2024-03-27 15:49:00 +08:00
dataIndex: 'attendNumber',
key: 'attendNumber',
2024-04-08 16:41:42 +08:00
align: 'center',
2024-03-27 15:49:00 +08:00
},
{
2024-04-20 20:57:10 +08:00
title: '通过人数',
2024-03-27 15:49:00 +08:00
dataIndex: 'passNumber',
key: 'passNumber',
2024-04-08 16:41:42 +08:00
align: 'center',
2024-03-27 15:49:00 +08:00
},
2024-04-10 21:34:49 +08:00
{
title: '本批次通过率',
dataIndex: 'batchpassrate',
key: 'batchpassrate',
align: 'center',
},
2024-03-27 15:49:00 +08:00
{
2024-04-08 16:41:42 +08:00
slots: { title: 'passRateSlot' },
2024-04-10 21:34:49 +08:00
dataIndex: 'gradepassrate',
key: 'gradepassrate',
2024-04-08 16:41:42 +08:00
align: 'center',
2024-04-10 21:34:49 +08:00
customCell: (_, index) => ({
rowSpan: index % 2 === 0 ? 2 : 0,
}),
2024-03-27 15:49:00 +08:00
}
],
2024-03-26 17:33:19 +08:00
Url: {
2024-03-27 16:10:08 +08:00
getEntrydate: '/cet/getEntrydate',
getCollege: '/cet/getCollege',
2024-04-02 18:00:44 +08:00
getData: '/cet/getData',
getCollegeMajor: '/cet/getCollegeMajor'
2024-03-26 17:33:19 +08:00
},
2024-03-27 18:26:50 +08:00
total: 0,
2024-04-20 20:57:10 +08:00
totalName: '',
2024-04-15 21:55:27 +08:00
passNumberBottom: 0,
passRateBottom: 0,
passRatePie: [],
2024-03-26 17:33:19 +08:00
collegeOptions: [],
2024-04-02 18:00:44 +08:00
collegeMajorOptions: [],
2024-03-26 17:33:19 +08:00
entrydateOptions: [],
college: null,
2024-04-02 18:00:44 +08:00
entrydate: null,
collegeMajor: null
2024-03-26 17:33:19 +08:00
};
},
2024-03-26 13:30:08 +08:00
methods: {
2024-03-26 17:33:19 +08:00
// 获取年级和学院数据
2024-03-27 16:10:08 +08:00
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: '全校' });
2024-03-27 15:49:00 +08:00
this.college = this.collegeOptions[0].value;
2024-03-27 16:10:08 +08:00
this.entrydateOptions = getEntrydate.entrydates;
2024-03-26 17:33:19 +08:00
this.entrydate = this.entrydateOptions[0].value;
2024-03-27 15:49:00 +08:00
},
2024-04-02 18:00:44 +08:00
//获取学院专业级联数据
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
}
})
}
});
2024-04-08 16:41:42 +08:00
//手动添加一个专升本字段
this.collegeMajorOptions.unshift({ value: '专升本', label: '专升本' });
2024-04-02 18:00:44 +08:00
// 手动添加一个全校字段
this.collegeMajorOptions.unshift({ value: '全校', label: '全校' });
this.collegeMajor = ['全校'];
console.log(this.collegeMajorOptions);
},
2024-04-10 21:34:49 +08:00
2024-03-27 15:49:00 +08:00
// 查询数据
async query() {
2024-03-27 18:46:10 +08:00
try {
2024-04-02 18:00:44 +08:00
//如果this.collegeMajor[1]不存在则设为null
let major = this.collegeMajor.length > 1 ? this.collegeMajor[1] : "";
if (this.college)
this.loading = true;
2024-03-27 18:46:10 +08:00
let params = {
2024-04-02 18:00:44 +08:00
college: this.collegeMajor[0],
major: major,
2024-03-27 18:46:10 +08:00
entrydate: this.entrydate
}
2024-04-02 18:00:44 +08:00
console.log("params", params);
2024-03-27 18:46:10 +08:00
const result = await defHttp.get({ url: this.Url.getData, params });
2024-04-10 21:34:49 +08:00
let tableData = [];
let piedata = [];
let passrate = 0;
let index = 0;
for (let grade in result.cet4) {
result.cet4[grade].forEach(item => {
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,
2024-04-15 21:55:27 +08:00
gradepassrate: (item.gradepassrate * 100).toFixed(1) + '%',
2024-04-10 21:34:49 +08:00
passNumber: item.passNumber,
2024-04-15 21:55:27 +08:00
batchpassrate: (item.batchpassrate * 100).toFixed(1) + '%'
2024-04-10 21:34:49 +08:00
});
});
}
console.log("tableData", tableData);
2024-04-17 21:44:36 +08:00
this.dataSourceCet4 = tableData;//表格数据
this.total = result.total;//总人数
2024-04-20 20:57:10 +08:00
this.totalName = result.totalName;//总人数名称
2024-04-17 21:44:36 +08:00
this.passNumberBottom = result.passNumber;//通过人数
this.passRateBottom = (result.passRate * 100).toFixed(1) + '%';//通过率
2024-04-15 21:55:27 +08:00
//内置饼图
2024-04-20 20:57:10 +08:00
this.passRatePie = []//清空数据
2024-04-15 21:55:27 +08:00
this.passRatePie.push({ value: result.passRate, name: '已通过' });
this.passRatePie.push({ value: 1 - result.passRate, name: '未通过' })
2024-04-17 21:44:36 +08:00
piedata.push({ value: (1 - passrate).toFixed(3), name: '未通过' });//外置饼图
2024-04-10 21:34:49 +08:00
setTimeout(() => {
this.drawPieChart(piedata);
}, 100);
// this.drawPieChart();
2024-03-27 18:46:10 +08:00
} finally {
this.loading = false;
2024-03-27 15:49:00 +08:00
}
2024-04-02 18:00:44 +08:00
},
2024-04-08 16:41:42 +08:00
test() {
defHttp.get({ url: "/cet/getTest" });
2024-04-10 21:34:49 +08:00
},
drawPieChart(piedata) {
2024-04-15 21:55:27 +08:00
console.log(this.passRatePie)
console.log("piedata", piedata)
2024-04-10 21:34:49 +08:00
let myChart = echarts.init(document.getElementById('piechart'));
let option = {
tooltip: {
trigger: 'item',
confine: false,
2024-04-15 21:55:27 +08:00
//字体大小
2024-04-20 20:57:10 +08:00
itemStyle: {
fontSize: 100
2024-04-15 21:55:27 +08:00
}
2024-04-10 21:34:49 +08:00
},
2024-04-20 20:57:10 +08:00
2024-04-10 21:34:49 +08:00
title: {
text: '四级通过率分析',
left: 'left',
top: '0%',
textStyle: {
fontSize: 20
}
},
legend: {
top: '5%',
left: 'center'
},
2024-05-27 13:23:32 +08:00
color: ['#b3cde0', '#6497b1', '#005b96', '#03396c', '#e5e5e5'],
2024-04-15 21:55:27 +08:00
2024-04-10 21:34:49 +08:00
series: [
2024-04-15 21:55:27 +08:00
//内圈饼图
2024-04-20 20:57:10 +08:00
// {
// name: '四级通过率',
// type: 'pie',
// radius: ['0', '30%'],
// avoidLabelOverlap: false,
// itemStyle: {
// borderRadius: 3,
// borderColor: '#fff',
// borderWidth: 2,
// },
// label: {
// position: 'inner',
// fontSize: 14
// },
// emphasis: {
// label: {
// show: true,
// fontSize: 20,
// fontWeight: 'bold'
// }
// },
// data: this.passRatePie
// },
2024-04-15 21:55:27 +08:00
//外圈饼图
{
name: '四级通过率',
type: 'pie',
2024-04-20 20:57:10 +08:00
radius: ['35%', '60%'],
2024-04-10 21:34:49 +08:00
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
2024-04-15 21:55:27 +08:00
borderWidth: 2,
},
label: {
show: true,
2024-04-20 20:57:10 +08:00
fontSize: 14,
2024-04-15 21:55:27 +08:00
overflow: 'truncate'
2024-04-10 21:34:49 +08:00
},
emphasis: {
2024-04-20 20:57:10 +08:00
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
2024-04-10 21:34:49 +08:00
label: {
show: true,
2024-04-20 20:57:10 +08:00
fontSize: 15,
2024-04-10 21:34:49 +08:00
fontWeight: 'bold'
}
},
data: piedata
}
]
};
myChart.setOption(option);
2024-04-08 16:41:42 +08:00
}
2024-03-26 13:30:08 +08:00
},
mounted() {
2024-03-27 16:10:08 +08:00
this.getEntrydateAndCollegeData();
2024-04-02 18:00:44 +08:00
this.getCollegeMajorData();
2024-03-26 13:30:08 +08:00
}
2024-04-10 21:34:49 +08:00
2024-03-26 13:30:08 +08:00
}
2022-03-17 14:58:49 +08:00
</script>
2024-03-26 13:30:08 +08:00
<style lang="less" scoped>
2024-03-27 16:10:08 +08:00
.container {
display: flex;
background-color: #fff;
padding: 15px;
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
}
2024-03-26 13:30:08 +08:00
.title {
font-size: 34px;
color: rgb(8, 8, 8);
font-weight: bold;
}
2024-03-27 16:10:08 +08:00
</style>