Pārlūkot izejas kodu

build: :zap: 其他页面不再监听学校变化

chaooo 2 gadi atpakaļ
vecāks
revīzija
d5d22b63dc

+ 0 - 17
src/views/dashboard/components/DataCard.vue

@@ -1,7 +1,6 @@
 <!-- 数据卡片 -->
 <script setup lang="ts">
 import {TransitionPresets, useTransition} from "@vueuse/core";
-import {watch} from "vue";
 
 const props = defineProps({
   classes: {
@@ -54,28 +53,12 @@ const trainingCount = ref(0);
 const trainingCountOutput = countNumber(trainingCount);
 // 监听数据变化
 watchEffect(() => {
-  console.log("card");
   classCount.value = <number>props.classes;
   teacherCount.value = <number>props.teachers;
   studentCount.value = <number>props.students;
   equipmentCount.value = <number>props.equipments;
   trainingCount.value = <number>props.trainings;
 });
-watch(
-  () => classCount,
-  (newValue) => {
-    console.log("classCount", newValue.value);
-    // classCount.value = <number>newValue.classes;
-    // teacherCount.value = <number>newValue.teachers;
-    // studentCount.value = <number>newValue.students;
-    // equipmentCount.value = <number>newValue.equipments;
-    // trainingCount.value = <number>newValue.trainings;
-  },
-  {
-    deep: true,
-    immediate: true,
-  }
-);
 </script>
 <template>
   <el-row class="data-card">

+ 0 - 10
src/views/dashboard/example.vue

@@ -1,18 +1,8 @@
 <script setup lang="ts">
-import {watch} from "vue";
-import {useUserStore} from "@/store/modules/user";
-
 defineOptions({
   name: "DashboardExample",
   inheritAttrs: false,
 });
-const userStore = useUserStore();
-watch(
-  () => userStore.schoolId,
-  (newValue, oldValue) => {
-    console.log(newValue, oldValue);
-  }
-);
 </script>
 
 <template>

+ 12 - 12
src/views/equipment/index.vue

@@ -1,11 +1,11 @@
 <script setup lang="ts">
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 import {TeacherList, TeacherManage} from "@/api/teacher/types";
 import {getTeacherList} from "@/api/teacher";
 import {EquipmentManage, EquipmentParams} from "@/api/equipment/types";
 import {getEquipmentLists} from "@/api/equipment";
 import {trimInput} from "@/utils";
+
 const userStore = useUserStore();
 defineOptions({
   name: "EquipmentIndex",
@@ -89,17 +89,17 @@ onMounted(() => {
   getTeacherData(userStore.schoolId);
   getEquipmentData(userStore.schoolId);
 });
-watch(
-  () => userStore.schoolId,
-  (newValue) => {
-    // 学校切换后重新获取
-    pageParams.school_id = newValue;
-    pageParams.teacher_id = 0;
-    pageParams.sn = "";
-    getTeacherData(newValue);
-    getEquipmentData(newValue);
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue) => {
+//     // 学校切换后重新获取
+//     pageParams.school_id = newValue;
+//     pageParams.teacher_id = 0;
+//     pageParams.sn = "";
+//     getTeacherData(newValue);
+//     getEquipmentData(newValue);
+//   }
+// );
 </script>
 
 <template>

+ 7 - 9
src/views/evaluation/index.vue

@@ -1,6 +1,4 @@
 <script setup lang="ts">
-import {watch} from "vue";
-import {useUserStore} from "@/store/modules/user";
 import EvaluateCard from "@/views/evaluation/components/EvaluateCard.vue";
 import RadarChart from "@/components/Charts/RadarChart.vue";
 import FocusBarChart from "@/components/Charts/FocusBarChart.vue";
@@ -12,13 +10,13 @@ defineOptions({
   name: "EvaluateIndex",
   inheritAttrs: false,
 });
-const userStore = useUserStore();
-watch(
-  () => userStore.schoolId,
-  (newValue, oldValue) => {
-    console.log(newValue, oldValue);
-  }
-);
+// const userStore = useUserStore();
+// watch(
+//   () => userStore.schoolId,
+//   (newValue, oldValue) => {
+//     console.log(newValue, oldValue);
+//   }
+// );
 /**
  * 数据卡片
  */

+ 8 - 9
src/views/grade/index.vue

@@ -1,5 +1,4 @@
 <script setup lang="ts">
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 
 import {getGradeList, getGradeStudents} from "@/api/grade";
@@ -59,14 +58,14 @@ onMounted(() => {
   // 获取班级
   getGradeItems(userStore.schoolId, gradeType.value);
 });
-watch(
-  () => userStore.schoolId,
-  (newValue, oldValue) => {
-    console.log("userStore.schoolId", newValue, oldValue);
-    // 学校切换后重新加载数据
-    getGradeItems(newValue, gradeType.value);
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue, oldValue) => {
+//     console.log("userStore.schoolId", newValue, oldValue);
+//     // 学校切换后重新加载数据
+//     getGradeItems(newValue, gradeType.value);
+//   }
+// );
 </script>
 
 <template>

+ 10 - 11
src/views/student/index.vue

@@ -1,6 +1,5 @@
 <script setup lang="ts">
 import {GradeList} from "@/api/grade/types";
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 import {getGradeSelect} from "@/api/grade";
 import {getStudentLists} from "@/api/student";
@@ -74,16 +73,16 @@ onMounted(() => {
   // 获取学生数据
   getStudentData(userStore.schoolId);
 });
-watch(
-  () => userStore.schoolId,
-  (newValue) => {
-    // 学校切换后重新加载数据
-    studentSearch.grade_id = 0;
-    studentSearch.search = "";
-    getGradeData(newValue);
-    getStudentData(userStore.schoolId);
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue) => {
+//     // 学校切换后重新加载数据
+//     studentSearch.grade_id = 0;
+//     studentSearch.search = "";
+//     getGradeData(newValue);
+//     getStudentData(userStore.schoolId);
+//   }
+// );
 </script>
 
 <template>

+ 7 - 8
src/views/student/result.vue

@@ -5,7 +5,6 @@ import CircleChart from "@/components/Charts/CircleChart.vue";
 import DoubleChart from "@/components/Charts/DoubleChart.vue";
 import SvgIcon from "@/components/SvgIcon/index.vue";
 import {getUrlParam} from "@/utils";
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 import {getStudentBoard} from "@/api/student";
 import {StudentBoard} from "@/api/student/types";
@@ -66,13 +65,13 @@ onMounted(() => {
   // 图表数据
   getChartData(userStore.schoolId);
 });
-watch(
-  () => userStore.schoolId,
-  (newValue) => {
-    // 图表数据
-    getChartData(newValue);
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue) => {
+//     // 图表数据
+//     getChartData(newValue);
+//   }
+// );
 </script>
 
 <template>

+ 9 - 10
src/views/teacher/index.vue

@@ -1,9 +1,8 @@
 <script setup lang="ts">
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 
 import {getTeacherEquipment, getTeacherGrade, getTeacherManage} from "@/api/teacher";
-import {TeacherItem, TeacherManage} from "@/api/teacher/types";
+import {TeacherItem} from "@/api/teacher/types";
 import {trimInput} from "@/utils";
 
 const userStore = useUserStore();
@@ -77,14 +76,14 @@ onMounted(() => {
   // 获取教师
   getTeacherData(userStore.schoolId, "");
 });
-watch(
-  () => userStore.schoolId,
-  (newValue) => {
-    searchKeyword.value = "";
-    // 学校切换后重新获取教师
-    getTeacherData(newValue, "");
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue) => {
+//     searchKeyword.value = "";
+//     // 学校切换后重新获取教师
+//     getTeacherData(newValue, "");
+//   }
+// );
 </script>
 
 <template>

+ 9 - 10
src/views/training/index.vue

@@ -1,11 +1,10 @@
 <script setup lang="ts">
-import {watch} from "vue";
 import {useUserStore} from "@/store/modules/user";
 import {GradeList} from "@/api/grade/types";
 import {TrainingItem, TrainingParams} from "@/api/training/types";
 import {getGradeSelect} from "@/api/grade";
 import {getTrainingLists} from "@/api/training";
-import {getUrlParam, trimInput} from "@/utils";
+import {trimInput} from "@/utils";
 
 const userStore = useUserStore();
 defineOptions({
@@ -72,14 +71,14 @@ onMounted(() => {
   getGradeData(userStore.schoolId);
   getTrainingData(userStore.schoolId);
 });
-watch(
-  () => userStore.schoolId,
-  (newValue) => {
-    // 学校切换后重新获取
-    getGradeData(newValue);
-    getTrainingData(newValue);
-  }
-);
+// watch(
+//   () => userStore.schoolId,
+//   (newValue) => {
+//     // 学校切换后重新获取
+//     getGradeData(newValue);
+//     getTrainingData(newValue);
+//   }
+// );
 </script>
 
 <template>