Compare commits

...

2 Commits

Author SHA1 Message Date
YuNan 60750d0ca4 页面优化 和 数据导入功能 2024-10-23 14:00:52 +08:00
YuNan 4aef7d706d 页面优化 和 数据导入 2024-10-23 14:00:27 +08:00
4 changed files with 321 additions and 256 deletions

View File

@ -22,16 +22,6 @@
</a-card>
<a-card>
<!--<template #extra>
<div style="display: flex">
<div v-if="topCollege != null">
<span style="font-size: 15px; padding-left: 100px">该数据为 </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>
</div>
</div>
</template>-->
<div>
<div id="map1" style="width: 100%; height: 400px"></div>
</div>
@ -48,25 +38,6 @@
</a-card>
</a-col>
</a-row>
<!-- <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="font-size: 15px;padding-left: 100px;">该数据为 </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>
</div>
</div>
<div id="map1" style="width: 100%; height: 500px"></div>
</div>
</a-col>
</a-row>
</div> -->
</a-card>
</div>
</template>
@ -209,7 +180,7 @@
}
console.log(result.data, 'result');
let titleText = major ? `${college} / ${major}专业 最新批次通过人数饼图` : `${college} 最新批次通过人数饼图`;
let titleText = major ? `${college} / ${major}专业 最新批次通过人数` : `${college} 最新批次通过人数`;
// 使 API
let chartData = [];
@ -221,109 +192,57 @@
});
}
console.log(chartData, '123');
let xData = chartData.map((item) => item.name); //
let yData = chartData.map((item) => item.value); //
let option = {
tooltip: {
trigger: 'item',
//conginee: false,
//
itemStytle: {
//
shadowBlur: 10, //
shadowColor: 'rgba(0, 0, 0, 0.3)', //
shadowOffsetX: 5, //
shadowOffsetY: 5, //
fontSize: 100,
},
grid: {
left: '20%', //
right: '5%', //
top: '15%', //
bottom: '10%', //
},
title: {
text: '最新批次每一年级的通过率饼图',
text: '最新批次每一年级的通过率',
left: 'top',
top: '0%',
textStyle: {
fontSize: 12,
},
},
legend: {
top: '15%',
left: 'center',
// orient: 'vertical',
itemGap: 3,
selectedMode: true,
// inactiveColor: '#ccc',
// icon: 'circle',
// formatter: function (name) {
// var value;
// for (var i = 0; i < data.length; i++){
// if(data[i].name == name){
// value = data[i].value;
// }
// }
// return name + ' : ' + Math.round(value / num * 10000) / 100 + "%";
// },
tooltip: {
trigger: 'item',
},
xAxis: {
type: 'category',
data: xData,
//data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value}%',
},
},
color: ['#b3cde0', '#6497b1', '#005b96', '#03396c', '#e5e5e5'],
series: [
{
name: titleText,
type: 'pie',
radius: ['50%', '100%'],
center: ['50%', '50%'],
startAngle: 130,
top: 80,
//
data: yData,
//data: [150, 230, 224, 218, 135, 147, 260],
type: 'line',
itemStyle: {
// borderRadius: 5,
// borderColor: '#fff',
borderWidth: 2,
},
normal: {
label: {
show: true,
// position: 'inside',
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 12,
overflow: 'truncate',
},
labelLine: {
show: true,
smooth: true,
length: 10,
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
label: {
show: true,
fontSize: 15,
fontWeight: 'bold',
formatter: '{c}%',
},
},
data: chartData,
},
{
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: chartData,
},
],
};
@ -405,6 +324,7 @@
show: true, //
position: 'top', //
formatter: '{c}%', //
fontSize: '10px',
},
},
],

View File

