|
@@ -7,9 +7,10 @@ import { GradeList } from "@/api/school/types";
|
|
import { watch } from "vue";
|
|
import { watch } from "vue";
|
|
import { useUserStore } from "@/store/modules/user";
|
|
import { useUserStore } from "@/store/modules/user";
|
|
import { CaretBottom } from "@element-plus/icons-vue";
|
|
import { CaretBottom } from "@element-plus/icons-vue";
|
|
-import { getGradeList } from "@/api/school";
|
|
|
|
|
|
+import { getGradeSelect } from "@/api/school";
|
|
import { getDashboardData, getDashboardTop } from "@/api/dashboard";
|
|
import { getDashboardData, getDashboardTop } from "@/api/dashboard";
|
|
import { DashboardCard, DashboardData } from "@/api/dashboard/types";
|
|
import { DashboardCard, DashboardData } from "@/api/dashboard/types";
|
|
|
|
+
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "DashboardIndex",
|
|
name: "DashboardIndex",
|
|
@@ -18,26 +19,17 @@ defineOptions({
|
|
/**
|
|
/**
|
|
* 数据卡片
|
|
* 数据卡片
|
|
*/
|
|
*/
|
|
-const cards: DashboardCard = reactive({
|
|
|
|
- grade: 0,
|
|
|
|
- teacher: 0,
|
|
|
|
- student: 0,
|
|
|
|
- equipment: 0,
|
|
|
|
- game: 0,
|
|
|
|
|
|
+let cards: DashboardCard = reactive({
|
|
|
|
+ grade: 0, // 全部班级
|
|
|
|
+ teacher: 0, // 全部教师
|
|
|
|
+ student: 0, // 全部学生
|
|
|
|
+ equipment: 0, // 设备套数
|
|
|
|
+ game: 0, // 累计训练次数
|
|
});
|
|
});
|
|
async function getDataCard(schoolId: number) {
|
|
async function getDataCard(schoolId: number) {
|
|
getDashboardTop(schoolId)
|
|
getDashboardTop(schoolId)
|
|
.then(({ data }) => {
|
|
.then(({ data }) => {
|
|
- // 全部班级
|
|
|
|
- cards.grade = data.grade;
|
|
|
|
- // 全部教师
|
|
|
|
- cards.teacher = data.teacher;
|
|
|
|
- // 全部学生
|
|
|
|
- cards.student = data.student;
|
|
|
|
- // 设备套数
|
|
|
|
- cards.equipment = data.equipment;
|
|
|
|
- // 累计训练次数
|
|
|
|
- cards.game = data.game;
|
|
|
|
|
|
+ cards = <DashboardCard>{ ...data };
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -50,11 +42,10 @@ const gradeData = ref<GradeList[]>();
|
|
// 班级编号
|
|
// 班级编号
|
|
let gradeId = ref(0);
|
|
let gradeId = ref(0);
|
|
async function getGradeData(schoolId: number) {
|
|
async function getGradeData(schoolId: number) {
|
|
- getGradeList(schoolId)
|
|
|
|
|
|
+ getGradeSelect(schoolId)
|
|
.then(({ data }) => {
|
|
.then(({ data }) => {
|
|
data.unshift({ id: 0, name: "全部班级" });
|
|
data.unshift({ id: 0, name: "全部班级" });
|
|
gradeData.value = data;
|
|
gradeData.value = data;
|
|
- //console.log(gradeData.value)
|
|
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
@@ -64,32 +55,24 @@ async function getGradeData(schoolId: number) {
|
|
* 图表数据
|
|
* 图表数据
|
|
*/
|
|
*/
|
|
const chartStatus = ref(false);
|
|
const chartStatus = ref(false);
|
|
-const chartData: DashboardData = reactive({
|
|
|
|
- frontAverage: 0,
|
|
|
|
- afterAverage: 0,
|
|
|
|
- front: 0,
|
|
|
|
- after: 0,
|
|
|
|
- frontProportion: { num: [], percentage: [] },
|
|
|
|
- afterProportion: { num: [], percentage: [] },
|
|
|
|
|
|
+let chartData: DashboardData = reactive({
|
|
|
|
+ frontAverage: 0, // 初期专注力估值
|
|
|
|
+ afterAverage: 0, // 近期专注力估值
|
|
|
|
+ front: 0, // 初期50分以上的占比
|
|
|
|
+ after: 0, // 近期50分以上的占比
|
|
|
|
+ frontProportion: { num: [], percentage: [] }, // 初期分期占比分析
|
|
|
|
+ afterProportion: { num: [], percentage: [] }, // 近期分期占比分析
|
|
});
|
|
});
|
|
async function getChartData(gradeId: number) {
|
|
async function getChartData(gradeId: number) {
|
|
getDashboardData(gradeId)
|
|
getDashboardData(gradeId)
|
|
.then(({ data }) => {
|
|
.then(({ data }) => {
|
|
- // 初期专注力估值
|
|
|
|
- chartData.frontAverage = data.frontAverage;
|
|
|
|
- // 近期专注力估值
|
|
|
|
- chartData.afterAverage = data.afterAverage;
|
|
|
|
- // 初期50分以上的占比
|
|
|
|
- chartData.front = data.front;
|
|
|
|
- // 近期50分以上的占比
|
|
|
|
- chartData.after = data.after;
|
|
|
|
- // 初期分期占比分析
|
|
|
|
- chartData.frontProportion = data.frontProportion;
|
|
|
|
- // 近期分期占比分析
|
|
|
|
- chartData.afterProportion = data.afterProportion;
|
|
|
|
- chartStatus.value = true;
|
|
|
|
- dataStatus.value = 1;
|
|
|
|
- // console.log(data);
|
|
|
|
|
|
+ chartData = <DashboardData>{ ...data };
|
|
|
|
+ if (chartData.frontAverage > 0) {
|
|
|
|
+ chartStatus.value = true;
|
|
|
|
+ dataStatus.value = 1;
|
|
|
|
+ } else {
|
|
|
|
+ dataStatus.value = 2;
|
|
|
|
+ }
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
console.log(error.toString());
|
|
console.log(error.toString());
|
|
@@ -98,6 +81,11 @@ async function getChartData(gradeId: number) {
|
|
}
|
|
}
|
|
// 数据状态:1正常,2训练次数小于3,3过期,4缺省
|
|
// 数据状态:1正常,2训练次数小于3,3过期,4缺省
|
|
const dataStatus = ref(5);
|
|
const dataStatus = ref(5);
|
|
|
|
+// 改变班级重新加载图表数据
|
|
|
|
+function changeGrade() {
|
|
|
|
+ dataStatus.value = 5;
|
|
|
|
+ getChartData(gradeId.value);
|
|
|
|
+}
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
// 获取班级
|
|
// 获取班级
|
|
getGradeData(userStore.schoolId);
|
|
getGradeData(userStore.schoolId);
|
|
@@ -118,11 +106,6 @@ watch(
|
|
getChartData(0);
|
|
getChartData(0);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
-// 改变班级重新加载图表数据
|
|
|
|
-function changeGrade() {
|
|
|
|
- dataStatus.value = 5;
|
|
|
|
- getChartData(gradeId.value);
|
|
|
|
-}
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|