|
@@ -1,37 +1,131 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { GradeList } from "@/api/school/types";
|
|
|
|
|
|
+import { watch } from "vue";
|
|
|
|
+import { useUserStore } from "@/store/modules/user";
|
|
|
|
+import { CaretBottom } from "@element-plus/icons-vue";
|
|
|
|
+import {
|
|
|
|
+ EquipmentShown,
|
|
|
|
+ TeacherEquipment,
|
|
|
|
+ TeacherItem,
|
|
|
|
+ TeacherList,
|
|
|
|
+} from "@/api/school/types";
|
|
|
|
+import {
|
|
|
|
+ getTeacherEquipment,
|
|
|
|
+ getTeacherGrade,
|
|
|
|
+ getTeacherList,
|
|
|
|
+} from "@/api/school";
|
|
|
|
|
|
|
|
+const userStore = useUserStore();
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "TeacherIndex",
|
|
name: "TeacherIndex",
|
|
inheritAttrs: false,
|
|
inheritAttrs: false,
|
|
});
|
|
});
|
|
-import { watch } from "vue";
|
|
|
|
-import { useUserStore } from "@/store/modules/user";
|
|
|
|
-import { CaretBottom } from "@element-plus/icons-vue";
|
|
|
|
-const userStore = useUserStore();
|
|
|
|
|
|
+/**
|
|
|
|
+ * 班级数据
|
|
|
|
+ */
|
|
|
|
+const teacherData = ref<TeacherItem[]>();
|
|
|
|
+// 教师数量
|
|
|
|
+let teacherCount = ref(0);
|
|
|
|
+// 用于搜索的教师名称或手机号
|
|
|
|
+let searchKeyword = ref("");
|
|
|
|
+// 获取教师
|
|
|
|
+async function getTeacherData(schoolId: number, keyword: string) {
|
|
|
|
+ getTeacherList(schoolId, keyword)
|
|
|
|
+ .then(({ data }) => {
|
|
|
|
+ const temp: TeacherList = data;
|
|
|
|
+ teacherData.value = temp.lists;
|
|
|
|
+ teacherCount.value = temp.count;
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+// 获取教师班级和设备
|
|
|
|
+async function getGradeAndEquipment(teacher: TeacherItem) {
|
|
|
|
+ // 获取教师班级
|
|
|
|
+ getTeacherGrade(teacher.id)
|
|
|
|
+ .then(({ data }) => {
|
|
|
|
+ teacher.grades = data;
|
|
|
|
+ if (teacher.grades && teacher.grades.length > 0) {
|
|
|
|
+ teacher.lines = teacher.grades.length;
|
|
|
|
+ }
|
|
|
|
+ if (!teacher.equipment || Object.keys(teacher.equipment).length == 0) {
|
|
|
|
+ // 获取教师设备
|
|
|
|
+ getTeacherEquipment(teacher.id).then(({ data }) => {
|
|
|
|
+ const temp: TeacherEquipment = data;
|
|
|
|
+ if (temp.AI && temp.AI.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.AI.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.SW && temp.SW.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.SW.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.KL && temp.KL.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.KL.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.PP && temp.PP.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.PP.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.SU && temp.SU.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.SU.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.SC && temp.SC.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.SC.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.UF && temp.UF.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.UF.length;
|
|
|
|
+ }
|
|
|
|
+ if (temp.JM && temp.JM.length > teacher.lines) {
|
|
|
|
+ teacher.lines = temp.JM.length;
|
|
|
|
+ }
|
|
|
|
+ const equipments: EquipmentShown[] = [];
|
|
|
|
+ for (let i = 0; i < teacher.lines; i++) {
|
|
|
|
+ let item: EquipmentShown = {
|
|
|
|
+ AI: temp.AI[i]?.sn || "",
|
|
|
|
+ SW: temp.SW[i]?.sn || "",
|
|
|
|
+ KL: temp.KL[i]?.sn || "",
|
|
|
|
+ PP: temp.PP[i]?.sn || "",
|
|
|
|
+ SU: temp.SU[i]?.sn || "",
|
|
|
|
+ SC: temp.SC[i]?.sn || "",
|
|
|
|
+ UF: temp.UF[i]?.sn || "",
|
|
|
|
+ JM: temp.JM[i]?.sn || "",
|
|
|
|
+ };
|
|
|
|
+ equipments.push(item);
|
|
|
|
+ }
|
|
|
|
+ teacher.equipment = equipments;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch((error) => {
|
|
|
|
+ console.log(error);
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+// 打开教师面板请求数据
|
|
|
|
+function collapseTeacher(teacher: TeacherItem) {
|
|
|
|
+ if (!teacher.grades || teacher.grades.length === 0) {
|
|
|
|
+ getGradeAndEquipment(teacher);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+// 搜索
|
|
|
|
+function teacherSearch() {
|
|
|
|
+ getTeacherData(userStore.schoolId, searchKeyword.value);
|
|
|
|
+}
|
|
|
|
+onMounted(() => {
|
|
|
|
+ // 获取教师
|
|
|
|
+ getTeacherData(userStore.schoolId, "");
|
|
|
|
+});
|
|
|
|
+watch(
|
|
|
|
+ () => userStore.schoolId,
|
|
|
|
+ (newValue) => {
|
|
|
|
+ searchKeyword.value = "";
|
|
|
|
+ // 学校切换后重新获取教师
|
|
|
|
+ getTeacherData(newValue, "");
|
|
|
|
+ }
|
|
|
|
+);
|
|
watch(
|
|
watch(
|
|
() => userStore.schoolId,
|
|
() => userStore.schoolId,
|
|
(newValue, oldValue) => {
|
|
(newValue, oldValue) => {
|
|
console.log(newValue, oldValue);
|
|
console.log(newValue, oldValue);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
-
|
|
|
|
-let teacherInfo = ref("");
|
|
|
|
-// 折叠面板active
|
|
|
|
-const activeItem = ref();
|
|
|
|
-const tableData = ref<any>([
|
|
|
|
- {
|
|
|
|
- e1: "AI00000000",
|
|
|
|
- e2: "AI00000000",
|
|
|
|
- e3: "AI00000000",
|
|
|
|
- e4: "AI00000000",
|
|
|
|
- e5: "AI00000000",
|
|
|
|
- e6: "AI00000000",
|
|
|
|
- e7: "AI00000000",
|
|
|
|
- e8: "AI00000000",
|
|
|
|
- cls: "TomTomTom",
|
|
|
|
- },
|
|
|
|
-]);
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -39,45 +133,62 @@ const tableData = ref<any>([
|
|
<!-- 教师查找 -->
|
|
<!-- 教师查找 -->
|
|
<div class="teacher-search">
|
|
<div class="teacher-search">
|
|
<el-input
|
|
<el-input
|
|
- v-model="teacherInfo"
|
|
|
|
|
|
+ v-model="searchKeyword"
|
|
size="large"
|
|
size="large"
|
|
placeholder="请输入教师名称或手机号码"
|
|
placeholder="请输入教师名称或手机号码"
|
|
/>
|
|
/>
|
|
- <el-button size="large" type="primary">查找</el-button>
|
|
|
|
- <span>共<b>40</b>人</span>
|
|
|
|
|
|
+ <el-button size="large" type="primary" @click="teacherSearch()"
|
|
|
|
+ >查找</el-button
|
|
|
|
+ >
|
|
|
|
+ <span
|
|
|
|
+ >共<b>{{ teacherCount }}</b
|
|
|
|
+ >人</span
|
|
|
|
+ >
|
|
</div>
|
|
</div>
|
|
<!-- 折叠面板-->
|
|
<!-- 折叠面板-->
|
|
- <div class="list-collapse">
|
|
|
|
- <el-collapse v-model="activeItem">
|
|
|
|
- <el-collapse-item name="1">
|
|
|
|
|
|
+ <div v-for="teacher in teacherData" :key="teacher.id" class="list-collapse">
|
|
|
|
+ <el-collapse v-model="teacher.active" @change="collapseTeacher(teacher)">
|
|
|
|
+ <el-collapse-item :name="teacher.id">
|
|
<template #title>
|
|
<template #title>
|
|
<div class="title">
|
|
<div class="title">
|
|
- <span class="blue mr-10">松阪老师</span>
|
|
|
|
- <span>注册时间:2023-02-23</span>
|
|
|
|
|
|
+ <span class="blue mr-10">{{ teacher.name }}</span>
|
|
|
|
+ <span>注册时间:{{ teacher.create_time }}</span>
|
|
<span class="blue fr"
|
|
<span class="blue fr"
|
|
>负责班级 & 绑定设备
|
|
>负责班级 & 绑定设备
|
|
<el-icon
|
|
<el-icon
|
|
:class="
|
|
:class="
|
|
- activeItem && activeItem.includes('1') ? 'is-active' : ''
|
|
|
|
|
|
+ teacher.active && teacher.active.includes(teacher.id)
|
|
|
|
+ ? 'is-active'
|
|
|
|
+ : ''
|
|
"
|
|
"
|
|
><CaretBottom
|
|
><CaretBottom
|
|
/></el-icon>
|
|
/></el-icon>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
- <div>
|
|
|
|
- <el-table :data="tableData" style="width: 100%">
|
|
|
|
- <el-table-column prop="e1" label="水母星球脑机" align="center" />
|
|
|
|
- <el-table-column prop="e2" label="智脑水舞" align="center" />
|
|
|
|
- <el-table-column prop="e3" label="智脑恐龙" align="center" />
|
|
|
|
- <el-table-column prop="e4" label="智脑碰碰车" align="center" />
|
|
|
|
- <el-table-column prop="e5" label="智脑UFO" align="center" />
|
|
|
|
- <el-table-column prop="e6" label="智脑SUV" align="center" />
|
|
|
|
- <el-table-column prop="e7" label="智脑赛车" align="center" />
|
|
|
|
- <el-table-column prop="e8" label="智脑积木" align="center" />
|
|
|
|
- <el-table-column prop="cls" label="负责班级" align="center" />
|
|
|
|
- </el-table>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="19">
|
|
|
|
+ <el-table :data="teacher.equipment" style="width: 100%">
|
|
|
|
+ <el-table-column
|
|
|
|
+ prop="AI"
|
|
|
|
+ label="水母星球脑机"
|
|
|
|
+ align="center"
|
|
|
|
+ />
|
|
|
|
+ <el-table-column prop="SW" label="智脑水舞" align="center" />
|
|
|
|
+ <el-table-column prop="KL" label="智脑恐龙" align="center" />
|
|
|
|
+ <el-table-column prop="PP" label="智脑碰碰车" align="center" />
|
|
|
|
+ <el-table-column prop="UF" label="智脑UFO" align="center" />
|
|
|
|
+ <el-table-column prop="SU" label="智脑SUV" align="center" />
|
|
|
|
+ <el-table-column prop="SC" label="智脑赛车" align="center" />
|
|
|
|
+ <el-table-column prop="JM" label="智脑积木" align="center" />
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="5" class="grade">
|
|
|
|
+ <el-table :data="teacher.grades" style="width: 100%">
|
|
|
|
+ <el-table-column prop="name" label="负责班级" align="center" />
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
</el-collapse-item>
|
|
</el-collapse-item>
|
|
</el-collapse>
|
|
</el-collapse>
|
|
</div>
|
|
</div>
|
|
@@ -152,4 +263,13 @@ const tableData = ref<any>([
|
|
:deep(.el-table th.el-table__cell) {
|
|
:deep(.el-table th.el-table__cell) {
|
|
background: #e9ebee;
|
|
background: #e9ebee;
|
|
}
|
|
}
|
|
|
|
+:deep(.el-table .el-table__row) {
|
|
|
|
+ min-height: 40px;
|
|
|
|
+}
|
|
|
|
+.grade {
|
|
|
|
+ border-left: 1px solid #dddddd;
|
|
|
|
+}
|
|
|
|
+:deep(.grade .el-table th.el-table__cell) {
|
|
|
|
+ background: #dddddd;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|