@ -23,17 +23,6 @@
</a-card>
<a-card>
<!--<template #extra>
<div style="display: flex">
<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>
</template>-->
<div>
<div id="map1" style="width: 100%; height: 400px"></div>
</div>
@ -44,42 +33,60 @@
<a-card style="margin-bottom: 10px">
<div style="width: 100%; height: 210px; padding: 10px" class="participate_Piechart" id="participate_Piechart"></div>
</a-card>
<a-card>
<div style="width: 100%; height: 210px; padding: 10px" class="pass_Piechart" id="pass_Piechart"></div>
<a-card style="height: 268px">
<div>
<a-table
:dataSource="dataSourceCet4"
:columns="columns"
:pagination="false"
bordered
class="custom-table"
:style="{ fontSize: '12px', color: '#333', marginTop: '-11px' }"
/>
</div>
</a-card>
</a-col>
</a-row>
<!-- <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: 600px;"></div>
</div>
</a-col>
</a-row>
</div> -->
</a-card>
</div>
</template>
<script>
//import { pagination } from 'mock/_util';
import { defHttp } from '/@/utils/http/axios';
import * as echarts from 'echarts';
export default {
data() {
return {
dataSourceCet4: [],
columns: [
{
title: '年级',
dataIndex: 'grade',
key: 'grade',
align: 'center',
},
{
title: '参加人数',
dataIndex: 'attendNumber',
key: 'attendNumber',
align: 'center',
},
{
title: '通过人数',
dataIndex: 'passNumber',
key: 'passNumber',
align: 'center',
},
{
title: '通过率',
dataIndex: 'passrate',
key: 'passrate',
align: 'center',
},
],
Url: {
getBatch: '/cet/getBatch',
getCollege: '/cet/getCollege',
@ -179,6 +186,7 @@
},
series: [
{
barMaxWidth: 50, //
data: yData,
type: 'bar',
itemStyle: {
@ -264,93 +272,122 @@
};
resultData = await defHttp.get({ url: this.Url.getRate, params });
this.sumRate = resultData.sumRate;
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; //
console.log(this.dataSourceCet4, 'dataSourceCet4');
} finally {
this.loading = false;
this.$nextTick(() => {
this.dataChart(resultData.data);
this.draPieChart_Pass();
//this.draPieChart_Pass();
this.draPieChart_Participate();
});
}
},
//--cet4
draPieChart_Pass() {
//console.log(this.passRatePie);
//console.log('piedata', piedata);
let myChart = echarts.init(document.getElementById('pass_Piechart'));
//--
//draPieChart_Pass() {
// //console.log(this.passRatePie);
// //console.log('piedata', piedata);
// let myChart = echarts.init(document.getElementById('pass_Piechart'));
let option = {
tooltip: {
trigger: 'item',
conginee: false,
//
itemStytle: {
fontSize: 100,
},
},
//title: {
// text: '/',
// let option = {
// tooltip: {
// trigger: 'item',
// conginee: false,
// //
// itemStytle: {
// fontSize: 100,
// },
// },
// title: {
// text: '',
// left: 'top',
// top: '0%',
// textStyle: {
// fontSize: 12,
// },
// },
// legend: {
// top: '5%',
// left: 'center',
// },
// color: ['#ec2e30', '#c75af1', '#2b9eef', '#eee03f', '#2aed91', '#c5ed3c'],
// series: [
// {
// name: '/',
// type: 'pie',
// radius: ['0', '100%'],
// top: 80,
// itemStyle: {
// borderRadius: 5,
// borderColor: '#fff',
// borderWideth: 2,
// },
// label: {
// show: true,
// fontSize: 12,
// overflow: 'truncate',
// },
// emphasis: {
// itemStyle: {
// shadowBlur: 10,
// shadowOffsetX: 0,
// shadowColor: 'rgba(0, 0, 0, 0.5)',
// },
// label: {
// show: true,
// fontSize: 15,
// fontWeight: 'bold',
// },
// },
// data: [
// { value: 1048, name: '' },
// { value: 735, name: '' },
// { value: 580, name: '' },
// { value: 484, name: '' },
// { value: 300, name: '' },
// ],
// },
// ],
// };
// myChart.setOption(option);
//},
legend: {
top: '5%',
left: 'center',
},
color: ['#ec2e30', '#c75af1', '#2b9eef', '#eee03f', '#2aed91', '#c5ed3c'],
series: [
{
name: '学院/专业该批次通过人数饼图',
type: 'pie',
radius: ['0', '100%'],
top: 80,
itemStyle: {
borderRadius: 5,
borderColor: '#fff',
borderWideth: 2,
},
label: {
show: true,
fontSize: 12,
overflow: 'truncate',
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
label: {
show: true,
fontSize: 15,
fontWeight: 'bold',
},
},
data: [
{ value: 1048, name: '你好' },
{ value: 735, name: '不好' },
{ value: 580, name: '孤寡' },
{ value: 484, name: '小鸟伏特加' },
{ value: 300, name: '喜喜' },
],
},
],
};
myChart.setOption(option);
},
//--
draPieChart_Participate() {
//--
async draPieChart_Participate() {
//console.log(this.passRatePie);
//console.log('piedata', piedata);
let myChart = echarts.init(document.getElementById('participate_Piechart'));
let queryParams = {
batch: this.batch,
college: this.collegeMajor,
level: 'cet4',
};
console.log(queryParams, 'queryParams');
let url = this.Url.getRate;
let result = await defHttp.get({ url: url, 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',
@ -365,32 +402,20 @@
fontSize: 100,
},
},
// title: {
// text: '/',
// left: 'top',
// top: '0%',
// textStyle: {
// fontSize: 12,
// },
// },
title: {
text: '该批次每一年级的通过率饼图',
left: 'top',
top: '0%',
textStyle: {
fontSize: 12,
},
},
legend: {
top: '5%',
top: '10%',
left: 'center',
// orient: 'vertical',
itemGap: 3,
selectedMode: true,
// inactiveColor: '#ccc',
// icon: 'circle',
// formatter: function (name) {
// var value;
// for (var i = 0; i < data.length; i++){
// if(data[i].name == name){
// value = data[i].value;
// }
// }
// return name + ' : ' + Math.round(value / num * 10000) / 100 + "%";
// },
},
color: ['#ec2e30', '#c75af1', '#2b9eef', '#eee03f', '#2aed91', '#c5ed3c'],
@ -431,13 +456,7 @@
fontWeight: 'bold',
},
},
data: [
{ value: 1048, name: '你好' },
{ value: 735, name: '不好' },
{ value: 580, name: '孤寡' },
{ value: 484, name: '小鸟伏特加' },
{ value: 300, name: '喜喜' },
],
data: chartsData,
},
{
type: 'pie',
@ -460,13 +479,7 @@
tooltip: {
show: false,
},
data: [
{ value: 1048, name: '你好' },
{ value: 735, name: '不好' },
{ value: 580, name: '孤寡' },
{ value: 484, name: '小鸟伏特加' },
{ value: 300, name: '喜喜' },
],
data: chartsData,
},
],
};

