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

1015 lines
33 KiB
Vue
Raw Normal View History

2024-03-26 13:30:08 +08:00
<template>
2024-04-10 21:34:49 +08:00
<div style="background: #ececec; padding: 15px">
<a-card :bordered="false">
2024-04-23 15:52:49 +08:00
<a-tabs v-model:activeKey="activeKey" type="card">
<a-tab-pane key="1" tab="查询全校各学院通过率">
<div>
<div class="query">
2024-04-26 21:31:34 +08:00
<span style="font-size: 15px; margin-right: 10px; display: flex; justify-content: center; align-items: center; font-weight: bold"
>年级:
</span>
2024-04-23 23:55:23 +08:00
<a-select v-model:value="oneentrydate" style="width: 200px" :options="entrydateOptions"></a-select>
2024-04-26 21:31:34 +08:00
<a-button style="margin-left: 10px" type="primary" @click="allQuery">查询</a-button>
2024-04-23 15:52:49 +08:00
</div>
<a-card title="查询全校各学院通过率" :loading="tab1loading" :bordered="false">
<template #extra>
<!-- <a-select v-model:value="college" style="width: 300px" mode="multiple" :max-tag-count="2"
:options="collegeOptions" @change="onCollegeMajorChange"></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-select v-model:value="entrydate" style="margin-left: 10px;width: 150px"
:options="entrydateOptions"></a-select>
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button> -->
</template>
<a-row :gutter="24">
<a-col :xl="24" :style="{ marginBottom: '24px' }">
<div class="container">
2024-04-26 21:31:34 +08:00
<div id="map1" style="width: 100%; height: 600px"></div>
2024-04-23 15:52:49 +08:00
</div>
</a-col>
</a-row>
</a-card>
</div>
</a-tab-pane>
<a-tab-pane key="2" tab="对比多学院" force-render>
<div>
<div class="query">
2024-04-26 21:31:34 +08:00
<span style="font-size: 15px; margin-right: 10px; display: flex; justify-content: center; align-items: center; font-weight: bold"
>学院:
</span>
<a-select
v-model:value="collegetab2"
style="width: 300px; margin-right: 20px"
mode="multiple"
:max-tag-count="5"
:options="collegeOptions"
@change="onCollegeChange"
></a-select>
<span style="font-size: 15px; margin-right: 10px; display: flex; justify-content: center; align-items: center; font-weight: bold"
>年级:
</span>
<a-select
v-model:value="collegeentrydate"
style="width: 200px"
:options="entrydateOptions"
mode="multiple"
:max-tag-count="5"
@change="onCollegeChange"
></a-select>
<a-button style="margin-left: 10px" type="primary" @click="collegeQuery">查询</a-button>
2024-04-23 15:52:49 +08:00
</div>
<a-card title="按学院分析" :loading="tab2loading" :bordered="false">
<template #extra>
<!-- <a-select v-model:value="college" style="width: 300px" mode="multiple" :max-tag-count="2"
:options="collegeOptions" @change="onCollegeMajorChange"></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-select v-model:value="entrydate" style="margin-left: 10px;width: 150px"
:options="entrydateOptions"></a-select>
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button> -->
</template>
<a-row :gutter="24">
<a-col :xl="24" :style="{ marginBottom: '24px' }">
<div class="container">
2024-04-26 21:31:34 +08:00
<div id="map2" style="width: 100%; height: 600px"></div>
2024-04-23 15:52:49 +08:00
</div>
</a-col>
</a-row>
</a-card>
</div>
</a-tab-pane>
<a-tab-pane key="3" tab="对比多专业">
<div>
2024-04-26 21:31:34 +08:00
<div class="tab3">
<!-- <span style="font-size: 15px;margin-right: 10px; display: flex;justify-content: center;align-items: center;
font-weight: bold;">专业: </span>
2024-04-23 15:52:49 +08:00
<a-cascader v-model:value="collegeMajor" style="width: 300px;margin-right: 20px;"
2024-04-26 21:31:34 +08:00
:options="collegeMajorOptions" :changeOnSelect="false" multiple :maxTagCount="5" expandTrigger="hover"
2024-04-23 23:55:23 +08:00
@change="onMajorChange" />
2024-04-26 21:31:34 +08:00
<span style="font-size: 15px;margin-right: 10px;font-weight: bold;display: flex;
justify-content: center;align-items: center;">年级: </span>
2024-04-23 15:52:49 +08:00
<a-select v-model:value="majorentrydate" style="width: 200px" :options="entrydateOptions" mode="multiple"
2024-04-26 21:31:34 +08:00
:max-tag-count="5" @change="onCollegeMajorChange"></a-select>
<a-button style="margin-left: 10px;" type="primary" @click="majorQuery">查询</a-button> -->
<div style="display: flex">
<span style="font-size: 15px; margin-right: 10px; font-weight: bold; display: flex; justify-content: center; align-items: center"
>年级:
</span>
<a-checkbox-group v-model:value="majorentrydate" :options="entrydateOptions" @change="onMajorEntrydateChange" />
</div>
<div style="display: flex; margin-top: 10px">
<span style="font-size: 15px; margin-right: 10px; font-weight: bold; display: flex; justify-content: center; align-items: center"
>学院:
</span>
<a-radio-group v-model:value="collegeMajor" :options="collegeMajorOptions" @change="onMajorCollegeChange" />
</div>
<div style="display: flex; margin-top: 10px">
<span style="font-size: 15px; margin-right: 10px; font-weight: bold; display: flex; justify-content: center; align-items: center"
>专业:
</span>
<a-checkbox-group v-model:value="majorCheckOn" :options="majorOptions" @change="onCollegeMajorChange" />
</div>
<div style="margin-top: 20px;margin-right: 20px;
display: flex;
justify-content: flex-end;
align-items: center;
">
<a-button style="margin-left: 10px;" type="primary" @click="clear">清除</a-button>
<a-button style="margin-left: 10px;" type="primary" @click="majorQuery">查询</a-button>
</div>
2024-04-23 15:52:49 +08:00
</div>
<a-card title="按专业分析" :loading="tab3loading" :bordered="false">
<template #extra>
<!-- <a-select v-model:value="college" style="width: 300px" mode="multiple" :max-tag-count="2"
:options="collegeOptions" @change="onCollegeMajorChange"></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-select v-model:value="entrydate" style="margin-left: 10px;width: 150px"
:options="entrydateOptions"></a-select>
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button> -->
</template>
<a-row :gutter="24">
<a-col :xl="24" :style="{ marginBottom: '24px' }">
<div class="container">
2024-04-26 21:31:34 +08:00
<div id="map3" style="width: 100%; height: 600px"></div>
2024-04-23 15:52:49 +08:00
</div>
</a-col>
</a-row>
</a-card>
</div>
</a-tab-pane>
</a-tabs>
<!-- <div>
<a-button type="primary" @click="visible = true">打开筛选项</a-button>
2024-04-23 15:52:49 +08:00
</div> -->
<!-- <a-drawer placement="right" :visible="visible" width="90%" :closable="false">
<template slot="title">
<span>CET查询筛选项</span>
</template>
<a-descriptions bordered>
<a-descriptions-item label="学院" :span="3">
2024-04-26 21:31:34 +08:00
<a-checkbox-group v-model="checkedOptions" :options="collegeOptions" :disabled="showGroup"
@change="checkOne"></a-checkbox-group>
</a-descriptions-item>
<a-descriptions-item label="年级" :span="3" v-if="showGroup">
<a-radio-group v-model:value="oneentrydate" :options="entrydateOptions" @change="checkoneentrydate" />
</a-descriptions-item>
<a-descriptions-item label="年级" :span="3" v-if="showBox">
<a-checkbox-group v-model:value="entrydate" :options="entrydateOptions" />
</a-descriptions-item>
</a-descriptions>
<div class="buttons">
<a-button type="primary" style="margin-right: 5px;" @click="visible = false"><a-icon
type="close" />取消</a-button>
2024-04-17 13:22:19 +08:00
<a-button type="primary" @click="query" style="margin-right: 5px;"><a-icon type="search" />查询</a-button>
</div>
2024-04-23 15:52:49 +08:00
</a-drawer> -->
</a-card>
2024-04-23 15:52:49 +08:00
<!-- <a-card title="按学院 / 专业分析" :loading="loading" :bordered="false">
<template #extra> -->
<!-- <a-select v-model:value="college" style="width: 300px" mode="multiple" :max-tag-count="2"
:options="collegeOptions" @change="onCollegeMajorChange"></a-select> -->
2024-04-23 15:52:49 +08:00
<!-- <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-select v-model:value="entrydate" style="margin-left: 10px;width: 150px"
2024-04-08 16:41:42 +08:00
:options="entrydateOptions"></a-select>
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button> -->
2024-04-23 15:52:49 +08:00
<!-- </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-04-20 20:57:10 +08:00
<div id="map1" style="width: 100%; height: 600px;"></div>
2024-03-26 13:30:08 +08:00
</div>
</a-col>
</a-row>
2024-04-23 15:52:49 +08:00
</a-card> -->
2024-03-27 17:08:37 +08:00
</div>
</template>
<script>
import { defHttp } from '/@/utils/http/axios';
import * as echarts from 'echarts';
import bar from '/@/components/Scrollbar/src/bar';
import { message } from 'ant-design-vue';
2024-04-26 21:31:34 +08:00
import { last } from 'xe-utils';
2024-04-23 15:52:49 +08:00
2024-03-27 17:08:37 +08:00
export default {
2024-04-26 21:31:34 +08:00
name: 'Analysis',
2024-03-27 17:08:37 +08:00
data() {
return {
2024-04-23 15:52:49 +08:00
activeKey: '1',
allCollege: [],
showBox: false,
showGroup: false,
oneentrydate: null,
2024-04-23 15:52:49 +08:00
collegeentrydate: [],
majorentrydate: [],
2024-04-26 21:31:34 +08:00
lastMajorEntrydate: [],
checkedOptions: [],
2024-04-23 15:52:49 +08:00
collegetab2: [],
collegeMajorOptions: [],
collegeMajor: [],
2024-03-27 17:08:37 +08:00
Url: {
getBatch: '/cet/getBatch',
2024-04-08 16:41:42 +08:00
getEntrydate: '/cet/getEntrydate',
2024-03-27 17:08:37 +08:00
getCollege: '/cet/getCollege',
2024-04-23 16:43:44 +08:00
getCollegeRate: '/cet/getRateByCollege',
getAllRate: '/cet/getAllRate',
2024-04-23 15:52:49 +08:00
getCollegeMajor: '/cet/getCollegeMajor',
getRateByMajor: '/cet/getRateByMajor',
2024-03-26 13:30:08 +08:00
},
2024-04-23 15:52:49 +08:00
tab1loading: false,
tab2loading: false,
tab3loading: false,
2024-03-27 17:08:37 +08:00
collegeOptions: [],
batchOptions: [],
levelOptions: [
{ value: 'cet4', label: '英语四级' },
2024-04-26 21:31:34 +08:00
{ value: 'cet6', label: '英语六级' },
2024-03-27 17:08:37 +08:00
],
visible: false,
2024-03-27 17:08:37 +08:00
level: null,
college: [],
2024-04-08 16:41:42 +08:00
batch: null,
entrydateOptions: [],
entrydate: [],
2024-04-26 21:31:34 +08:00
majorCheckOn: [],
lastCollegeMajor: [],
majorLength: 0,
majorOptions: [],
2024-03-27 17:08:37 +08:00
};
},
methods: {
2024-04-23 23:55:23 +08:00
onMajorChange(value) {
2024-04-26 21:31:34 +08:00
console.log(value, 'value');
2024-04-23 23:55:23 +08:00
let length = value.length;
//遍历value,与this.collegeMajorOptions比较如果value中的数据在this.collegeMajorOptions中则获得他的children长度
for (let i = 0; i < value.length; i++) {
for (let j = 0; j < this.collegeMajorOptions.length; j++) {
if (value[i] == this.collegeMajorOptions[j].value) {
length += this.collegeMajorOptions[j].children.length;
length -= 1;
2024-04-26 21:31:34 +08:00
}
if (length > 5) {
message.error('最多选择五个专业');
//删除value最后一个数据
value.pop();
return;
2024-04-23 23:55:23 +08:00
}
}
}
2024-04-26 21:31:34 +08:00
console.log(length, 'length');
2024-04-23 23:55:23 +08:00
},
2024-04-23 15:52:49 +08:00
allQuery() {
this.tab1loading = true;
let college = ['全校'];
2024-04-26 21:31:34 +08:00
let query = 'tab1';
2024-04-23 15:52:49 +08:00
if (this.oneentrydate == null) {
this.oneentrydate = '2017';
}
this.query(query, college, [this.oneentrydate]);
},
async majorQuery() {
2024-04-26 21:31:34 +08:00
if (this.lastCollegeMajor.length == 0 || this.lastCollegeMajor == null) {
message.error('请选择专业');
return;
2024-04-23 23:55:23 +08:00
}
if (this.majorentrydate.length == 0) {
2024-04-26 21:31:34 +08:00
message.error('请选择年级');
return;
2024-04-23 23:55:23 +08:00
}
2024-04-23 15:52:49 +08:00
this.tab3loading = true;
let res = null;
try {
let params = {
2024-04-26 21:31:34 +08:00
college: this.lastCollegeMajor,
2024-04-23 15:52:49 +08:00
entrydate: this.majorentrydate,
2024-04-26 21:31:34 +08:00
};
2024-04-23 15:52:49 +08:00
res = await defHttp.post({ url: this.Url.getRateByMajor, params });
2024-04-26 21:31:34 +08:00
} finally {
console.log(res, 'res');
2024-04-23 15:52:49 +08:00
this.tab3loading = false;
this.$nextTick(() => {
this.drawChart(res.data, 'tab3');
2024-04-26 21:31:34 +08:00
});
2024-04-23 15:52:49 +08:00
}
},
collegeQuery() {
2024-04-23 23:55:23 +08:00
if (this.collegetab2.length == 0) {
2024-04-26 21:31:34 +08:00
message.error('请选择学院');
return;
2024-04-23 23:55:23 +08:00
}
if (this.collegeentrydate.length == 0) {
2024-04-26 21:31:34 +08:00
message.error('请选择年级');
return;
2024-04-23 23:55:23 +08:00
}
2024-04-23 15:52:49 +08:00
this.tab2loading = true;
2024-04-26 21:31:34 +08:00
let query = 'tab2';
2024-04-23 15:52:49 +08:00
this.query(query, this.collegetab2, this.collegeentrydate);
},
test(value) {
2024-04-26 21:31:34 +08:00
console.log(this.collegeMajor);
console.log(value);
2024-04-23 15:52:49 +08:00
},
//选择全校
checkAll(e) {
2024-04-26 21:31:34 +08:00
this.college = ['全校'];
this.showGroup = !this.showGroup;
},
//选择学院
checkOne(e) {
2024-04-26 21:31:34 +08:00
console.log(e);
this.college = e;
this.showBox = true;
if (e.length == 0) {
this.showBox = false;
}
},
//选择年级
checkoneentrydate(e) {
2024-04-26 21:31:34 +08:00
console.log(e.target.value, 'e');
this.entrydate = [e.target.value];
},
2024-04-23 15:52:49 +08:00
//获取学院专业级联数据
async getCollegeMajorData() {
const res = await defHttp.get({ url: this.Url.getCollegeMajor });
//通过map方法将数据转换为级联选择器需要的数据格式
2024-04-26 21:31:34 +08:00
this.collegeMajorOptions = res.collegeMajor.map((item) => {
2024-04-23 15:52:49 +08:00
return {
value: item.college,
label: item.college,
2024-04-26 21:31:34 +08:00
children: item.major.map((major) => {
2024-04-23 15:52:49 +08:00
return {
value: major,
2024-04-26 21:31:34 +08:00
label: major,
};
}),
};
2024-04-23 15:52:49 +08:00
});
2024-04-26 21:31:34 +08:00
this.collegeMajor = ['东语学院', '日语'];
console.log(this.collegeMajor, 'collegeMajor');
console.log(this.collegeMajorOptions, 'collegeMajorOptions1');
2024-04-23 15:52:49 +08:00
},
2024-04-03 14:36:10 +08:00
getCollegeOptions() {
2024-04-26 21:31:34 +08:00
defHttp.get({ url: this.Url.getCollege }).then((res) => {
2024-04-03 14:36:10 +08:00
this.collegeOptions = res.colleges;
// 手动添加一个全校字段
2024-04-15 21:55:27 +08:00
2024-04-23 15:52:49 +08:00
// this.collegeOptions.unshift({ value: '全校', label: '全校' });
// this.collegeOptions.forEach(option => {
// if (option.value !== '全校') {
// option.disabled = true;
//}
// });
// this.college = ['全校'];
2024-04-23 15:52:49 +08:00
this.collegetab2 = ['地理科学学院', '文学院'];
2024-04-26 21:31:34 +08:00
console.log(this.collegeOptions, 'collegeOptions');
2024-04-03 14:36:10 +08:00
});
},
2024-04-26 21:31:34 +08:00
onMajorEntrydateChange(value) {
console.log(value, 'value');
if (value.length > 5) {
//找到value中不在this.lastMajorEntrydate中的数据
for (let i = 0; i < value.length; i++) {
if (!this.lastMajorEntrydate.includes(value[i])) {
message.error('最多选择五个');
//删除value[i]
value.splice(i, 1);
return;
}
}
}
this.lastMajorEntrydate = value;
},
//学院对比学院选项回调函数
onCollegeChange(value) {
console.log(value, 'value');
if (value.length > 5) {
message.error('最多选择五个');
2024-04-23 23:55:23 +08:00
//删除value最后一个数据
value.pop();
2024-04-26 21:31:34 +08:00
return;
2024-04-23 23:55:23 +08:00
}
2024-04-15 21:55:27 +08:00
},
2024-04-26 21:31:34 +08:00
//专业选项回调函数
onCollegeMajorChange(value) {
//将value中的数据与this.lastCollegeMajor比较如果value中的有this.lastCollegeMajor中没有的数据则添加,反之寻找在this.majorOptions中并且在this.lastCollegeMajor中但是不在value中的数据删除
for (let i = 0; i < value.length; i++) {
if (!this.lastCollegeMajor.map((item) => item[1]).includes(value[i])) {
if (this.majorLength == 5) {
message.error('最多选择五个');
//从value中删除value[i]
value.splice(i, 1);
return;
}
this.lastCollegeMajor.push([this.collegeMajor, value[i]]);
this.majorLength++;
}
}
for (let i = 0; i < this.lastCollegeMajor.length; i++) {
if (!value.includes(this.lastCollegeMajor[i][1])) {
//查看该数据是都在this.majorOptions中
if (this.majorOptions.find((item) => item.value == this.lastCollegeMajor[i][1])) {
this.lastCollegeMajor.splice(i, 1);
console.log('splice');
this.majorLength--;
}
}
}
console.log(value, 'value');
},
//学院选项回调函数
onMajorCollegeChange(value) {
let val = value.target.value;
console.log(val, 'value');
console.log(this.collegeMajorOptions.find((item) => item.value == val).children, 'majorOptions');
this.majorOptions = this.collegeMajorOptions.find((item) => item.value == val).children;
//将this.majorCheckOn中的数据与this.lastCollegeMajor比较如果this.lastCollegeMajor中有this.majorCheckOn中没有的数据则删除,反之添加
// for (let i = 0; i < this.majorCheckOn.length; i++) {
// if (!this.lastCollegeMajor.includes(this.majorCheckOn[i])) {
// this.lastCollegeMajor.push(this.majorCheckOn[i]);
// }
// }
// for (let i = 0; i < this.lastCollegeMajor.length; i++) {
// if (!this.majorCheckOn.includes(this.lastCollegeMajor[i])) {
// this.lastCollegeMajor.splice(i, 1);
// console.log("splice")
// }
// }
// this.lastCollegeMajor = this.majorCheckOn;
console.log(this.lastCollegeMajor, 'lastCollegeMajor');
this.majorCheckOn = this.lastCollegeMajor.map((item) => item[1]);
console.log(this.majorCheckOn, 'majorCheckOn');
},
2024-04-23 16:43:44 +08:00
2024-04-26 21:31:34 +08:00
clear() {
this.majorCheckOn = [];
this.lastCollegeMajor = [];
this.majorLength = 0;
},
2024-04-23 23:55:23 +08:00
//tab2\3图标
drawChart(data, tab) {
2024-04-23 15:52:49 +08:00
let seriesData = [];
2024-04-23 23:55:23 +08:00
2024-04-23 15:52:49 +08:00
let xData = this.majorentrydate.sort((a, b) => a - b);
2024-04-23 23:55:23 +08:00
if (tab == 'tab2') {
xData = this.collegeentrydate.sort((a, b) => a - b);
}
2024-04-23 15:52:49 +08:00
let k = 0;
let legendData = [];
2024-04-26 21:31:34 +08:00
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 ',
];
2024-04-23 15:52:49 +08:00
let isJK = false;
2024-04-23 23:55:23 +08:00
for (let i in data) {
2024-04-26 21:31:34 +08:00
console.log(i, 'i');
2024-04-23 15:52:49 +08:00
legendData.push(i);
let yData = [];
// legendData=[];
2024-04-26 21:31:34 +08:00
console.log(data[i], 'data[i]');
2024-04-23 23:55:23 +08:00
for (let j in data[i]) {
2024-04-26 21:31:34 +08:00
console.log(data[i][j].college, 'data[i][j].college111');
2024-04-23 15:52:49 +08:00
// if(data[i][j].college == ''){
2024-04-23 23:55:23 +08:00
yData.push(data[i][j].passRate);
// legendData.push(data[i][j].college);
2024-04-23 15:52:49 +08:00
}
2024-04-26 21:31:34 +08:00
console.log(yData, 'yData');
2024-04-23 15:52:49 +08:00
seriesData.push({
2024-04-26 21:31:34 +08:00
name: i,
2024-04-23 15:52:49 +08:00
type: 'bar',
//设置柱状图大小
barWidth: 25,
data: yData,
//柱子间距
barGap: '30%',
//颜色
itemStyle: {
normal: {
label: {
2024-04-26 21:31:34 +08:00
show: true, //开启显示
position: 'top', //在上方显示
2024-04-23 15:52:49 +08:00
formatter: '{c}%',
2024-04-26 21:31:34 +08:00
textStyle: {
//数值样式
2024-04-23 15:52:49 +08:00
color: 'black',
2024-04-26 21:31:34 +08:00
fontSize: 13,
2024-04-23 15:52:49 +08:00
},
},
2024-04-26 21:31:34 +08:00
color: colors[k++],
},
},
2024-04-23 15:52:49 +08:00
});
}
2024-04-26 21:31:34 +08:00
console.log(legendData, 'legendData');
console.log(seriesData, 'dasaaseriresdata');
2024-04-23 15:52:49 +08:00
// debugger
let myChart = null;
2024-04-26 21:31:34 +08:00
console.log(tab, 'tab');
2024-04-23 15:52:49 +08:00
if (tab == 'tab2') {
2024-04-26 21:31:34 +08:00
myChart = document.getElementById('map2');
2024-04-23 23:55:23 +08:00
if (myChart) {
2024-04-26 21:31:34 +08:00
myChart = echarts.getInstanceByDom(myChart);
2024-04-23 23:55:23 +08:00
if (myChart) {
2024-04-23 16:43:44 +08:00
myChart.dispose();
}
}
2024-04-26 21:31:34 +08:00
myChart = echarts.init(document.getElementById('map2'));
2024-04-23 15:52:49 +08:00
} else if (tab == 'tab3') {
2024-04-26 21:31:34 +08:00
myChart = document.getElementById('map3');
2024-04-23 23:55:23 +08:00
if (myChart) {
2024-04-26 21:31:34 +08:00
myChart = echarts.getInstanceByDom(myChart);
2024-04-23 23:55:23 +08:00
if (myChart) {
2024-04-23 16:43:44 +08:00
myChart.dispose();
}
}
2024-04-26 21:31:34 +08:00
myChart = echarts.init(document.getElementById('map3'));
2024-04-23 15:52:49 +08:00
}
// 指定图表的配置项和数据
let option = {
title: {
2024-04-26 21:31:34 +08:00
text: '本批次学院通过率排名',
2024-04-24 17:12:42 +08:00
},
2024-04-26 21:31:34 +08:00
legend: {},
2024-04-23 15:52:49 +08:00
tooltip: {
trigger: 'axis',
axisPointer: {
2024-04-26 21:31:34 +08:00
type: 'shadow',
2024-04-23 15:52:49 +08:00
},
formatter: function (params) {
//生成tooltip,加上小圆球
let result = params[0].name + '级通过率<br>';
for (let i = 0; i < params.length; i++) {
2024-04-23 23:55:23 +08:00
result += params[i].marker + legendData[i] + ' : ' + params[i].value + '%' + '<br>';
2024-04-23 15:52:49 +08:00
}
return result;
2024-04-26 21:31:34 +08:00
},
2024-04-23 15:52:49 +08:00
},
toolbox: {
show: true,
feature: {
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
2024-04-26 21:31:34 +08:00
saveAsImage: { show: true },
},
2024-04-23 15:52:49 +08:00
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: [
{
type: 'category',
data: xData,
axisLabel: {
2024-04-26 21:31:34 +08:00
interval: 0, //代表显示所有x轴标签显示
rotate: 0, //代表倾斜0度显示
},
},
2024-04-23 15:52:49 +08:00
],
yAxis: [
{
type: 'value',
name: '通过率',
axisLabel: {
2024-04-26 21:31:34 +08:00
formatter: '{value} %',
},
},
2024-04-23 15:52:49 +08:00
],
2024-04-26 21:31:34 +08:00
series: seriesData,
2024-04-23 15:52:49 +08:00
};
// 使用刚指定的配置项和数据显示图表。
2024-04-26 21:31:34 +08:00
console.log(option, 'option');
console.log(myChart, 'myChart');
2024-04-23 16:43:44 +08:00
setTimeout(() => {
myChart.setOption(option);
2024-04-26 21:31:34 +08:00
}, 1);
2024-04-23 15:52:49 +08:00
},
2024-04-23 23:55:23 +08:00
2024-04-23 15:52:49 +08:00
dataChart(data, tab) {
let seriesData = [];
2024-03-27 19:12:05 +08:00
let xData = [];
2024-04-26 21:31:34 +08:00
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 ',
];
let j = 0;
for (let i in data) {
xData = [];
let yData = [];
for (let key in data[i]) {
xData.push(data[i][key].college);
// 将数据转换为百分比(加上%
yData.push(data[i][key].passRate);
}
2024-04-23 23:55:23 +08:00
2024-04-26 21:31:34 +08:00
xData = xData.map((label) => label.split('').join('\n')); //将x轴竖着展示
seriesData.push({
name: i + '级累计总通过率',
type: 'bar',
2024-04-20 20:57:10 +08:00
//设置柱状图大小
2024-04-23 15:52:49 +08:00
barWidth: 25,
data: yData,
2024-04-20 20:57:10 +08:00
//柱子间距
barGap: '30%',
//颜色
itemStyle: {
normal: {
label: {
2024-04-26 21:31:34 +08:00
show: true, //开启显示
position: 'top', //在上方显示
formatter: '{c}%',
2024-04-26 21:31:34 +08:00
textStyle: {
//数值样式
color: 'black',
2024-04-26 21:31:34 +08:00
fontSize: 13,
},
},
2024-04-26 21:31:34 +08:00
color: colors[j++],
},
},
2024-04-17 13:22:19 +08:00
});
2024-04-23 23:55:23 +08:00
if (j == colors.length) {
j = 0;
}
2024-04-26 21:31:34 +08:00
let rankData = yData
.slice()
.sort((a, b) => b - a)
.map((value) => yData.indexOf(value) + 1);
2024-04-17 13:22:19 +08:00
//如果选择全校,增加排名
2024-04-23 15:52:49 +08:00
if (tab == 'tab1') {
2024-04-17 13:22:19 +08:00
seriesData.push({
name: i + '级累计总通过率排名',
type: 'line',
yAxisIndex: 1,
data: rankData,
bar: {},
show: false,
itemStyle: {
normal: {
label: {
2024-04-26 21:31:34 +08:00
show: false, //开启显示
position: 'top', //在上方显示
2024-04-17 13:22:19 +08:00
formatter: '{c}',
2024-04-26 21:31:34 +08:00
textStyle: {
//数值样式
2024-04-17 13:22:19 +08:00
color: 'black',
2024-04-26 21:31:34 +08:00
fontSize: 13,
2024-04-17 13:22:19 +08:00
},
},
2024-04-26 21:31:34 +08:00
color: colors[j++],
},
},
2024-04-17 13:22:19 +08:00
});
2024-04-23 23:55:23 +08:00
if (j == colors.length) {
j = 0;
}
}
2024-03-27 19:12:05 +08:00
}
2024-04-23 15:52:49 +08:00
let myChart = null;
if (tab == 'tab2') {
2024-04-26 21:31:34 +08:00
myChart = echarts.init(document.getElementById('map2'));
2024-04-23 15:52:49 +08:00
} else if (tab == 'tab1') {
2024-04-26 21:31:34 +08:00
myChart = echarts.init(document.getElementById('map1'));
2024-04-23 15:52:49 +08:00
} else if (tab == 'tab3') {
2024-04-26 21:31:34 +08:00
myChart = echarts.init(document.getElementById('map3'));
2024-04-23 15:52:49 +08:00
}
2024-03-27 17:08:37 +08:00
// 指定图表的配置项和数据
2024-04-23 15:52:49 +08:00
// const college1 = this.college;
2024-03-27 17:08:37 +08:00
let option = {
title: {
2024-04-26 21:31:34 +08:00
text: '本批次学院通过率排名',
2024-03-27 17:08:37 +08:00
},
tooltip: {
trigger: 'axis',
axisPointer: {
2024-04-26 21:31:34 +08:00
type: 'shadow',
2024-04-10 21:34:49 +08:00
},
formatter: function (params) {
//生成tooltip,加上小圆球
let result = params[0].name + '<br>';
for (let i = 0; i < params.length; i++) {
result += params[i].marker + params[i].seriesName + ' : ' + params[i].value + '%' + '<br>';
}
2024-04-23 15:52:49 +08:00
if (tab == 'tab1') {
2024-04-26 21:31:34 +08:00
result =
params[0].name +
'<br/>' +
2024-04-17 13:22:19 +08:00
'<table>' +
2024-04-26 21:31:34 +08:00
'<tr><td>' +
params[0].marker +
params[0].seriesName +
'</td><td style="font-weight: bold;">' +
'&nbsp;&nbsp;&nbsp;&nbsp;' +
params[0].value +
'%' +
'</td></tr>' +
'<tr><td>' +
params[1].marker +
params[1].seriesName +
'</td><td style="font-weight: bold;">' +
'&nbsp;&nbsp;&nbsp;&nbsp;' +
params[1].value +
'</td></tr>' +
2024-04-17 13:22:19 +08:00
'</table>';
}
return result;
2024-04-26 21:31:34 +08:00
},
2024-03-27 17:08:37 +08:00
},
2024-04-08 16:41:42 +08:00
toolbox: {
show: true,
feature: {
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
2024-04-26 21:31:34 +08:00
saveAsImage: { show: true },
},
2024-04-08 16:41:42 +08:00
},
2024-03-27 19:12:05 +08:00
grid: {
left: '3%',
right: '4%',
bottom: '3%',
2024-04-20 20:57:10 +08:00
containLabel: true,
2024-03-27 17:08:37 +08:00
},
2024-03-27 19:12:05 +08:00
xAxis: [
2024-03-27 17:08:37 +08:00
{
2024-03-27 19:12:05 +08:00
type: 'category',
data: xData,
2024-04-08 16:41:42 +08:00
axisLabel: {
2024-04-26 21:31:34 +08:00
interval: 0, //代表显示所有x轴标签显示
rotate: 0, //代表倾斜0度显示
},
},
2024-03-27 19:12:05 +08:00
],
yAxis: [
2024-03-27 17:08:37 +08:00
{
2024-04-10 21:34:49 +08:00
type: 'value',
name: '通过率',
axisLabel: {
2024-04-26 21:31:34 +08:00
formatter: '{value} %',
},
2024-04-10 21:34:49 +08:00
},
{
type: 'value',
name: '排名',
show: false,
2024-04-26 21:31:34 +08:00
},
2024-03-27 17:08:37 +08:00
],
2024-04-26 21:31:34 +08:00
series: seriesData,
2024-03-27 17:08:37 +08:00
};
2024-04-23 15:52:49 +08:00
if (tab == 'tab1') {
2024-04-26 21:31:34 +08:00
option.series = [
{
name: '累计总通过率',
type: 'bar',
data: seriesData[0].data,
//设置柱状图大小
barWidth: 25,
// barWidth: '60%',
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: 'top', //在上方显示
formatter: '{c}%',
textStyle: {
//数值样式
color: 'black',
fontSize: 13,
},
2024-04-17 13:22:19 +08:00
},
2024-04-26 21:31:34 +08:00
color: colors[0],
2024-04-17 13:22:19 +08:00
},
2024-04-26 21:31:34 +08:00
},
2024-04-10 21:34:49 +08:00
},
2024-04-26 21:31:34 +08:00
{
name: '排名',
type: 'bar',
data: seriesData[1].data,
label: {
show: false,
position: 'inside',
formatter: '{c}',
},
yAxisIndex: 1,
color: colors[1],
},
];
2024-04-17 13:22:19 +08:00
}
2024-04-26 21:31:34 +08:00
// 使用刚指定的配置项和数据显示图表。
2024-04-23 15:52:49 +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-26 13:30:08 +08:00
},
2024-04-08 16:41:42 +08:00
//获取年级数据
async getEntrydate() {
const getEntrydate = await defHttp.get({ url: this.Url.getEntrydate });
this.entrydateOptions = getEntrydate.entrydates;
2024-04-23 15:52:49 +08:00
this.oneentrydate = this.entrydateOptions[0].value;
this.collegeentrydate = [this.entrydateOptions[0].value];
this.majorentrydate = [this.entrydateOptions[0].value];
// this.entrydate.push (this.entrydateOptions[0].value);
2024-04-08 16:41:42 +08:00
},
2024-03-27 17:08:37 +08:00
// 查询数据
2024-04-23 15:52:49 +08:00
async query(query, college, entrydate) {
this.visible = false;
2024-04-08 16:41:42 +08:00
let result = null;
2024-04-23 23:55:23 +08:00
// console.log(this.college, this.entrydate);
// //如果this.college和this.batch为null则先赋静态值
// if (this.college === null || this.college.length === 0) {
// this.college = ['全校'];
// }
2024-04-23 23:55:23 +08:00
// if (!this.entrydate || this.entrydate.length === 0) {
// this.entrydate = ['2017'];
// }
2024-03-27 18:46:10 +08:00
try {
2024-04-23 23:55:23 +08:00
// console.log(this.college, this.entrydate)
2024-03-27 18:46:10 +08:00
let params = {
2024-04-23 15:52:49 +08:00
college: college,
entrydate: entrydate,
2024-04-26 21:31:34 +08:00
level: 'cet4',
};
2024-04-23 16:43:44 +08:00
let url = query == 'tab1' ? this.Url.getAllRate : this.Url.getCollegeRate;
2024-04-26 21:31:34 +08:00
console.log(params.college, 'college');
2024-04-23 16:43:44 +08:00
result = await defHttp.post({ url: url, params });
2024-04-08 16:41:42 +08:00
//使数据按照passRate从大到小排序
// result.data.sort((a, b) => {
// return b.passRate - a.passRate;
// });
2024-04-26 21:31:34 +08:00
console.log('data', result.data);
2024-03-27 18:46:10 +08:00
} finally {
2024-04-26 21:31:34 +08:00
query == 'tab1' ? (this.tab1loading = false) : (this.tab2loading = false);
2024-03-27 18:46:10 +08:00
this.$nextTick(() => {
2024-04-23 15:52:49 +08:00
if (query == 'tab1') {
this.dataChart(result.data, query);
} else if (query == 'tab2') {
2024-04-23 23:55:23 +08:00
this.drawChart(result.data, query);
2024-04-23 15:52:49 +08:00
}
2024-04-26 21:31:34 +08:00
});
2024-03-27 17:08:37 +08:00
}
2024-04-26 21:31:34 +08:00
},
2024-03-27 17:08:37 +08:00
},
mounted() {
2024-04-03 14:36:10 +08:00
this.getCollegeOptions();
2024-04-08 16:41:42 +08:00
// this.getBatch();
this.getEntrydate();
2024-04-23 15:52:49 +08:00
this.allQuery();
this.getCollegeMajorData();
2024-04-26 21:31:34 +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);
}
2024-04-23 15:52:49 +08:00
.query {
2024-04-26 21:31:34 +08:00
//居左
2024-04-23 15:52:49 +08:00
display: flex;
2024-04-26 21:31:34 +08:00
justify-content: flex-start;
align-items: center;
margin-left: 24px;
}
2024-04-23 15:52:49 +08:00
2024-04-26 21:31:34 +08:00
.tab3 {
justify-content: flex-start;
align-items: center;
margin-left: 24px;
2024-04-23 15:52:49 +08:00
}
2024-03-27 17:08:37 +08:00
.title {
font-size: 34px;
color: rgb(8, 8, 8);
font-weight: bold;
}
</style>