|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
- <a-spin :spinning="loading1 || loading2">
|
|
|
+ <a-spin :spinning="loading || loading1 || loading2 || loading3">
|
|
|
<!-- 基础数据展示 -->
|
|
|
<div class="count-basic-data">
|
|
|
<div
|
|
@@ -31,7 +31,7 @@
|
|
|
:class="{
|
|
|
'count-echarts-bar-title-right-btn': true,
|
|
|
'count-echarts-bar-title-right-btn-checked':
|
|
|
- barTabChecked === item.id,
|
|
|
+ barTabChecked === item.code,
|
|
|
}"
|
|
|
v-for="(item, index) in barDataTab"
|
|
|
:key="index"
|
|
@@ -75,17 +75,18 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ loading: false, // 基础数据加载动画
|
|
|
loading1: false, // 是否显示加载动画
|
|
|
loading2: false, // 是否显示加载动画
|
|
|
loading3: false, // 是否显示加载动画
|
|
|
basicList: [], // 基础数据列表
|
|
|
// 统计图
|
|
|
barDataTab: [
|
|
|
- { id: 1, title: '本周' },
|
|
|
- { id: 2, title: '本月' },
|
|
|
- { id: 3, title: '本年' },
|
|
|
+ { id: 1, title: '本周', code: 'week' },
|
|
|
+ { id: 2, title: '本月', code: 'month' },
|
|
|
+ { id: 3, title: '本年', code: 'year' },
|
|
|
], // 统计图的tab栏
|
|
|
- barTabChecked: 1, // 当前选中的tab栏ID
|
|
|
+ barTabChecked: 'week', // 当前选中的tab栏ID
|
|
|
barData: {}, // 统计图数据
|
|
|
// 扇形-文章类型占比
|
|
|
articlesProportion: {},
|
|
@@ -93,7 +94,9 @@ export default {
|
|
|
examsProportion: {},
|
|
|
};
|
|
|
},
|
|
|
- created() {},
|
|
|
+ created() {
|
|
|
+ this.getEngineeringWorkList();
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.initDataFun(); // 初始化数据
|
|
|
},
|
|
@@ -103,6 +106,33 @@ export default {
|
|
|
...mapGetters(['userInfo']),
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取工种,并存到vuex
|
|
|
+ getEngineeringWorkList() {
|
|
|
+ this.$_http
|
|
|
+ .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
|
|
|
+ .then((res) => {
|
|
|
+ this.$store.commit('common/SET_ENGINEERING_WORK_LIST', res.data);
|
|
|
+ this.getExamQuestionTypeConditionParentList();
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.isInited = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取试题类型-父类信息,并存到vuex
|
|
|
+ getExamQuestionTypeConditionParentList() {
|
|
|
+ this.$_http
|
|
|
+ .get(this.$_API.INTERFACE_GET_EXAMS_QUESTION_TYPE_CONDITION_PARENT)
|
|
|
+ .then((res) => {
|
|
|
+ this.$store.commit(
|
|
|
+ 'common/SET_EXAM_QUESTION_TYPE_CONDITION_PARENT',
|
|
|
+ res.data
|
|
|
+ );
|
|
|
+ this.isInited = true;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.isInited = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
// 初始化数据
|
|
|
async initDataFun() {
|
|
|
this.basicList = [
|
|
@@ -184,7 +214,7 @@ export default {
|
|
|
.get(this.$_API.INTERFACE_GET_COUNT_EXAMS)
|
|
|
.then((res) => {
|
|
|
basicList[2].count = res.data;
|
|
|
- this.getExamsCountUp(basicList);
|
|
|
+ this.getExamsCountUp(basicList); // 查询:本月新增考试数量
|
|
|
})
|
|
|
.catch(() => {
|
|
|
this.loading1 = false;
|
|
@@ -196,7 +226,6 @@ export default {
|
|
|
.get(this.$_API.INTERFACE_GET_COUNT_EXAMS_UP)
|
|
|
.then((res) => {
|
|
|
basicList[2].monthUp = res.data;
|
|
|
- this.$refs.echartsBarRef.initDataFun(this.barData);
|
|
|
this.loading1 = false;
|
|
|
})
|
|
|
.catch(() => {
|
|
@@ -206,46 +235,71 @@ export default {
|
|
|
// 查询:统计图-考试平均成绩:本周、本月、全年
|
|
|
getAverageTestScore() {
|
|
|
this.loading2 = true;
|
|
|
- this.barData = {
|
|
|
- xAxis: {
|
|
|
- data: [
|
|
|
- '期终考试',
|
|
|
- '期中考试',
|
|
|
- '期末考试',
|
|
|
- '4月',
|
|
|
- '5月',
|
|
|
- '6月',
|
|
|
- '7月',
|
|
|
- '8月',
|
|
|
- '9月',
|
|
|
- '10月',
|
|
|
- '11月',
|
|
|
- '12月',
|
|
|
- ],
|
|
|
- }, // x轴数据
|
|
|
- series: {
|
|
|
- data: [
|
|
|
- 1113,
|
|
|
- 823,
|
|
|
- 1140,
|
|
|
- 1110,
|
|
|
- 405,
|
|
|
- 813,
|
|
|
- 823,
|
|
|
- 389,
|
|
|
- 678,
|
|
|
- 407,
|
|
|
- 1178,
|
|
|
- 789,
|
|
|
- ],
|
|
|
- }, // 移入提示数据
|
|
|
+ let params = {
|
|
|
+ date: this.barTabChecked,
|
|
|
};
|
|
|
- this.loading2 = false;
|
|
|
- // this.$_http
|
|
|
- // .get(this.$_API.INTERFACE_GET_COUNT_BAR)
|
|
|
- // .then((res) => {
|
|
|
- // this.loading2 = false;
|
|
|
- // })
|
|
|
+ this.$_http
|
|
|
+ .get(this.$_API.INTERFACE_GET_COUNT_BAR, { params })
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ let dataArr = this.formateResDataToEcharts(res.data); // 格式化数据结构为echarts所需要的结构
|
|
|
+ let xAxis = dataArr.map((item) => {
|
|
|
+ return item.name;
|
|
|
+ });
|
|
|
+ let series = dataArr.map((item) => {
|
|
|
+ return item.value;
|
|
|
+ });
|
|
|
+ if (xAxis.length > 0 && series.length > 0) {
|
|
|
+ this.barData = {
|
|
|
+ xAxis: {
|
|
|
+ data: xAxis,
|
|
|
+ },
|
|
|
+ series: {
|
|
|
+ data: series,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ this.barData = {
|
|
|
+ xAxis: {
|
|
|
+ data: [
|
|
|
+ '期终考试',
|
|
|
+ '期中考试',
|
|
|
+ '期末考试',
|
|
|
+ '4月',
|
|
|
+ '5月',
|
|
|
+ '6月',
|
|
|
+ '7月',
|
|
|
+ '8月',
|
|
|
+ '9月',
|
|
|
+ '10月',
|
|
|
+ '11月',
|
|
|
+ '12月',
|
|
|
+ ],
|
|
|
+ }, // x轴数据
|
|
|
+ series: {
|
|
|
+ data: [
|
|
|
+ 1113,
|
|
|
+ 823,
|
|
|
+ 1140,
|
|
|
+ 1110,
|
|
|
+ 405,
|
|
|
+ 813,
|
|
|
+ 823,
|
|
|
+ 389,
|
|
|
+ 678,
|
|
|
+ 407,
|
|
|
+ 1178,
|
|
|
+ 789,
|
|
|
+ ],
|
|
|
+ }, // 移入提示数据
|
|
|
+ };
|
|
|
+ }
|
|
|
+ this.loading2 = false;
|
|
|
+ this.$refs.echartsBarRef.initDataFun(this.barData);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading2 = false;
|
|
|
+ });
|
|
|
},
|
|
|
// 查询:文章类别占比
|
|
|
getArticlesProportion() {
|
|
@@ -253,20 +307,7 @@ export default {
|
|
|
this.$_http
|
|
|
.get(this.$_API.INTERFACE_GET_COUNT_ARTICLE_PROPORTION)
|
|
|
.then((res) => {
|
|
|
- let dataArr = [];
|
|
|
- for (let key in res.data) {
|
|
|
- dataArr.push({
|
|
|
- name: key,
|
|
|
- value: formate(res.data[key]),
|
|
|
- });
|
|
|
- }
|
|
|
- function formate(value) {
|
|
|
- if (value.includes('%')) {
|
|
|
- return Math.round(Number(value.replace('%', '')));
|
|
|
- } else {
|
|
|
- return value;
|
|
|
- }
|
|
|
- }
|
|
|
+ let dataArr = this.formateResDataToEcharts(res.data); // 格式化数据结构为echarts所需要的结构
|
|
|
this.articlesProportion = {
|
|
|
title: '文章总计',
|
|
|
seriesLabel: '文章类别占比',
|
|
@@ -285,27 +326,13 @@ export default {
|
|
|
this.$_http
|
|
|
.get(this.$_API.INTERFACE_GET_COUNT_QUESTIONS_PROPORTION)
|
|
|
.then((res) => {
|
|
|
- let dataArr = [];
|
|
|
- for (let key in res.data) {
|
|
|
- dataArr.push({
|
|
|
- name: key,
|
|
|
- value: formate(res.data[key]),
|
|
|
- });
|
|
|
- }
|
|
|
- function formate(value) {
|
|
|
- if (value.includes('%')) {
|
|
|
- return Math.round(Number(value.replace('%', '')));
|
|
|
- } else {
|
|
|
- return value;
|
|
|
- }
|
|
|
- }
|
|
|
+ let dataArr = this.formateResDataToEcharts(res.data); // 格式化数据结构为echarts所需要的结构
|
|
|
this.articlesProportion = {
|
|
|
title: '试题总计',
|
|
|
seriesLabel: '试题类别占比',
|
|
|
count: count,
|
|
|
data: dataArr,
|
|
|
};
|
|
|
- console.log(this.articlesProportion);
|
|
|
this.$refs.echartsPieTwoRef.initDataFun(this.articlesProportion);
|
|
|
this.loading3 = false;
|
|
|
})
|
|
@@ -313,12 +340,24 @@ export default {
|
|
|
this.loading3 = false;
|
|
|
});
|
|
|
},
|
|
|
+ // 格式化数据结构为echarts所需要的结构
|
|
|
+ formateResDataToEcharts(data) {
|
|
|
+ let dataArr = [];
|
|
|
+ for (let key in data) {
|
|
|
+ dataArr.push({
|
|
|
+ name: key,
|
|
|
+ value: data[key],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return dataArr;
|
|
|
+ },
|
|
|
// 操作:切换统计图的tab
|
|
|
handleEchartsTab(item) {
|
|
|
- if (this.barTabChecked === item.id) {
|
|
|
+ if (this.barTabChecked === item.code) {
|
|
|
return;
|
|
|
}
|
|
|
- this.barTabChecked = item.id;
|
|
|
+ this.barTabChecked = item.code;
|
|
|
+ this.getAverageTestScore(); // 查询:统计图-考试平均成绩:本周、本月、全年
|
|
|
},
|
|
|
},
|
|
|
};
|