From b9d306edc51f6c766a2c6f44c4aef00230f1eee3 Mon Sep 17 00:00:00 2001 From: Cool <747682928@qq.com> Date: Mon, 6 May 2024 14:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/cet/cet-ana-2.vue | 100 ++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/src/views/cet/cet-ana-2.vue b/src/views/cet/cet-ana-2.vue index 4d93ad2..7011f41 100644 --- a/src/views/cet/cet-ana-2.vue +++ b/src/views/cet/cet-ana-2.vue @@ -4,13 +4,13 @@
-
+
@@ -24,14 +24,14 @@ import { defHttp } from '/@/utils/http/axios'; import * as echarts from 'echarts'; export default { - name: "Analysis", + name: 'Analysis', data() { return { Url: { getBatch: '/cet/getBatch', getCollege: '/cet/getCollege', getRate: '/cet/getRateByAllBatch', - getCollegeMajor: '/cet/getCollegeMajor' + getCollegeMajor: '/cet/getCollegeMajor', }, loading: false, collegeOptions: [], @@ -39,12 +39,12 @@ export default { batchOptions: [], levelOptions: [ { value: 'cet4', label: '英语四级' }, - { value: 'cet6', label: '英语六级' } + { value: 'cet6', label: '英语六级' }, ], level: null, college: null, batch: null, - collegeMajor: null + collegeMajor: null, }; }, methods: { @@ -54,41 +54,50 @@ export default { for (let key in data) { xData.push(key); // 将数据转换为百分比(加上%) - yData.push((data[key]).toFixed(1)); + yData.push(data[key].toFixed(1)); } - let myChart = echarts.init(document.getElementById("map1")); + let myChart = echarts.init(document.getElementById('map1')); // 指定图表的配置项和数据 let option = { title: { - text: "学院 / 专业通过率变化", + text: '学院 / 专业通过率变化', }, xAxis: { type: 'category', data: xData, axisLabel: { - interval: 0,//代表显示所有x轴标签显示 - rotate: -10,//代表倾斜30度显示 - } + interval: 0, //代表显示所有x轴标签显示 + rotate: -10, //代表倾斜30度显示 + }, }, tooltip: { trigger: 'axis', axisPointer: { - type: 'shadow' + type: 'shadow', }, formatter: function (params) { - return params[0].name + '
' + + return ( + params[0].name + + '
' + '' + - '' + - '' - + '
' + params[0].marker + '' + '    ' + params[0].value + '%' + '
'; - } + '' + + params[0].marker + + '' + + '    ' + + params[0].value + + '%' + + '' + + '' + + '' + ); + }, }, yAxis: { type: 'value', name: '通过率', axisLabel: { - formatter: '{value} %' - } + formatter: '{value} %', + }, }, series: [ { @@ -99,16 +108,17 @@ export default { label: { show: true, //开启显示 position: 'top', //在上方显示 - textStyle: { //数值样式 + textStyle: { + //数值样式 color: 'black', - fontSize: 12 + fontSize: 12, }, formatter: '{c}%', - } - } - } - } - ] + }, + }, + }, + }, + ], }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); @@ -129,17 +139,17 @@ export default { async getCollegeMajorData() { const res = await defHttp.get({ url: this.Url.getCollegeMajor }); //通过map方法将数据转换为级联选择器需要的数据格式 - this.collegeMajorOptions = res.collegeMajor.map(item => { + this.collegeMajorOptions = res.collegeMajor.map((item) => { return { value: item.college, label: item.college, - children: item.major.map(major => { + children: item.major.map((major) => { return { value: major, - label: major - } - }) - } + label: major, + }; + }), + }; }); this.collegeMajor = this.collegeMajorOptions[0].value; console.log(this.collegeMajorOptions); @@ -147,36 +157,40 @@ export default { // 查询数据 async query() { let data = null; + console.log(this.collegeMajor, 'collegeMajor'); try { - console.log("sb", this.collegeMajor); + //如果this.collegeMajor为null则先赋个值 if (!this.collegeMajor) { this.collegeMajor = ['东语学院']; } + let major = null; + let college = null; //如果this.collegeMajor[1]不存在则设为null - let major = this.collegeMajor.length > 1 ? this.collegeMajor[1] : ""; + college = this.collegeMajor[0]; + major=this.collegeMajor.length>1?this.collegeMajor[1]:''; this.loading = true; + console.log(college, major,"college,major"); let params = { - college: this.collegeMajor[0], + college: college, major: major, level: 'cet4', - } + }; data = await defHttp.get({ url: this.Url.getRate, params }); } finally { this.loading = false; this.$nextTick(() => { this.dataChart(data); - }) + }); } - } + }, }, mounted() { this.getCollegeMajorData(); this.getBatch(); - this.query(); - } - -} + // this.query(); + }, +};