View File

@ -0,0 +1,132 @@
<template>
<div style="background: #ececec; padding-top: 0px; padding-left: 20px; padding-right: 20px; padding-bottom: 20px">
<a-card title="英语四级数据导入" :bordered="false">
<a-row :gutter="2">
<a-col :xl="3" :style="{ marginBottom: '24px' }">
<a-space direction="vertical" :size="12">
<a-date-picker v-model:value="month" picker="month" />
</a-space>
</a-col>
<a-col :xl="5" :style="{ marginBottom: '24px' }">
<div class="clearfix">
<!-- accept=".dbf" 属性限制文件类型 -->
<a-upload :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
<a-button type="primary">
<upload-outlined />
导入文件
</a-button>
</a-upload>
<div class="clearfix">
<a-button preIcon="ant-design:export-outlined" @click="onExportXls"> 下载模板</a-button>
</div>
<div class="clearfix">
<a-button type="primary" :disabled="!canUpload" :loading="uploading" @click="handleUpload">
{{ uploading ? 'Uploading' : '确认上传文件' }}
</a-button>
</div>
</div>
</a-col>
<a-col :xl="1" :style="{ marginBottom: '24px' }" />
</a-row>
<a-row :gutter="10">
<a-col :xl="24">
<a-table :dataSource="dataSourceCet4" :columns="columns" :pagination="false" :loading="loading" bordered class="custom-table" />
</a-col>
</a-row>
</a-card>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { message } from 'ant-design-vue';
//
const month = ref(null);
//
const fileList = ref([]);
const uploading = ref(false);
//
const canUpload = computed(() => fileList.value.length > 0 && month.value !== null);
//
const handleRemove = (file) => {
const index = fileList.value.indexOf(file);
const newFileList = fileList.value.slice();
newFileList.splice(index, 1);
fileList.value = newFileList;
};
//
const beforeUpload = (file) => {
fileList.value = [...fileList.value, file];
return false; //
};
//
const handleUpload = async () => {
const formData = new FormData();
fileList.value.forEach((file) => {
formData.append('files[]', file);
});
uploading.value = true;
try {
let queryParams = {
month: month,
formData: formData,
};
const response = await defHttp.post({ url: url, data: queryParams });
fileList.value = [];
month.value = null; //
message.success('Upload successfully.');
} catch (error) {
message.error('Upload failed.');
} finally {
uploading.value = false;
}
};
//
const dataSourceCet4 = ref([]);
//
const columns = [
{
title: '考试批次',
dataIndex: 'batch',
key: 'batch',
align: 'center',
},
{
title: '参加人数',
dataIndex: 'attendNumber',
key: 'attendNumber',
align: 'center',
},
];
//
const fetchData = async () => {
loading.value = true; //
try {
const response = await defHttp.get('/api/words');
console.log(response, 'response');
dataSourceCet4.value = response.data; //
} catch (error) {
message.error('Failed to load data.');
} finally {
loading.value = false; //
}
};
// fetchData
onMounted(fetchData);
</script>
<style scoped>
.clearfix {
display: flex;
padding-left: 10px;
}
</style>