|
|
@@ -77,7 +77,7 @@
|
|
|
v-hasPermi="['dz:teacher:edit']"
|
|
|
>修改</el-button>
|
|
|
</el-col>
|
|
|
- <el-col :span="1.5">
|
|
|
+ <!-- <el-col :span="1.5">
|
|
|
<el-button
|
|
|
type="danger"
|
|
|
plain
|
|
|
@@ -86,7 +86,7 @@
|
|
|
@click="handleDelete"
|
|
|
v-hasPermi="['dz:teacher:remove']"
|
|
|
>删除</el-button>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
|
type="warning"
|
|
|
@@ -110,7 +110,7 @@
|
|
|
<el-table-column label="培训校区班级" align="center" prop="campusClass" />
|
|
|
<el-table-column label="所在机构" align="center" prop="deptName" />
|
|
|
<el-table-column label="用户ID" align="center" prop="userId" />
|
|
|
- <el-table-column label="状态" align="center" key="status">
|
|
|
+ <el-table-column label="禁用状态" align="center" key="status">
|
|
|
<template #default="scope">
|
|
|
<el-switch
|
|
|
v-model="scope.row.status"
|
|
|
@@ -125,7 +125,7 @@
|
|
|
<el-button link type="primary" icon="" @click="handleUpdateTeacherClass(scope.row)" v-hasPermi="['dz:teacher:edit']">学校班级</el-button>
|
|
|
<el-button link type="primary" icon="" @click="handleUpdateCampusClass(scope.row)" v-hasPermi="['dz:teacher:edit']">校区班级</el-button>
|
|
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['dz:teacher:edit']">修改</el-button>
|
|
|
- <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['dz:teacher:remove']">删除</el-button>
|
|
|
+ <!-- <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['dz:teacher:remove']">删除</el-button> -->
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -148,7 +148,7 @@
|
|
|
<el-input v-model="form.name" placeholder="请输入教师姓名" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="所在学校" prop="schoolId">
|
|
|
- <el-select v-model="form.schoolId" placeholder="请选择所在学校" style="width: 100%">
|
|
|
+ <el-select v-model="form.schoolId" placeholder="请选择所在学校" style="width: 100%" @change="handleSchoolChange">
|
|
|
<el-option
|
|
|
v-for="item in schoolOptions"
|
|
|
:key="item.id"
|
|
|
@@ -157,8 +157,18 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="学校班级" prop="schoolClassIds">
|
|
|
+ <el-select v-model="form.schoolClassIds" multiple placeholder="请选择学校班级" style="width: 100%" :disabled="!form.schoolId">
|
|
|
+ <el-option
|
|
|
+ v-for="item in schoolClassOptions"
|
|
|
+ :key="item.classId"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.classId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="培训校区" prop="campusId">
|
|
|
- <el-select v-model="form.campusId" placeholder="请选择培训校区" style="width: 100%">
|
|
|
+ <el-select v-model="form.campusId" placeholder="请选择培训校区" style="width: 100%" @change="handleCampusChange">
|
|
|
<el-option
|
|
|
v-for="item in campusOptions"
|
|
|
:key="item.id"
|
|
|
@@ -167,6 +177,17 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="校区班级" prop="campusClassIds">
|
|
|
+ <el-select v-model="form.campusClassIds" multiple placeholder="请选择校区班级" style="width: 100%" :disabled="!form.campusId">
|
|
|
+ <el-option
|
|
|
+ v-for="item in campusClassOptions"
|
|
|
+ :key="item.classId"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.classId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
@@ -218,7 +239,7 @@
|
|
|
v-model="formCampusClass.campusId"
|
|
|
placeholder="请选择培训校区"
|
|
|
style="width: 100%"
|
|
|
- @change="handleCampusChange"
|
|
|
+ @change="handleCampusClassChange"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in campusOptions"
|
|
|
@@ -259,7 +280,7 @@
|
|
|
import { listTeacher, getTeacher, delTeacher, addTeacher, updateTeacher } from "@/api/dz/teacher"
|
|
|
import {listAllSchool} from "@/api/dz/school"
|
|
|
import {listCampus} from "@/api/dz/campus"
|
|
|
-import { listAllClass } from "@/api/dz/classes"
|
|
|
+import { listAllClass, getClassesBySchoolId } from "@/api/dz/classes"
|
|
|
import { batchBindTeacherClass,listAllTeacherClass } from "@/api/dz/teacherclass"
|
|
|
import {getCampusSchoolList} from "@/api/dz/cards.js";
|
|
|
import { changeUserStatus } from "@/api/system/user"
|
|
|
@@ -271,6 +292,7 @@ const schoolOptions = ref([])
|
|
|
const campusOptions = ref([])
|
|
|
const classOptions = ref([])
|
|
|
const campusClassOptions = ref([])
|
|
|
+const schoolClassOptions = ref([])
|
|
|
const open = ref(false)
|
|
|
const openTeacherClass = ref(false)
|
|
|
const openCampusClass = ref(false)
|
|
|
@@ -375,8 +397,12 @@ function reset() {
|
|
|
userId: null,
|
|
|
schoolId: null,
|
|
|
campusId: null,
|
|
|
- name: null
|
|
|
+ name: null,
|
|
|
+ schoolClassIds: [],
|
|
|
+ campusClassIds: []
|
|
|
}
|
|
|
+ schoolClassOptions.value = []
|
|
|
+ campusClassOptions.value = []
|
|
|
proxy.resetForm("teacherRef")
|
|
|
}
|
|
|
|
|
|
@@ -421,6 +447,8 @@ function handleSelectionChange(selection) {
|
|
|
/** 新增按钮操作 */
|
|
|
function handleAdd() {
|
|
|
reset()
|
|
|
+ getSchoolList()
|
|
|
+ getCampusList()
|
|
|
open.value = true
|
|
|
title.value = "添加老师"
|
|
|
}
|
|
|
@@ -428,14 +456,147 @@ function handleAdd() {
|
|
|
/** 修改按钮操作 */
|
|
|
function handleUpdate(row) {
|
|
|
reset()
|
|
|
+ getSchoolList()
|
|
|
+ getCampusList()
|
|
|
const _teacherId = row.teacherId || ids.value
|
|
|
getTeacher(_teacherId).then(response => {
|
|
|
form.value = response.data
|
|
|
+ // 初始化班级ID数组
|
|
|
+ form.value.schoolClassIds = []
|
|
|
+ form.value.campusClassIds = []
|
|
|
+
|
|
|
+ // 先加载班级列表,然后获取已关联的班级并回显
|
|
|
+ const loadPromises = []
|
|
|
+
|
|
|
+ if (form.value.schoolId) {
|
|
|
+ loadPromises.push(
|
|
|
+ getClassesBySchoolId({ schoolId: form.value.schoolId }).then(response => {
|
|
|
+ schoolClassOptions.value = response.data || []
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ if (form.value.campusId) {
|
|
|
+ loadPromises.push(
|
|
|
+ getClassesBySchoolId({ campusId: form.value.campusId }).then(response => {
|
|
|
+ campusClassOptions.value = response.data || []
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取该老师已关联的所有班级
|
|
|
+ Promise.all([
|
|
|
+ ...loadPromises,
|
|
|
+ listAllTeacherClass({ teacherId: _teacherId })
|
|
|
+ ]).then((results) => {
|
|
|
+ const teacherClassResponse = results[results.length - 1]
|
|
|
+ const teacherClasses = teacherClassResponse.data || []
|
|
|
+
|
|
|
+ // 根据班级所属的学校/校区,分别设置到对应的数组中
|
|
|
+ teacherClasses.forEach(tc => {
|
|
|
+ if (tc.classId) {
|
|
|
+ // 检查该班级是否属于学校
|
|
|
+ const schoolClass = schoolClassOptions.value.find(c => c.classId === tc.classId)
|
|
|
+ if (schoolClass) {
|
|
|
+ if (!form.value.schoolClassIds) {
|
|
|
+ form.value.schoolClassIds = []
|
|
|
+ }
|
|
|
+ form.value.schoolClassIds.push(tc.classId)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查该班级是否属于校区
|
|
|
+ const campusClass = campusClassOptions.value.find(c => c.classId === tc.classId)
|
|
|
+ if (campusClass) {
|
|
|
+ if (!form.value.campusClassIds) {
|
|
|
+ form.value.campusClassIds = []
|
|
|
+ }
|
|
|
+ form.value.campusClassIds.push(tc.classId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
open.value = true
|
|
|
title.value = "修改老师"
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+/** 学校变化处理 */
|
|
|
+function handleSchoolChange() {
|
|
|
+ // 如果是编辑模式,不清空已选班级,只更新选项列表
|
|
|
+ if (!form.value.teacherId) {
|
|
|
+ form.value.schoolClassIds = []
|
|
|
+ }
|
|
|
+ schoolClassOptions.value = []
|
|
|
+ if (form.value.schoolId) {
|
|
|
+ getClassesBySchoolId({ schoolId: form.value.schoolId }).then(response => {
|
|
|
+ schoolClassOptions.value = response.data || []
|
|
|
+ // 如果是编辑模式,需要重新匹配已关联的班级
|
|
|
+ if (form.value.teacherId) {
|
|
|
+ loadTeacherClassesForEdit()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 校区变化处理 */
|
|
|
+function handleCampusChange() {
|
|
|
+ // 如果是编辑模式,不清空已选班级,只更新选项列表
|
|
|
+ if (!form.value.teacherId) {
|
|
|
+ form.value.campusClassIds = []
|
|
|
+ }
|
|
|
+ campusClassOptions.value = []
|
|
|
+ if (form.value.campusId) {
|
|
|
+ getClassesBySchoolId({ campusId: form.value.campusId }).then(response => {
|
|
|
+ campusClassOptions.value = response.data || []
|
|
|
+ // 如果是编辑模式,需要重新匹配已关联的班级
|
|
|
+ if (form.value.teacherId) {
|
|
|
+ loadTeacherClassesForEdit()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 编辑模式下加载已关联的班级 */
|
|
|
+function loadTeacherClassesForEdit() {
|
|
|
+ if (!form.value.teacherId) return
|
|
|
+
|
|
|
+ listAllTeacherClass({ teacherId: form.value.teacherId }).then(response => {
|
|
|
+ const teacherClasses = response.data || []
|
|
|
+
|
|
|
+ // 重置班级ID数组
|
|
|
+ form.value.schoolClassIds = []
|
|
|
+ form.value.campusClassIds = []
|
|
|
+
|
|
|
+ // 根据班级所属的学校/校区,分别设置到对应的数组中
|
|
|
+ teacherClasses.forEach(tc => {
|
|
|
+ if (tc.classId) {
|
|
|
+ // 检查该班级是否属于学校
|
|
|
+ const schoolClass = schoolClassOptions.value.find(c => c.classId === tc.classId)
|
|
|
+ if (schoolClass) {
|
|
|
+ if (!form.value.schoolClassIds) {
|
|
|
+ form.value.schoolClassIds = []
|
|
|
+ }
|
|
|
+ if (!form.value.schoolClassIds.includes(tc.classId)) {
|
|
|
+ form.value.schoolClassIds.push(tc.classId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查该班级是否属于校区
|
|
|
+ const campusClass = campusClassOptions.value.find(c => c.classId === tc.classId)
|
|
|
+ if (campusClass) {
|
|
|
+ if (!form.value.campusClassIds) {
|
|
|
+ form.value.campusClassIds = []
|
|
|
+ }
|
|
|
+ if (!form.value.campusClassIds.includes(tc.classId)) {
|
|
|
+ form.value.campusClassIds.push(tc.classId)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
/** 提交按钮 */
|
|
|
function submitForm() {
|
|
|
proxy.$refs["teacherRef"].validate(valid => {
|
|
|
@@ -477,7 +638,7 @@ function handleExport() {
|
|
|
|
|
|
/** 用户状态修改 */
|
|
|
function handleStatusChange(row) {
|
|
|
- let text = row.status === "0" ? "启用" : "关闭"
|
|
|
+ let text = row.status === "0" ? "启用" : "禁用"
|
|
|
proxy.$modal.confirm('确认要"' + text + '""' + row.name + '"用户吗?').then(function () {
|
|
|
return changeUserStatus(row.userId, row.status)
|
|
|
}).then(() => {
|
|
|
@@ -569,8 +730,8 @@ function handleUpdateCampusClass(row) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/** 校区选择变化时,加载该校区的班级列表 */
|
|
|
-function handleCampusChange(campusId) {
|
|
|
+/** 校区班级弹窗中校区选择变化时,加载该校区的班级列表 */
|
|
|
+function handleCampusClassChange(campusId) {
|
|
|
if (campusId) {
|
|
|
loadCampusClasses(campusId, formCampusClass.value.teacherId)
|
|
|
// 清空已选择的班级
|