CET-vue-3.0/src/views/cet/cet-ana-1.vue

146 lines
3.6 KiB
Vue
Raw Normal View History

2024-03-26 13:30:08 +08:00
<template>
2024-03-27 17:08:37 +08:00
<div style="background: #ececec; padding: 25px">
2024-03-27 18:26:50 +08:00
<a-card title="按学院分析" :loading="loading" :bordered="false">
2024-03-27 17:08:37 +08:00
<template #extra>
<!-- <a-select v-model:value="college" style="width: 300px" :options="collegeOptions"></a-select> -->
<a-select v-model:value="batch" style="margin-left: 10px;width: 120px" :options="batchOptions"></a-select>
<!-- <a-select v-model:value="level" style="margin-left: 10px;width: 120px" :options="levelOptions"></a-select> -->
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button>
</template>
2024-03-26 13:30:08 +08:00
<a-row :gutter="24">
2024-03-27 17:08:37 +08:00
<a-col :xl="24" :style="{ marginBottom: '24px' }">
2024-03-26 13:30:08 +08:00
<div class="container">
2024-03-27 17:08:37 +08:00
<div id="map1" style="width: 660px; height: 400px;"></div>
2024-03-26 13:30:08 +08:00
</div>
</a-col>
</a-row>
2024-03-27 17:08:37 +08:00
</a-card>
</div>
</template>
<script>
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'
2024-03-26 13:30:08 +08:00
},
2024-03-27 18:26:50 +08:00
loading: false,
2024-03-27 17:08:37 +08:00
collegeOptions: [],
batchOptions: [],
levelOptions: [
{ value: 'cet4', label: '英语四级' },
{ value: 'cet6', label: '英语六级' }
],
level: null,
college: null,
batch: null
};
},
methods: {
2024-03-27 18:26:50 +08:00
dataChart() {
2024-03-27 17:08:37 +08:00
// 基于准备好的dom初始化echarts实例 这个和上面的main对应
let myChart = echarts.init(document.getElementById("map1"));
// 指定图表的配置项和数据
let option = {
title: {
text: "总上座人数对比",
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: ["英国", "中国"],//上方的标签
},
xAxis: {
data: ["一级", "二级", "三级", "四级"],
axisLabel: {
interval: 0,
// rotate: 30
}
},
yAxis: {
name: '总上座人数(万)',
},
series: [
{
name: "英国",
type: "bar",
data: [1450, 1100, 450, 300],
label: {
formatter: '{@value}'
2024-03-26 13:30:08 +08:00
}
},
2024-03-27 17:08:37 +08:00
{
name: "中国",
type: "bar",
data: [552, 180, 200, 0],
label: {
formatter: '{@value}'
2024-03-26 13:30:08 +08:00
}
},
2024-03-27 17:08:37 +08:00
],
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
},
// 获取批次数据
async getBatch() {
const getBatch = await defHttp.get({ url: this.Url.getBatch });
this.batchOptions = getBatch.batches;
this.batch = this.batchOptions[0].value;
this.level = this.levelOptions[0].value;
2024-03-27 18:46:10 +08:00
this.query();
2024-03-26 13:30:08 +08:00
},
2024-03-27 17:08:37 +08:00
// 查询数据
async query() {
2024-03-27 18:46:10 +08:00
try {
this.loading = true;
let params = {
batch: this.batch,
level: 'cet4'
}
const data = await defHttp.get({ url: this.Url.getRate, params });
} finally {
this.loading = false;
this.$nextTick(() => {
this.dataChart();
})
2024-03-27 17:08:37 +08:00
}
2024-03-26 13:30:08 +08:00
}
2024-03-27 17:08:37 +08:00
},
mounted() {
this.getBatch();
2024-03-27 18:26:50 +08:00
this.dataChart();
2024-03-26 13:30:08 +08:00
}
2024-03-27 17:08:37 +08:00
}
</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;
}
</style>